Posts

Showing posts from March, 2013

anypoint studio - Mule Dataweave format :number -

i'm having issue trying parse string double sample code, it's returning integer instead of type :double ideas? { "data": "22" :number { format: "##.##" } } this, , this, works me; %dw 1.0 %output application/json --- { data: "22" :number :string {format: ".00"} :number } format seems add zeros when converting number string. if "22" have been number wouldn't need first :number conversion; data: 22 :string {format: ".00"} :number the latter number conversion makes output float. otherwise string, formatted according hosts locale. and beware. when using %output text/json instead, above code in cases produces 22.0 instead of 22.00 .

c# - Call a non-default constructor in from a generic list instantiation -

i have class called fred constructor takes parameter parma want pass initialisation of generic list of type multictorclass called mylist. the default constructor multictorclass passes parmb base; want call other constructor of multictorclass passing in parma initialisation of fred. public class fred { public fred(parmtype parma) { mylist = new list<multictorclass>(); } public ienumerable<multictorclass> mylist { get; set; } } public class multictorclass : mybase { public multictorclass() : this(parmb) { } public multictorclass(parmtype parm) : base(parm) { } } i trying following: public fred(parmtype parma) { mylist = new list<multictorclass(parma)>(); } how can achieved? you're not calling constructor in either case - list empty. call constructor when creating new item, e.g. mylist.add(new multictorclass(...)); and can pick constructor @ there :)

Deleting elements in Python list using user input -

name=input("enter name: ") message=input("enter message:") namefinal=list(name) namefinal in message: del(namefinal) print(message) i need creating program gets message user , removes of letters in user’s name. made user input(name) list don't know how delete letters. example if type in charan , message lebron james delete r,a,and n lebron james, making lebo jmes . you can this: name=input("enter name: ") message=input("enter message:") namefinal = '' letter in name: if letter not in message: namefinal += letter print namefinal

html - CSS: Issue with the third inline-block element -

below can see code has 3 lines of inline-block elements. these lines absolutely same. behavior of third line strange. see @ code snippet. what's wrong third line? why displayed weird? thank you. .partners { width: 940px; text-align: center; margin: 95px auto 0 auto; } .partners__h2 { color: #333; font-weight: bold; font-size: 22px; text-align: center; margin-bottom: 32px; } .wrap { background: #a1a1a1; } .partners li { display: inline-block; vertical-align: text-top; } .partner__wrap { bottom: 0; width: 100%; text-align: center; } .partner__name { display: block; float: left; width: 100%; font-weight: bold; color: #333; font-size: 14px; margin-bottom: 0px; } .partner__description { font-family: roboto; font-weight: 300; color: #666; font-size: 14px; text-align: center; float: left; margin-top: 10px; } .partner__1 { width: 220px; height: 100%; float: left; } .part

widget - Tcl/Tk: how to trigger bind function inside script instead of GUI operation -

in tcl/tk script, there combobox widget, , bind event it, if user change selection of combobox, bind function triggered. want trigger bind function inside script, instead of gui operation, how this? code goes following: ttk::combobox .combo_select_tag -background white; .combo_select_tag configure -value "1 2 3"; pack .combo_select_tag bind .combo_select_tag <<comboboxselected>> { puts "trigger\n" } tl;dr use event generate . the bind command associates binding script event on binding tag. each widget typically has 4 binding tags: name of widget, name of widget's class, name of widget's toplevel, , all binding tag. (the aim put customizations on individual widgets, or on toplevel have them apply whole window — which great hotkey sequences — while tk focuses on class level. global all level not used has few backstop things.) to activate binding script, need event sent widget. event generate command precisely that.

java - Android Studio - Why does the ActionBar always show, even when fully disabled? -

i started android application development , have come across issue actionbar. aware question has been asked few times, , have made changes necessary can see other articles. currently, main activity looks this: image as can see, there blue bar @ top of screen directly under notification bar actionbar supposed be. of app themes (i believe) set noactionbar. rid of blue bar can use entire screen put contents. my code follows: main_activity.java package ryanpx2016.golftracker; import android.os.bundle; import android.support.design.widget.floatingactionbutton; import android.support.design.widget.snackbar; import android.support.v7.app.appcompatactivity; import android.support.v7.widget.toolbar; import android.view.view; import android.view.menu; import android.view.menuitem; import android.widget.button; import android.content.intent; public class mainactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.o

