Posts

r - Finding the Column Index for a Specific Value -

i having brain cramp. below toy dataset: df <- data.frame( id = 1:6, v1 = c("a", "a", "c", na, "g", "h"), v2 = c("z", "y", "a", na, "a", "g"), stringsasfactors=f) i have specific value want find across set of defined columns , want identify position located in. fields searching characters , trick value looking might not exist. in addition, null strings present in dataset. assuming knew how this, variable position indicates values returned. > df id v1 v2 position 1 1 z 1 2 2 y 1 3 3 c 2 4 4 <na> <na> 99 5 5 g 2 6 6 h g 99 the general rule want find position of value "a", , if not located or if v1 missing, want 99 returned. in instance, searching across v1 , v2, in reality, have 10 different variables. worth noting value search...

datetime - time difference's seems like working odd? -

i going find difference between 2 times not getting want!!! have 2 timeedit components in form here code: void __fastcall tform1::button1click(tobject *sender) { ttime time1=strtotime(t1->text); ttime time2=strtotime(t2->text); //t1->text=time2-strtotime("3:00"); showmessage((time2-time1).timestring()); } if set t1 = 02:00 , set t2 = 01:00 it shows 1:00 but expect 23:00 01:00 - 02:00 should 23:00 where wrong ? you not taking account how ttime encoded. tdatetime double , integral portion contains number of days since dec 30 1899, , fractional portion contains percentage of 24-hour day (this information stated in c++builder documentation). ttime fractional portion of tdatetime integral portion ignored. because of encoding, performing such seemingly simple mathematical operations on date/time values not produce kind of result expecting. 02:00 (2 am) represented 0.083333333333 , , 01:00 (1 am) represented 0.04166...

security - how to secure keys for API calls from android device to amazon services -

so writing app android push data on amazon s3 storage later read. using amazons sdk make calls requires me store public , private keys within app. there way secure them couldn't extracted reverse engineering? possible since making direct calls device? or option run proxy server (on ec2) , pass data through it? thanks help! step 1. use https step 2. aes encrypt keys in application other that, there's not can do, other using proxy server (option mentioned)

Creating and populating an array with a fixed width in JavaScript -

i've got input array in format: [[timestamp, jobid, time completion],[..]] the data sql db, grouped both timestamp, , jobid, array looks like: [ [1, 30, 400], [1, 31, 200], [2, 29, 300], .. ] i create new array 1 column every jobid, instead of 1 row every job id, is, single row per timestamp. so, wrote code iterated through above array, , populated new array, simple enough, except, result array isn't fixed width, is, result looks like: [ [1, 400, 200], [2, 300] .. ] which makes impossible me values [1] job id 30, can't have meaningful header row. is, data in format: timestamp, jobid29, jobid30, jobid31 [ [1, 0, 400, 200], [2, 300, 0, 0], .. ] i can't output map, unfortunately. how can achieve this? know i'll haveto go through input once distinct jobids, , guess i'd map each jobid position, etc, i'm wondering if best way? thank you. my solution uses 2 arrays , 2 maps plenty of possibilities optim...

java - Can using non primitive Integer/ Long datatypes too frequently in the application, hurt the performance? -

i using long / integer data types in application, build generic datatypes. fear using these wrapper objects instead of primitive data types may harmful performance since each time needs create objects expensive operation. seems have no other choice(when have use primtives generics) rather using them. however, still great if can suggest if there make better. or way if avoid ?? also may downsides of ? suggestions welcomed! repeat after me. "creating object in java not expensive operation" . you prematurely optimizing application. better approach implement in natural way using integer , long , profile determine bottlenecks are. if profiler tells use of integer , long performance issue, then @ ways cure this. if determine integer , long issue, here things do: look class library implements "collections" of primitive types; e.g. trove. beware apis of such collection types won't compatible java.util.collection , descendants. us...

jquery - Export calendar events to google calendar, ical, microsoft outlook -

i have used jquery calendar, , have used create event details, want export same event details google calendar,ical , microsoft outlook, depending upon user requirements.but want procvide 3 features. there tools available or have dirty hands code whole thing myself. fyi:i have used servlets , mysql @ end , jquery along html5 @ front end. since using java on server side, can use ical4j library creating icalender. basically, need ical completing requirement. google, microsoft, apple , many others mozilla sunbird support icalender can use 1 format, rather going different formats.

objective c - How can I reload the com.apple.systemuiserver preferences into the SystemUIServer application? -

for mac osx application, have feature removes system clock in upper right hand corner of screen when button clicked. preferences control system menus displayed (including system clock) stored in ~/library/preferences/com.apple.systemuiserver.plist. able update relevant preferences in file remove system clock. however, systemuiserver application needs restarted new preferences can reloaded , clock can removed. here code have used restart systemuiserver. nstask *killsystemuitask = [[nstask alloc] init]; nsmutablearray *args = [nsmutablearray array]; [args addobject:@"systemuiserver"]; [killsystemuitask setlaunchpath:@"/usr/bin/killall"]; [killsystemuitask setarguments:args]; [killsystemuitask launch]; when systemuiserver killed, osx automatically restarts it. above code works, removal of system clock not clean like. entire system bar removed second. can think of better way reload preferences systemuiserver? ideally, i'd removal of system clock clean clock ...