Posts

jquery - javascript issue on reloading data from div element -

i have <div id=x><textarea>data</textarea></div> data populated via ajax request. if change text (by typing in textarea) , if fire event on keypress/change old data value (alert displays old data)... $(function(){ $('#x').change(function(event){ xx=$('#x').html(); alert(xx); }) }); keydown , keypress fire before input's value updated. try keyup instead. also, change event fires once element loses focus, , @jinggoy mentioned, should attached inputs. jsbin: http://jsbin.com/vitomatocu/1/edit?html,js,console,output

batch file - How to send wild card attachment? -

this batch file ( date.bat ) copy file based on current date new folder: copy c:\test\output.csv c:\test2\output%date:~-4,4%_%date:~-10,2%_%date:~7,2%.csv this email.vbs script send attachment user: set objmessage = createobject("cdo.message") objmessage.subject = "test123" objmessage.from = "spartan@test.com" objmessage.to = "test123@test.com" objmessage.htmlbody = strhtml objmessage.addattachment "c:\test\output.csv" '==this section provides configuration information remote smtp server. '==normally change server name or ip. objmessage.configuration.fields.item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'name or ip of remote smtp server objmessage.configuration.fields.item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "spartan-dev" 'server port (typically 25) objmessage.configuration.fields.item _ ("http://schemas.microsoft....

string - how to convert "user_id" to "userId" in Java? -

this question has answer here: what simplest way convert java string caps (words separated underscores) camelcase (no word separators)? 17 answers convert string camelcase eg: "user_id" "userid" "user_name" "username" "country_province_city" "countryprovincecity" how in easy way? ps:"country_province_city" should "countryprovincecity" not "countryprovincecity" i use loop , stringbuilder . like string[] arr = { "user_id", "user_name", "country_province_city" }; (string str : arr) { stringbuilder sb = new stringbuilder(str); int pos; while ((pos = sb.indexof("_")) > -1) { string ch = sb.substring(pos + 1, pos + 2); sb.replace(pos, pos + 2, ch.touppercase()); } system.out.printf("%s...

python - Regex taking forever on short string. -

i'm looking through bunch of strings, trying match following pattern. location_pattern = re.compile( r""" \b (?p<location> ([a-z]\w*[ -]*)+[, ]+ ( [a-z]{2} | [a-z]\w+\ *\d ## ) ) \b """, flags=re.verbose) now regex runs ok on data set, takes forever (well, 5 seconds) on this particular string: ' javascript software architect, successful serial' there bunch of strings 1 (all caps, lots of space chars) @ point in input data , program slowed when hits it. tried taking out different parts of regex, , turns out culprit the \ *\d @ end of co...

Hamcrest matchers json subarray: is there a way to use hasItems to look for items in a subarray? -

for example, had following json response: { "0": { "field1" : 5 "field2" : 10 } "1": { "field1" : 1 "field2" : 10 } } is there way verify field1 has values 5 , 1? stuck @ .body statement here: .body("[0].field1", matchers.hasitems(1)); it totally possible not understand hasitems supposed do, since tried lots of combinations of [0], [*], , field names , none of them work. wish there usage article hamcrest , json didn't cover basic cases. know if asking possible? thanks reading. first of "json document" not valid. should this: { "0": { "field1" : 5, "field2" : 10 }, "1": { "field1" : 1, "field2" : 10 } } since you're targeting path matches single ...

r - Finding value that corresponds to same location in another matrix -

i trying factor scores each person. factors stored in dataframe factors need average of values in dataframe called data of values correspond factors , store in new column in data . apologize terrible explanation. hope example help, , happy answer questions! factors<-data.frame(c(na,2,na),c(na,3,1)) colnames(factors)<-c("v1","v2") row.names(factors)<-c("col1data","col2data","col3data") factors data<-data.frame(c(2,4,2),c(1,1,2),c(3,3,3)) colnames(data)<-c("col1data","col2data","col3data") row.names(data)<-c("person1","person2","person3") data #in dataframe factors row col2data present (i.e. not na) under factor v1 #go dataframe data each person , make new column called v1 holds value of col2data #do factor v2 , average values come 1 number each person. final result data<-data.frame(c(2,4,2),c(1,1,2),c(3,3,3),c(1,1,2),c(2,3,2.5)) colnames(data)<-...

perl - Creating an array of arrays for GD::Graph -

all right, i'm trying make array of arrays in perl use gd::graph module. , can't figure out why following not valid array of arrays gd::graph. my @t = (1, 2, 3, 4); @g = (2, 4, 5, 6); @data = (@t, @g); i've tried constructing data below, , still not it. my @data; push @data, @t; push @data, @g; i want keep values in seperate arrays , combine them use gd::graph, because i've found easiest way, if ugly. how go creating valid structure use gd::graph, created on fly? it complains here. my $gd = $graph->plot(\@data) or die $graph->error; looks @data single dimension array 8 elements. you can define array of arrays using anonymous array constructor [] my @data = ( [1, 2, 3, 4], [2, 4, 5, 6] );