javascript - Instantiate ViewModel from array items within an existing ViewModel. -

i've started messing knockout (tech requirement) , i'm trying build gallery custom functionality. the data coming json response represents 1 gallery (title, description, etc) , within gallery object, array of slides. to try , separate concerns i'd love have gallery-based viewmodel , separate slide viewmodel. but i'm not sure how instantiate slide viewmodel on array within object. in earlier version tried loop on array of slides not sure how i'd physical execute i'm trying set new instance of slideviewmodel on each slide object in slides array any appreciate. codepen here: http://codepen.io/pbj/pen/maolmb code here: js var testgallery = { "title" : "anna's gallery title", "slides" : [ { "title": "slide image #1", "image" : "http://google.com/image/goes/here" }, { "title": "slide image #1", "image" :

Selenium IE 32bit WebDriver is crashing -

have strange happening selenium , webdriver - using ie webdriver 32bit - when ever following code executed; on second web driver crashes following: command line server ie driver has stopped working the java code follows: // del language , add 1 (int j = 1; j <= 18; j++) { webdriverwait wait3 = new webdriverwait(driver, 20); wait3.until(expectedconditions.visibilityofelementlocated(by.xpath("//*[contains(@title,'delete language')]"))).click(); driver.findelement(by.xpath("//*[contains(@title,'delete language')]")).click(); } and console log follows: org.openqa.selenium.remote.unreachablebrowserexception: error communicating remote browser. may have died. build info: version: '2.45.0', revision: '32a636c', time: '2015-03-05 22:01:35' system info: host: 'xxxxx', ip: 'xxxxxxx', os.name: 'windows 8.1', os.arch: 'amd64', os.version: '6.3', java.vers

ios - NSPOSIXErrorDomain wher download file -

i have next code download file url. i'm getting next error: failed error: error domain=nscocoaerrordomain code=516 "“cfnetworkdownload_85dvq4.tmp” couldn’t moved “documents” because item same name exists." userinfo={nssourcefilepatherrorkey=/users/otani/library/developer/coresimulator/devices/8babc203-7fd9-4f03-bf0d-d660dd29ccde/data/containers/data/application/09c714d3-f185-4289-91db-13b21557b784/tmp/cfnetworkdownload_85dvq4.tmp, nsuserstringvariant=( move ), nsdestinationfilepath=/users/otani/library/developer/coresimulator/devices/8babc203-7fd9-4f03-bf0d-d660dd29ccde/data/containers/data/application/09c714d3-f185-4289-91db-13b21557b784/documents/temp.llg, nsfilepath=/users/otani/library/developer/coresimulator/devices/8babc203-7fd9-4f03-bf0d-d660dd29ccde/data/containers/data/application/09c714d3-f185-4289-91db-13b21557b784/tmp/cfnetworkdownload_85dvq4.tmp, nsunderlyingerror=0x7fea5a53a9a0 {error domain=nsposixerrordomain code=17 "file

Python regex expression to match pattern in sentences -

given paragraph example .this figure 3a. fig 4a . (figure 5). important (fig 6a). i python regex extract sentences based on figure number. trying this figure 3a using ([^.]*?fig. 3[^.] .) this fig 4a ([^.]*?fig. 4[^.] .) i (figure 5) ([^.]*?fig. 5[^.] .) this important (fig 6a) ([^.]*?fig. 6[^.] .) but matching not specific. number 4 example extract figures. 1 specific figures based on figure number you need replace, .* before 4 [^.]* replace 4 \d code: in[3]: s = "this figure 3a. fig 4a . (figure 5). important (fig 6a)." in[4]: import re in[5]: re.findall(r'[^.]*?fig[^.]*\d[^.]*', s) out[5]: ['this figure 3a', ' fig 4a ', ' (figure 5)', ' important (fig 6a)'] or in[8]: re.findall(r'\s*([^.]*?fig[^.]*\d[^.]*?)(?=\s*\.)', s) out[8]: ['this figure 3a', 'this fig 4a', 'i (figure 5)', 'this important (fig 6a)']

colors - How to change / assign BGCOLOR to a field/cell/row/column in a freeform query -

i using freeform query populate temp table fields. can adjust width fine cant assign color field/cell/row/column. how assign color ? you need "row display trigger" go browse widget. like: on row-display of f anywhere do: if "{&window-system}" = "tty" columnhandle:dcolor = getcolornum( "red" ). else columnhandle:fgcolor = getcolornum( "red" ). return. end. something might handy getting columnhandle: function getbrowsecolumnbyname returns handle ( z handle, n character ): define variable c handle no-undo. c = z:first-column. while valid-handle( c ): if c:name = n leave. else c = c:next-column. end. return c. end.

sql server 2008 - XML Path Loop Inline -

i utilizing sparsely populated version of tcp-h database attempting output data orders using xml path. have query find each supplier , part supply, aggregated numbers orders , wish include list of every orders info under single orders element. can in oracle single query looks like <orderedpart> <partname partkey="100">part#100</partname> <suppliername supplierkey="1">supplier#1</suppliername> <totalqty>32</totalqty> <ordercount>2</ordercount> <orders> <order orderkey="4928"> <orderdate>1993-10-04</orderdate> <orderqty>4</orderqty> </order> <order orderkey="1223"> <orderdate>1996-05-25</orderdate> <orderqty>28</orderqty> </order> </orders> </orderedpart> however, in current sql server 2008 query current outputting them sep

r - Pass column name to function from mutate_each -

i'd apply transformation columns via dplyr::mutate_each , e.g. library(dplyr) mult <- function(x,m) return(x*m) mtcars %>% mutate_each(funs(mult(.,2))) # multiply columns factor of 2 however, transformation should have parameters depending on column name. therefore, column name should passed function additional argument named.mult <- function(x,colname) return(x*param.a[[colname]]) example: multiply every column different factor: param.a <- c() param.a[names(mtcars)] <- seq(length(names(mtcars))) param.a # mpg cyl disp hp drat wt qsec vs gear carb # 1 2 3 4 5 6 7 8 9 10 11 since column name gets lost during mutate_each , work around passing list lazy evalution mutate_ (the se version): library(lazyeval) named.mutate <- function(fun, cols) sapply(cols, function(n) interp(~fun(col, n), fun=fun, col=as.name(n))) mtcars %>% mutate_(.dots=named.mutate(named.mult, names(.))) works, there special variabl

python - How to format a regex -

i trying make warning waver can known warnings in log file. the warnings in waving file copied directly log file during review of warnings. the mission here make simple possible. found directly copying bit problematic due fact warnings contain absolute paths. so added "tag" inserted warning system should for. whole string this. warning:hdlparsers:817 - ":re[.*]:/modules/top/hdl_src/top.vhd" line :re[.*]: choice . not locally static expression. the tag :re[ insert regex here ]: . in above warning string there 2 of these tags trying find using python3 regex tool. , pattern following: (:re\[.*\]\:) see regex101 reference my problem above that, when there 2 tags in string finds 1 result extended first last tag. how setup regex find each tag ? regards you can use re.findall following regex assumes regular expression inside square brackets spans :re[ ] followed ] : :re\[.*?]: see regex demo . .*? matches 0 or more characters other

[Edited]VHDL counter won't run -

Image
when num changes, counter should increase 1 num in sensitivity list. simulation says no. wonder what's wrong code. on quartus 9.0 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity tmp port ( num : in std_logic_vector(3 downto 0); counter : out std_logic_vector(3 downto 0); clr : in std_logic ); end tmp; architecture ar of tmp signal c : std_logic_vector(3 downto 0); begin process(num, clr) begin if clr'event , clr = '1' c <= "0000"; end if; c <= c + 1; end process; counter <= c; end; if use directly counter instead of c , might you. try this library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity tmp port ( num : in std_logic_vector(3 downto 0); counter : out std_logic_vector(3 downto 0); clr : in std_logic ); end tmp; architecture ar of tmp begin

redis - Tag huge list of elements with lat/long with large list of geolocation data -

i have huge list of geolocation events: event (1 billion) ------ id datetime lat long and list of point of interest loaded open street map: poi (1 million) ------ id tag (shop, restaurant, etc.) lat long i assign each each event tag of point of interest. best architecture achieve problem? tried using google bigquery have cross join , not work. open use other big data system. using dataflow can cross join pretty using cogroupbykey . using approach event , poi joining need fit in memory (dataflow automatically spill disk if list of items given key large fit in memory). here's more detail. create pcollection of events keyed latitude , longitude. create pcollection of poi keyed latitude , longitude use cogroupbykey join 2 pcollections. write dofn processes cogbkresult the dofn like: pcollection<t> finalresultcollection = cogbkresultcollection.apply(pardo.of( new dofn<kv<k, cogbkresult>, t>() { @override public void processe

objective c - Why does IDA show a method that a class-dump can't? And why can't I hook it? -

when doing class-dump on instagram (v7.7), confused on why in class, method declaration "sponsoredcontext" missing. in comparison, ida shows "-(char)sponsoredcontext" method. class dump result: @interface igfeeditemtimelinelayoutattributes : xxunknownsuperclass { bool _sponsoredcontext; bool _showexplorecontext; bool _showtimestamponfirstlayoutelement; igfeeditem* _feeditem; nsarray* _rowitems; } @property(retain, nonatomic) nsarray* rowitems; @property(assign, nonatomic) bool showtimestamponfirstlayoutelement; @property(assign, nonatomic) bool showexplorecontext; @property(assign, nonatomic) bool sponsoredcontext; @property(retain, nonatomic) igfeeditem* feeditem; -(void).cxx_destruct; -(id)commentfortexttimelinerow:(int)texttimelinerow; -(int)celltypefortexttimelinerow:(int)texttimelinerow; -(int)numberoftextrowsintimeline; -(id)initwithfeeditem:(id)feeditem sponsoredcontext:(bool)context showexplorecontext:(bool)context3 showtimestampo

How to Insert or Update table On base of Name value in Sqlite android -

public long createcountry(string code, string name, string continent, string region) { contentvalues initialvalues = new contentvalues(); initialvalues.put(key_product_type, code); initialvalues.put(key_product_name, name); initialvalues.put(key_product_quantity, continent); initialvalues.put(key_prodcut_cost, region); return mdb.insertwithonconflict(sqlite_table, null, initialvalues, sqlitedatabase.conflict_replace); } this insert or update function taking new row if name x alredy present in table row want should update suppose have 3 entry name column value has x,y,z suppose want call again function name x rest of value should update not should create column please me doing wrong . there no update-or-insert function. have manually: public void createcountry(string code, string name, string continent, string region) { contentvalues values = new contentvalues(); values.put(key_product_type, code); values.put(key

c# - NHibernate - one to one mapping of foreign key -

i have excluded many sections brevity. i have 2 classes, map 2 tables in database. speedscript , adminuser. speedscript has foreign key of adminuserid. have created one-to-one mapping works when retrieve instance of speedscript using nhibernate , admin user property correctly loaded. here's mapping <class name="speedscript" table="speedscript" lazy="false"> <id name="speedscriptid"> <column name="speedscriptid" /> <generator class="native" /> </id> <property name="scriptname"> <column name="name" /> </property> <one-to-one name="adminuser" class="adminuser" cascade="all" lazy="false" /> <class name="adminuser" table="adminuser" lazy="false"> <id name="adminuserid"> <column name="adminuserid" /> <generator

c# - How to group data on the YAxis of a .NET chart? -

Image
i have .net chart looks this: here code used generate it: protected void page_load(object sender, eventargs e) { // set chart properties ganttchart.width = 800; ganttchart.height = 500; // create chart area var area = new chartarea(); ganttchart.chartareas.add(area); ganttchart.chartareas[0].axisy.labelstyle.angle = 30; // unknown reason y-axis x-axis ganttchart.chartareas[0].axisy.labelstyle.format = "hh:mm dd/mmm";; // set data var dt = new datatable(); dt.columns.add("name", typeof(string)); dt.columns.add("seriesid", typeof(double)); dt.columns.add("y", typeof(datetime)); dt.columns.add("y2", typeof(datetime)); dt.rows.add("a", 1, new datetime(2015, 10, 22, 8, 0, 0), new datetime(2015, 10, 22, 9, 0, 0)); dt.rows.add("a", 1, new datetime(2015, 10, 22, 10, 0, 0), new datetime(2015, 10, 22, 12, 0, 0)); dt.rows.add("a", 1, new datetime(2015, 10, 22, 1

python - Typeerror:list indices must be integers, not tuple -

i have got error in type of indices. tried run code got complied error can see in python idle below. the code: def triples(self, (sub, pred, obj)): #generator on triple store. #returns triples match given triple pattern. # check terms present in order use correct index: try: if sub != none: if pred != none: # sub pred obj if obj != none: if obj in self._spo[sub][pred]: yield (sub, pred, obj) # sub pred none else: retobj in self._spo[sub][pred]: yield (sub, pred, retobj) else: # sub none obj if obj != none: retpred in self._osp[obj][sub]: yield (sub, retpred, obj) # sub none none else: retpred, objset in self._spo[sub].items(): retobj in objset: yield (sub, retpred, retobj

Invert map and reduceByKey in Spark-Scala -

i'm have csv dataset want process using spark, second column of format: yyyy-mm-dd hh:mm:ss i want group each mm-dd val days : rdd = sc.textfile(<csv file>) val partitioned = days.map(row => { row.split(",")(1).substring(5,10) }).invertthemap.grouporreducebykey the result of grouporreducebykey of form: ("mm-dd" -> (row1, row2, row3, ..., row_n) ) how should implement invertthemap , grouporreducebykey ? i saw in python here wonder how done in scala? this should trick val testdata = list("a, 1987-09-30", "a, 2001-09-29", "b, 2002-09-30") val input = sc.parallelize(testdata) val grouped = input.map{ row => val columns = row.split(",") (columns(1).substring(6, 11), row) }.groupbykey() grouped.foreach(println) the output is (09-29,compactbuffer(a, 2001-09-29)) (09-30,compactbuffer(a, 1987-09-30, b, 2002-09-30))

android - Apply multiple whereNotEqualTo() to ParseQuery -

parsequery<user> searchuserquery = parsequery.getquery(user.class); searchuserquery.wherenotequalto("objectid", parseuser.getcurrentuser().getobjectid()); searchuserquery.wherenotequalto("objectid", "some object id"); i getting current user in result. means second wherenotequalto() applied query. may know how apply multiple wherenotequalto() parsequery? you can pass array of string of users objectid string[] listobjectid= {"objectid1", "objectid2", "objectid3"}; query.wherenotequalto("objectid", arrays.aslist(listobjectid));

swift - iOS: Large UIAlertController ActionSheet bouncing while scrolling and not showing line separators -

Image
i have two questions long action sheet including 20 options (larger screen height): question 1 . how disable vertical bounces while scrolling? question 2 . how show line separators while scrolling bottom? missing line separators of question 2 : i using xcode 6.4 , ios 8.4 simulator. 2 issues exist ipad running same code on ios 9.0.2. i have created action sheet using uialertcontrollerstyle.actionsheet . have added 20 options in action sheet using addaction . my viewcontroller .swift below: override func viewdidload() { super.viewdidload() let button = uibutton(frame: cgrectmake(50, 60, 200, 20)) button.settitle("press", forstate: uicontrolstate.normal) button.settitlecolor(uicolor.bluecolor(), forstate: uicontrolstate.normal) button.addtarget(self, action: "btnpressed:", forcontrolevents: uicontrolevents.touchupinside) view.addsubview(button) } func btnpressed(sender: uibutton) { let controller = uialertcontroller(

php - Cakephp could not create tmp folder -

i'm using vagrant setup centos 6.6 x86_64 virtual os. have installed apache , cakephp it. i have let apache run vagrant user , in vagrant group. , vagrant's vagrantfile has line config.vm.synced_folder "./gym", "/var/www", mount_options: ["dmode=777", "fmode=777"] . after run index.php, cakephp report error: php warning: /var/www/gym_new/app/tmp/cache/persistent/ not writable in /var/www/cake_2_6/cake/cache/engine/fileengine.php on line 385 php warning: _cake_core_ cache unable write 'file_map' file cache in /var/www/cake_2_6/cake/cache/cache.php on line 328 so open fileengine.php there code trigger error: /** * determine cache directory writable * * @return bool */ protected function _active() { $dir = new splfileinfo($this->settings['path']); if (configure::read('debug')) { $path = $dir->getpathname(); if (!is_dir($path)) {

c# - Why foreach loop fails at last row of gridview? -

i have put code color background of gridview cell# 14 if cell's text != "nbsp;" , work except last row. doesn't color last row isn't equal "nbsp;" protected void grdviewcases_rowdatabound(object sender, gridviewroweventargs e) { if (e.row.rowtype == datacontrolrowtype.datarow) { foreach (gridviewrow gr in grdviewcases.rows) { if (gr.cells[14].text != "&nbsp;") { gr.cells[14].backcolor = color.red; ; gr.cells[14].forecolor = color.whitesmoke; } } } } you need not loop rows in rowdatabound event, may use e object reference each row protected void grdviewcases_rowdatabound(object sender, gridviewroweventargs e) { if (e.row.rowtype == datacontrolrowtype.datarow) { if (e.row.cells[14].text != "&nbsp;") {

c# - Update Panel - The ScriptManager must appear before any controls that need it -

i tried put update panel in aspx form, keeps on showing error. scriptmanager must appear before controls need it this aspx <form id="form1" runat="server" class="form-horizontal"> <div class="col-lg-6"> <%--<asp:panel id="pnlexisting" runat="server"> <div class="alert alert-danger" role="danger"> <i class="glyphicon glyphicon-exclamation-sign"></i> <asp:label id="recordcheck" runat ="server"> </asp:label> </div> </asp:panel>--%> <div class="form-group"> <label class="control-label col-lg-4">project</label> <div class="col-lg-8"> <asp:dropdownlist id="ddlprojects" runat="server" class="form-control" autopostba

angularjs - Angular curly braces not processed for lazy loading directive -

i trying use 2 directives inside directive, last directive compiled content still has it's curly braces.it lazy loading directive, happens when click on image. idea why happens? here demo: demo on plnker (function (angular) { angular.module("app", []).directive("expandinggrid", [ "$http", function($window) { return { restrict: "e", templateurl:"grid.tmpl.html", controller: [ "$scope", "$http", "$attrs", function($scope, $http, $attrs) { var self = this; $scope.items = []; var $element = $attrs.$$element; $scope.items = [{title:"emanuel", desciption:"taking test"}]; } ] } } ]).directive("griditem", [ "$timeou

javascript - Why is alert de[fine]d, and then two lines later, it's not (Meteor)? -

i've got code insert document mongodb collection: meteor.methods({ 'insertperson': function(firstname, lastname, streetaddr1, streetaddr2, placename, stateorprov, zipcode, emailaddr, phone, notes) { console.log('insertperson reached'); // todo: remove before deploying check(firstname, string); . . . alert('phone ' + phone); var textaddrasemailaddr = meteor.call('gettextaddrasemailaddr', phone); alert('textaddrasemailaddr ' + textaddrasemailaddr); . . . ...i see first alert ("phone 087163281"), not second; meteor console says alert not defined: i20151022-07:22:49.659(-7)? insertperson reached i20151022-07:22:49.881(-7)? exception while invoking method 'insertperson' refer enceerror: alert not defined i20151022-07:22:49.881(-7)? @ [object object].meteor.methods.insertperson ( both/methods.js:15:9) i20151022-07:22:49.882(-7)? @ maybeauditargumentchec

subset - R help- creating a sub-data set -

i have large dataset (38053 rows= transcripts, 39 columns=samples) want make new dataset sample values group of transcripts. x= data1["698568366",] works single transcript, "698568366" name of transcript but instead of 1 @ time, want use lits of 3000 i thought should able use: data1[data1[,1] %in% 3000_m,] where 3000_m list in matrix form, but keep getting back <0 rows> (or row.names mit length 0) here arrays , b: a = c(1:10) b = c(11:20) creating dataframe them: df = data.frame(a, b) here index array: ind = c(3, 5, 7) select rows indexed ind: new_df = df[ind,] you can't use multidimensional arrays index (as far know).