Posts

Showing posts from September, 2010

linux - Bash column altering -

i have data in columns, data confusing column numbers making bash opperations confusing, data below working (however there on 1 million lines of). interested in numbers in 8th , 9th column: 2014-05-10 08:47:57.373 3600.633 udp 114.31.255.90:57844 -> 42.209.2.47:52436 1.3 m 1.8 g 1 2014-05-10 09:50:39.609 3601.385 udp 114.31.255.90:57844 -> 60.120.101.149:47403 1.0 m 1.5 g 1 2014-05-10 10:00:14.064 3607.106 udp 114.31.255.90:57844 -> 46.83.205.250:32307 2.0 m 3.0 g 1 2014-05-10 10:03:04.263 3644.192 udp 114.31.255.90:57844 -> 1.32.33.64:10933 987743 1.4 g 1 2014-05-10 11:07:16.247 546.764 tcp 105.51.244.36:80 -> 114.31.255.222:55580 797919 1.2 g 1 2014-05-10 10:46:15.190 2332.334 udp 114.31.255.90:57844 -> 43.95.27.215:53394 1.1 m 1.7 g 1 2014-05-10 11:00:49.005 1458.456 udp 114.31.255.90:57844 -> 39.150.172.138:39326 1.2 m 1.7 ...

mongodb - Why is Robomongo returning an object from db.collection.distinct() instead of an array? -

using example mongodb reference , i'd expect db.inventory.distinct("dept"); return array ["a", "b"] , , that's happens when run shell. using robomongo (on os x) instead object name-value pairs, so: { "0" :"a", "1": "b" } . this setup: db.inventory.drop(); db.inventory.insert([ { "_id": 1, "dept": "a", "item": { "sku": "111", "color": "red" }, { "_id": 2, "dept": "a", "item": { "sku": "111", "color": "blue" }, { "_id": 3, "dept": "b", "item": { "sku": "222", "color": "blue" }, { "_id": 4, "dept": "a", "item": { "sku": "333", "color": "black" } ]); why robomongo behavin...

dojo tabContainer - how to get tab id under right-mouse click popup menu for tab not in focus -

i'm dojo newbie , i'm modifying existing application customer , adding options popup menu....'close all', , 'close other tabs'. there exists 'close'. adding menu items straightforward...'close all' gets tabcontainer , iterates on tabs removing them. but 'close other tabs', i.e. close other tabs except 1 right-clicked on, can't figure out how id of tab, on right-mouse click done. the 'selectedchildwidget' not tab want, gives tab selected...i right clicked on 1 of other non selected tabs. any ideas? have mouse event cannot find path tab triggered against, popup menu. many thanks, andrew (going rapidly grey on one) dijit menus have currenttarget property indicates node menu being displayed for. menuitem's onclick handler, can access current target node this.getparent().currenttarget : closemenu.addchild(new menuitem({ label: 'close all', ownerdocument: document, onclick: function...

css - Simple animation using keyframes not working -

simple animation using keyframes not working, not sure i've done wrong. when run see still car image. new stuff apologies if question makes want facepalm. css @charset "utf-8"; @-webkit-keyframes drive { from {-webkit-transform: translatex(0px);} to {-webkit-transform: translatex(800px);} } body { background:#fff; } .wrapper { margin: 1em auto; width: 960px; position:relative; } .drive { position: relative; top:10px; left:10px; webkit-animation-name: drive; webkit-animation-duration: 2s; webkit-animation-timing-function: ease-in; webkit-animation-iteration-count: 1; } html <!doctype html> <html> <head> <meta charset="utf-8"> <title>css using keyframes</title> <link rel="stylesheet" type="text/css" href="my-css-1.css"> </head> <body> <!--<script src="js/jquery-1.11.2.js"></script> <scri...

Sorting arrays containing numbers with 3 decimals and keeping trailing zeroes (Ruby) -

i have array following numbers numbers = [70.920, -38.797, 14.354, 99.323, 90.374, 7.581] i sort them numerically, problem ruby automatically rounds numbers trailing zeroes. keep format 3 decimal places , trailing zeroes ignored. when declare numbers array, output. => [70.92, -38.797, 14.353, 99.323, 90.374, 7.581] i tried map array include 3 decimal places , convert them floats. number.map { |n| "%.3f" % n }.map(&:to_f).sort once again, ruby trims trailing zeroes. [-38.797, 7.581, 14.354, 70.92, 90.374, 99.323] i expecting input this [-38.797, 7.581, 14.354, 70.920, 90.374, 99.323] i've used float documentation reference, can't figure out how implement this http://ruby-doc.org/core-2.2.0/float.html is possible in ruby? in advance. are using input representation trailing zeros visualization purposes? can use array ruby use it, removing trailing zeroes. , when need present input, use like: numbers.sort.map{|n|sprintf ...

ImageView returning as null in android -

so issue have set of data inside listview outputs onto page. able change image based on rating retrieved. reason when try set imageview variable , find id returns null. there way can retrieve other way? if (jo.getstring("ratingvalue").contains("-1")) { listplaces.add(jo.getstring("businessname") + "\n" + jo.getstring("addressline1") + "\n" + jo.getstring("addressline2") + "\n" + jo.getstring("addressline3") + "\n" + jo.getstring("postcode") + "\nrating: exempt\ndated: " + jo.getstring("ratingdate") + "\n"); } else { if (jo.getstring("ratingvalue").contains("0")) { changeimg(0); system.out.println("resu...

python - Data Science using Vim -

i have found great solution setup , learning vim python , framework around (django, flask, pyramid, etc ), possible setup data science. suppose coding not problem, visualizing, there libraries can install. thank you. matplotlib popular , easy use python library visualisation, stanford's seaborn , extends matplotlib , useful statistical analysis. if d3.js, there python library, d3py , can use (for interactive javascript based graphs).

concurrency - z/os cics db2 cobol program to process database entries concurrently -

i have db2 table containing large amount of records send out external system via mqs. there column in table containing whether record status (sent or pending sent). i write scheduler program continually check if there records in table "pending sent". if yes, program send pending records out , update status accordingly that schedule started in multiple transactions. therefore expecting multiple instances of same program running concurrently my questions how prevent same records being pick , sent multiple schedulers @ same time? i told use cursor row level locks? not sure how works remarks: working on cics cobol in z/os environment i think have design problem. accomplish similar trying having trigger on db2 table sends mq message queue defined trigger cics transaction. in case, can dispense cics altogether , @billwoodger suggests , send message when set pending flag.

excel - Search for a variable string within a string -

this actual problem: have text in a1: the gross return of s&p index on past year has been 5%. isin gross return ch354892. isin net return ch875621. i want write general function return isin gross return, ch354892 . thinking of searching words gross return , isin , if difference of positions between them < 35, grab text starting 5 positions after gross return , ending @ 8 positions after start. is there way it? the first is seems equally distinctive: =mid(a1,find(" ",a1)+4,8)

c++ method as template argument -

i trying specialize std::unordered_map class x custom hash , custom equality. problem both equality , hash functions not depend on object(s) of class x on data in (fixed) object of class y. here toy example (with hash function) of want do: #include <unordered_map> using namespace std; struct y { bool b; struct x { size_t i; }; size_t hash(const x &x) { return x.i + b; } unordered_map<x, int, hash> mymap; }; the problem function hash in template specialization method , compiler complains ("call non-static member function without object argument"). want y.mymap uses y.hash(). way this? note in real code y template, in case matters. thanks! edit: clarify, instead of boolean b in code have vector data needed in comparing objects of type x. data added when x created, vector not constant, data given x not change after added, hash given x never changes (so in sense depends on x required hash). main reason use approach save memory sin...

How to control size of journals in mongodb? -

how control size of large journals files journal file take large amount of space. how can space can saved using small files. after doing research: setting smallfiles option controlling journaling doesn't control size however command --smallfiles

regex - Regular expression for Password Requirements for PCI Compliance -

here password requirements pci compliance: must contain @ least 1 upper case letter must contain @ least 1 lower case letter must contain @ least 1 number must contain @ least 1 special character such #, !, ?, ^, or @. please tell me how create such regulat expressions? can`t figure out how it don't single regex. there's no need in single regex, , easier change rules, , easier read, if make multiple regex checks. if doing in perl, example, you'd do my $ok = ($pw =~ /[a-z]/) && # has @ least 1 lowercase char ($pw =~ /[a-z]/) && # has @ least 1 uppercase char ($pw =~ /\d/) && # has @ least 1 digit ($pw =~ /[#!?^@]); # has punctuation that far easier read later on when have maintain code in future.

objective c - Location manager not monitoring Beacons -

i not getting region entry , exit events beacon regions. how add beacon monitoredregions: nsuuid *uuid = [[nsuuid alloc] initwithuuidstring: beacon.uuid]; clbeaconregion *region = [[clbeaconregion alloc] initwithproximityuuid: uuid major: (clbeaconmajorvalue) beacon.major  minor: (clbeaconmajorvalue) beacon.minor  identifier:  @"some identifier"]; [_locationmanager startmonitoringforregion: region]; and events: - (void) locationmanager: (cllocationmanager *) manager didenterregion: (clregion *) region { nslog(@"entered beacon region"); } - (void) locationmanager: (cllocationmanager *) manager didexitregion: (clregion *) region { nslog(@"exited beacon region"); } none of these delegate events called beacon region. i have tested geographical regions , works not work beacon. have tested ranging on same beacon works. are there known issues beacon monitoring?? many thanks hi @ldsarria check steps working me step 1 ...

ios - What is the most reliable and fastest type or data structure to store data using Objective C? -

i looking type or data structure store big number of same type primitives on app (mac os x or ios) using objective c. understood nsnumber stores 1 primitive (correct me if wrong). have, let's say, thousands of integers or strings. which best solution put, store , access them there? nsset, nsarray, nsmutablearray, nsdictionary, nsmutabledictionary or else? know have different features, care performance of basic operations (putting, storing, retrieving). it depends on how want add, store , remove data. first let go through each type of data structure available in objective-c: primitive array this basic type of storage in objective-c(or c) used store primitives. ex: int a[4] = {1, 2, 3, 4}; limitation can store primitive types. array size cannot changed once declared. can retrieved index. can store single type of data, defined @ time of declaring array. nsarray this container storing objects. object of type nsobject (or inherits nsobject ) or of type ...

Unexpected MATLAB expression? (trying to create a function) -

load('matrix.mat'); userinput = input('input value 1-5') dayreport = sum(matrix(:,end 2);==userinput) i trying retrieve number of rows in column 2 of loaded matrix corresponds userinput. however, when try run code, says there error in third line (simply, "unexpected matlab expression"). ideas why is? edit: found solution, turns out don't need "end" or semicolon within sum function. load('matrix.mat'); userinput = input('input value 1-5') dayreport = sum(matrix(:,2)==userinput) remove semi-colon , end statement in last line of code. guess want access second column of matrix , , it's matrix(:,2) . also, suspect copied , pasted code somewhere. that's bad programming practice because copied code may work in situation, if try , bring current context, may different you're doing , can result in errors. see discussion on programmers stack exchange on why should avoid together: https://softwareengin...

Why this works: Meteor-Blaze #with and data context? -

i wonder why following thing outputs 'hello' instead of 'bye'??? template: <template name="example"> {{#with datacontext}} {{say}} {{/with}} </template> template helper: template.example.helpers({ datacontext: function() { return { say: 'bye' }; }, say: function() { return 'hello'; } }); (meteor 1.1.0.2) the shortest answer helpers have preference on data context. if rename 1 of them else should solve problem. the order lookup goes is: the data context (if contains . ). {{say}} not. the template's helper. {{say}} has helper say . a template a global helper such defined template.registerhelper . the data context so if first isn't found, goes down list until finds something [1] https://github.com/meteor/meteor/blob/90b356061ff2464f11749dc8b43d1a139b233980/packages/blaze/lookup.js#l100-l139

python - Nested list django -

assuiming i have 1 many model this: class user(models.model): username = models.charfield(max_length=255) class usercomment(models.model): user = models.foreignkey(user) text = models.charfield(max_length=255) how can make queryset in django view in order have list following? user_comments= [[username1, [text1, text2, text3]], [username2, [text1, text2]]] ----update---- i ended using modified version of sander van leeuwen solution views.py user_comments = {} user_comments = comments.objects.select_related('envia') comments_by_user = collections.defaultdict(list) comment in user_comments: comments_by_user[comment.envia.id].append([comment.envia.first_name+" "+comment.envia.last_name,comment.text,comment.date.strftime('%d/%m/%y')]) comments_by_user.default_factory = none template.html {% key, values in comments_by_user.items %} <ul class="chat-history" id="{{key}}-hist"> {% val in values%} ...

ios - How can I programatically add a Gradient Layer over an image in Swift? -

i want place layer predefined transparent black gradient on top of uiimage content image loaded via web , creating effect of shadow on it. i don't want via loading png such gradient. i suggest creating custom subclass of uiview (or uiimageview, if want add gradient uiimageview). in init method of custom view, create cagradientlayer , add sublayer of view's layer. set black transparent gradient on layer. you need override layoutsubviews() , change settings on gradient layer in case view's bounds change. edit: i created playground gist on github working example of this: the code looks this: import uikit import avfoundation class imageviewwithgradient: uiimageview { let mygradientlayer: cagradientlayer override init(frame: cgrect) { mygradientlayer = cagradientlayer() super.init(frame: frame) self.setup() } required init(coder adecoder: nscoder) { mygradientlayer = cagradientlayer() super.init(coder: adecoder) ...

javascript - Prevent image file from loading to canvas after file size warning -

i trying prevent image file selected loading canvas if larger maximum allowed have set. logic checks image , throws warning, still loads image being checked. how can prevent occurring? also, need able clear image loaded, if new 1 loaded , checked. newly loaded image large, not checked validity or have warning thrown if big. var fileinput = document.getelementbyid("file"), renderbutton = $("#renderbutton"), submit = $(".submit"), imgly = new imglykit({ container: "#container", ratio: 1 / 1 }); // user selects file... fileinput.addeventlistener("change", function (event) { //check file size of input if (window.file && window.filereader && window.filelist && window.blob) { //get file size , file type file input field var fsize = $('#file')[0].files[0].size; var ftype = $('#file')[0].files[0].type; var fname = $('#file')[0]....

linux - diff commnad not working "missing operand after `diff'" -

in diff command getting following error. kindly assist how can specify want see difference in 2 files: #current_unavail=ranjith root@iitmserver1 tmp]# cat /tmp/ran ranjith [root@iitmserver1 tmp]# #test=$(cat /tmp/ran) [root@iitmserver1 tmp]# diff `$current_unavail` `$test` diff: missing operand after `diff' diff: try `diff --help' more information. [root@iitmserver1 tmp]# diff takes 2 filenames arguments, appear passing in file contents first argument. want change script/commands more like: current_unavail=/tmp/unavail_cn.out result=$(diff $current_unavail /moes/home/pharthiphan/scripts/monitoring/unavail_cn/$last_unavail) alternatively, can use process substitution pass output of command command expecting file. eg: diff <(echo -e "foo\nbar") <(echo -e "foo\nbaz") however, while know about, seem needless level of complexity current problem.

java - JavaFX extending PropertyValueFactory -

i have tableview of objects contain ids mapped other objects of other types. need tablecolumn which, instead of showing id, shows object mapped id. thought maybe creating own propertyvaluefactory, so: public class somepropertyvaluefactory extends propertyvaluefactory<someobject, string> { public somepropertyvaluefactory(string property) { super(property); } @override public observablevalue<string> call(celldatafeatures<someobject, string> parameter) { someotherobject obj = function(parameter.getvalue().getid()); return obj.tostring(); } } is viable solution? function properly? i've tried loadexception thrown: caused by: java.lang.instantiationexception: ui.view.somepropertyvaluefactory @ java.lang.class.newinstance(unknown source) @ sun.reflect.misc.reflectutil.newinstance(unknown source) ... 21 more caused by: java.lang.nosuchmethodexception: ui.view.somepropertyvaluefactory.<init>() @...

write a one year calendar to file using python -

when run below code prints out calendar entire year (which don't want). want write file won't. returns error message typeerror: expected character buffer object . also, casting string doesn't work. import calendar cal = calendar.prcal(2015) open('yr2015.txt', 'w') wf: wf.write(cal) as example, below code prints 1 month of year , returns string, isn't want print calendar.month(2015, 4) print type(calendar.month(2015, 4)) so when run below code error message <type 'nonetype'> . seems me should string isn't. suggestions on how can 12-month calendar text file? print type(calendar.prcal(2015)) prcal doesn't return anything. use cal = calendar.textcalendar().formatyear(2015) instead.

mongodb - Mongo DB Update to a sub array document -

i have structure { "_id" : objectid("562dfb4c595028c9r74fda67"), "office_id" : "123456", "employee" : [ { "status" : "declined", "personid" : "123456", "updated" : numberlong("1428407042401") } ] } this office can have multiple persons.is there way if want update employee status person under specific office_id "approved".i trying same through plain mongo java driver.what trying office id using query builder , iterate on list , save document.somewhat not satisfied iterative approach(fetch,iterate , save ) following.please suggest if there alternative way. you can update using $ positional operator : db.collection.update( { "office_id" : "123456", "employee.status": ...

mysqli - how to change mysql_query to mysqli_guery -

i using in script mysqli_query think there wrong syntaxes. script did work before, changing form mysql_query mysqli_query, data not put anymore correct in database. this original query: mysql_query( "insert download_manager (set filename='".mysqli_real_escape_string($_get['file'])."'), on duplicate key update downloads=downloads+1"); i changed mysqli_query way: mysqli_query($link, "insert download_manager (set filename='".mysqli_real_escape_string($_get['file'])."'), on duplicate key update downloads=downloads+1"); can tell me did wrong? update: connection looks this: $link = @mysqli_connect($db_host, $db_user, $db_pass, $db_database) or die ("error " . mysqli_error($link)); mysql_set_charset('utf8'); ensure handle stored in $link generated call mysqli_connect , not mysql_connect : http://php.net/manual/en/function.mysqli-connect....

How to do serial communication via rs232 android? -

i have android device 'micronet a317' has rs232 44 pins serial port. have device i.e card reader has 9 pin d-pad connector. have connected both device(android & card reader) each other using converter. task make serial communication between these 2 device. please suggest me it. you can use usb-serial-for-android library transfer data via serial port on android. i've tested library usb-to-serial adapter + usb-host cable plugged nexus 7 usb port. your rs232 port should represented usb device internally, otherwise library won't work. you need know serial adapter type (ftdi/prolific/cdcacm) , add usb device vid/pid appropriate driver file function getsupporteddevices(). you can find out serial adapter type , vid/pid running cat /proc/kmsg root shell on device, or inspecting directory /sys/class/tty

assembly - MIPS Branching issue -

i'm doing project in mips; create wanted long employed requirements. anyway, chose trivia program, has been difficult not impossible. ran problem today branching. increscore: add $t9, $t9, 1 #increment incr. counter add $t8, $t8, 1 #increment counter move $v0, $t8 #move $v0 beq $v0, $s2, eqtwo #counter=2, question 2 beq $v0, $s3, eqthree #counter=3, question 3 beq $v0, $s4, eqfour #counter=4, question 4 beq $v0, $s5, eqfive #counter=5, question 5 bgt $v0, $t8, etally #counter>5, etally decrescore: add $a3, $a3, 1 #increment decr. counter add $t8, $t8, 1 #increment counter move $v0, $t8 #move $v0 beq $v0, $s2, eqtwo #counter=2, question 2 beq $v0, $s3, eqthree #counter=3, question 3 beq $v0, $s4, eqfour ...

vsto - How to trap the insert smartart dialog in powerpoint -

i know how add smart art slide, fills slide. customer wants place smart art automatically in places on slide. can't see how trap insert smartart dialog smartart , place myself on slide. have nay suggestions on how might accomplish this? btw, how find mso code can put on ribbon invoke insert smartart dialog? one way add event handler, trap selection change event. when selection changes, determine whether current selection smart art shape. if so, @ smart art shape's .tags collection see if it's been tagged. if so, leave alone. if not, tag , resize it. try smartartinsert (generally can figure out names if go ppt's customize ribbon dialog , hover mouse pointer on control you're interested in)

java - Image view setBackground is not acting properly -

i have class makes me imagebutton. image button contains image view, tow text view , button. i put width in image view, , if put xml 1 image background, works properly, if java code don't works, acts src atribute. (the image being shown if has no width, src, , not backgorund). this java code: public class miboton extends relativelayout{ protected int idimagen; protected string nomproducte; protected double preuproducte; protected string spreuproducte; //protected mainactivity maprincipal; public miboton(context context, int imgimageresource, string sname, double iprice){ super(context); this.idimagen = imgimageresource; this.nomproducte = sname; this.preuproducte = iprice; this.spreuproducte = double.tostring(iprice) + " €"; layoutinflater inflater = (layoutinflater) context .getsystemservice(context.layout_inflater_service); inflater.inflate(r.layout.products, this, true); imageview imageproduct = (imageview)f...

Localization in Xcode, Base and Language string files -

Image
i having lot of trouble getting localization done in app. trying follow tutorial http://www.raywenderlich.com/64401/internationalization-tutorial-for-ios-2014 . when add language project , asks me files localize gives me option choose launchscreen.xib, no option storyboard. normal? i confused localizable.strings file. created 1 , clicked localize on it. want translate app english traditional. have option of choosing "base" "english" , "chinese" strings file. difference between base , english? 1 need? need "chinese", paste strings , write translations in that? it's confusing ...... edit: step step: first add chinese language: no option storyboard here. want extract strings storyboard can add chinese translations. next click on storyboard , click localize. choose chinese: this storyboard looks in inspector : chinese selected there no other files under storyboard, no string files. doesn't expand or anything. : for r...

javascript - Dynamically removing multiple key/value pairs from an object -

say have array of objects. there keys/values don't want. traditional way delete one key/value pair use delete so: for (var = 0; < tracks.length; i++) { delete tracks[i]["currency"]; ... } the objects i'm pulling in have on 30 pairs. there way can state pairs want , remove others? example in array of objects want keep trackname , kind , price var tracks = [{ tracknumber: "01", trackname: "track 1", trackduration: "5:35", kind: "song", currency: "usd", price: 1.29 }, { tracknumber: "02", trackname: "track 2", trackduration: "5:15", kind: "song", currency: "usd", price: 1.29 }, { tracknumber: "03", trackname: "track 3", trackduration: "5:07", kind: "song", currency: "usd", price: 1.29 }, { tracknumber: "04", tracknam...

ios - No provision profiles found: can not submit binary -

Image
any idea missing? cleaned provision profiles on developer.apple.com cleaned provision profiles in xcode preferences try following steps reinstall certificates , provisioning profiles: go apple member center , download certificates , provisioning profiles save them somewhere can access theme on desktop double-click of them, certificates , profiles this bring xcode , keychain close keychain won't need anymore in xcode, go build settings verify profiles added correctly set developer code signing identity profile all important files reinstalled now. maybe fix problem. hope helps :)

Meteor package (yogiben:admin) refuses to install, seems to be picking up wrong version from github? -

i'm using aldeed:autoform@5. want use yogiben's autoform-file, had trouble getting work autoform@5 i've used fork abdj:autoform-file. now want use yogiben:admin. according discussion on github , latest master ( https://github.com/yogiben/meteor-admin/blob/master/package.js ), yogiben:admin@1.1.0 uses aldeed:autoform@4.2.2 || 5.0.0 . so why error? c:\webdev\koolaid>meteor add yogiben:admin@1.1.0 => errors while adding packages: while selecting package versions: error: conflict: constraint aldeed:autoform@4.2.2 not satisfied aldeed:autoform 5.1.2. constraints on package "aldeed:autoform": * aldeed:autoform@5.0.2 <- abdj:autoform-file 0.2.0 * aldeed:autoform@4.2.2 <- yogiben:admin 1.1.0 looks me meteor somehow picking wrong version github? btw i'm using meteor windowspreview@0.3.0. how these packages play nice together?

java - Problems with Spring MVC 4 REST security -

i having real difficulty adding security rest api , wondering if can here. have set of model, controller , dao classes in order add, edit , delete customers through api. using latest version of spring mvc 4. want have basic authentication select number of users can that. i added following class start with: @configuration @enablewebsecurity public class securityconfig extends websecurityconfigureradapter { @autowired public void configureglobal(authenticationmanagerbuilder auth) throws exception { auth.inmemoryauthentication().withuser("user").password("password").roles("user"); } protected void configure(httpsecurity http) throws exception { http.authorizerequests().anyrequest().authenticated().and().formlogin().and().httpbasic(); http.csrf().disable(); } } as can notice disable csrf after error messages coming during testing. added following class in order initialise securityconfig . public cla...

Python Multiprocessing: is locking appropriate for (large) disk writes? -

i have multiprocessing code wherein each process disk write (pickling data), , resulting pickle files can upwards of 50 mb (and more 1 gb depending on i'm doing). also, different processes not writing same file, each process writes separate file (or set of files). would idea implement lock around disk writes 1 process writing disk @ time? or best let operating system sort out if means 4 processes may trying write 1 gb disk @ same time? as long processes aren't fighting on same file; let os sort out. that's job. unless processes try , dump data in 1 big write, os in better position schedule disk writes. if use 1 big write, mighy try , partition in smaller chunks. might give os better chance of handling them. of course hit limit somewhere. program might cpu-bound, memory-bound or disk-bound. might hit different limits depending on input or load. unless you've got evidence you're constantly disk-bound and you've got idea how solve that, i'...

r - pad numeric column with leading zeros -

i've been looking past few hours. have tried using sprintf changes column character. want have fixed-width numeric column, padded zeros. if you're willing use custom class, can write print method this. make data frame, , give custom class: df <- data.frame(a=letters[1:10], b=sample(c(1, 10, 100), 10, rep=t), c=sample(c(1, 10, 100), 10, rep=t)) class(df) <- c("my_df", class(df)) write print method uses @benbolker's formatting: print.my_df <- function(x, ...) { num.cols <- sapply(x, is.numeric) x[num.cols] <- lapply(x[num.cols], sprintf, fmt="%04d") nextmethod() } and then: df produces: b c 1 0100 0100 2 b 0010 0001 3 c 0001 0010 4 d 0001 0100 5 e 0001 0001 6 f 0001 0001 7 g 0001 0001 8 h 0001 0100 9 0001 0100 10 j 0001 0001 you can still use data frame same way since numbers converted when printed. > sum(df$b) [1] 118

LINQ to SQL Left Join over Left Join c# -

i trying perform left join on existing left join lookup table. something like: (from m in maintablerepository.asqueryable() join st1 in subtable1repository.asquerable on m.id = s1.id grps1 s in grps1.defaultifempty() join lt1 in lookuptablerepository.asquerable on s.lkpid = lt1.id grplt1 lkp in grplt1.defaultifempty() select new { prop1 = m.prop1, prop2 = s.prop2, prop3 = lkp.prop3 }).tolist(); the issue query runs fine when remove left join on lookup table, though there not matching value in sub table. however putting in place results in "object reference not set" error. i have tried following, no go: (from m in maintablerepository.asqueryable() join st1 in subtable1repository.asquerable on m.id = s1.id grps1 s in grps1.defaultifempty() join lt1 in lookuptablerepository.asquerable on s.lkpid = lt1.id grplt1 lkp in grplt1.defaultifempty() s!=null && lkp!=null select new { prop1 = m.prop1, prop2 = (s==null)?string.empty:s.prop2, prop3 = (lkp==nu...

datetime - convert character string with timezone to date in r -

i have vector of character strings looking this. want convert them dates. characters time-zone posing trouble. > [1] "07/17/2014 5:01:22 pm edt" "7/17/2014 2:01:05 pm pdt" "07/17/2014 4:00:48 pm cdt" "07/17/2014 3:05:16 pm mdt" if use: strptime(a, "%d/%m/%y %i:%m:%s %p %z") [1] na if omit "%z" time-zone, , use this: strptime(a, "%m/%d/%y %i:%m:%s %p", tz = "est5edt") get [1] "2014-07-17 17:01:22 edt" since strings contain various time zones - pdt, cdt, edt, mdt , can't default time zones est5edt . 1 way overcome split vector different vectors each time-zone, remove letters pdt / edt etc. , apply right timezone strptime - "est5edt" , "cst6cdt" etc. there other way solve this? if date first part of elements of character vector , followed time, splitting elements whitespaces possibility. if date needed: dates <- sapply(a, function(x) st...

OneDrive/SharePoint OAuth invalid audience error -

my goal write code enable office 365 user access files in onedrive business via rest api. have registered application in azure ad (web app/multi tenant) , added permissions access sharepoint online. want use "delegated user identity oauth" scenario app accesses onedrive business via rest apis using user impersonation. the permissions in app's manifest this: "oauth2permissions": [ { "adminconsentdescription": "allow application access appname on behalf of signed-in user.", "adminconsentdisplayname": "appname", "id": "xxx", "isenabled": true, "origin": "application", "type": "user", "userconsentdescription": "allow application access appname on behalf.", "userconsentdisplayname": "appname", "value": "user_impersonation" } the ...

ios - Is possible create a simple game with background scroll to Apple Watch? -

i developing simple game apple watch, , doubt i'm following:   can simple background of infinite scrolling in apple watch. simple game style run.    use spritekit. may indicate tutorial lot. you cannot use spritekit apple watch. read apple watch programming guide find out can do.

ios - Hooking UITableView to a JSON API -

i'm quite new swift i'm trying hook uitableview best possible way. i've decided use swiftyjson, seem simple. objects in json object following: { "id": "146", "title": "esports site streak provides prize-heavy alternative traditional betting", "url": "http://www.dailydot.com/esports/streak-counter-strike-vulcun-betting/", "image_url": "//cdn0.dailydot.com/cache/bb/cc/bbccc49d8271f2f3ed4c40b45c0fe0c0.jpg", "date": "2015-04-10 22:07:00", "news_text": "test teeeext", "referer_img": "1" } so far i've started creating loop creates loop through loops in viewdidload for (key: string, subjson: json) in jsonarray { println(subjson) } and after i've created class news below: class news { var id: int! var title: nsstring! var link: nsstring! var imagelink: nsstring! var sum...

video - How to access Device Crash Logs on Windows Phone 8.1 -

we developing video rendering app windows phone 8.1 , hitting roadblock. phone restarts when call videocomposition.rendertofileasync combine multiple video clips. happens on 1 of our 2 devices... lumia 535. we've tried access debug folder in documents on phone there no dmp crash our app. fact phone restarting may have that. we've tried use field medic record 'os crash 0000014b' under 'uploads' tab. not able view contents of crash. i'm curious log uploaded , if have access either locally or wherever uploaded to. or perhaps there way approach this? thanks!

node.js - How to sanitize array values in mongoose schema? -

i have following schema: var schema = new mongoose.schema({ }, {strict: "throw"}); adschema.add({ files: { type: [string] // ^\d{1,2}:[\w-]{7,14}$/ } }); when new model saved mongodb database need sanitize files field values correspond ^\d{1,2}:[\w-]{7,14}$/ , drop other don't. what base place sanitize?

objective c - Incompatible types casting 'NSString *' to 'CTStringRef *' -

i'm trying cast nsstring* ctstringref* nsstring *foobar = @"foobar"; cfstringref *tmp = (__bridge_retained cfstringref*)foobar; can error? "incompatible types casting 'nsstring *' 'ctstringref *' (aka const struct __cfstring **)with __bridge_retained cast" i've tried __bridge , don't work either. documentation, think _retained right type need. thanks. if closely @ error message see problem is. hint in part - __cfstring ** notice 2 * - means trying cast pointer pointer, or in other words reference reference. ctstringref reference, implied 'ref' part of name, don't need * in (__bridge_retained cfstringref*) your code should read nsstring *foobar = @"foobar"; cfstringref tmp = (__bridge_retained cfstringref)foobar;

python - Extracting text from chart in Beautiful soup -

relatively new beautifulsoup , i'm trying extract data webpage: http://reports.workforce.test.ohio.gov/program-county-wia-reports.aspx?name=gtl8gammduly5gslycy7wq==&datatype=hip9ibmbiwbkor1wvt5bkg==&datatypetext=hip9ibmbiwbkor1wvt5bkg==# i grab numbers under headings "program completers", "employed second quarter", etc. relevant part of html code is: <ul class="listbox"> <li class="li1"> <p style="cursor:help" class="listtop" title="wia adult completers individuals have exited wia adult program individual received core staff-assisted service (such job search or placement assistance) or intensive service (such counseling, career planning, or job training). individuals participated in wia through self-service, ohiomeansjobs.com, or other less intensive programs not included in dashboard.">program completers</p> <p id="programcomp...

java - In CXF RS, can I get the resource method in a request filter? -

i want authorize calls made rest api differently depending on method being called. requesthandler looks this: public interface requesthandler { response handlerequest(message m, classresourceinfo resourceclass); } i can't figure out how method called resourceclass . possible? the responsehandler seems have parameter can named operationresourceinfo : public interface responsehandler { response handleresponse(message m, operationresourceinfo ori, response response); } but time, have deleted had no permission delete (as example). how figure out method called in request filter? fwiw, reason want method because want search custom built annotation put on each method. if there better way approach this, i'm open idea. for completeness, here's documentation on topic: http://cxf.apache.org/docs/jax-rs-filters.html you can use interceptors, rather request...

javascript - How to use ng-toggle and ng-class to change icon while using ng-click:predicate -

Image
i'm using predicate sort items in data model. i've working on adding in , down arrow icons show state sort in. example of predicate orderby in action: http://plnkr.co/edit/?p=preview not sure how toggle values within predicate: <button type="button" class="btn btn-default" ng-click="predicate = 'added_epoch'; reverse=!reverse;"> <div ng-class="recentadded == 'up' ? 'iconupbig' : 'icondownbig'"></div> added </button> controller $scope.recentadded = 'up' i'm not using function here, why it's bit hard me see how toggle now. is there way hook , change recentadded var? inturn change ng-class : ng-click="predicate = 'added_epoch'; reverse=!reverse;" then based on predicate, toggle ng-class : ng-class="recentadded == 'up' ? 'iconupbig' : 'icondownbig'" ...

php - Laravel 5 and Mockery, doesn't work -

i've been debugging line per line , seems error comes when try bind repository mock: $mock = mockery::mock('mynamespace\repositories\mymodelinterfacerepository'); // error in line $this->app->instance('mynamespace\repositories\mymodelinterfacerepository', $mock); i bound repo interface , implementation , works on browser, it fails in test case, giving me error 500 . my controller's constructor goes this: use mynamespace\repositories\mymodelinterfacerepository; class mycontroller extends controller { public function __construct(mymodelinterfacerepository $repo) { $this->repo = $repo; } .... any ideas? edit: here log . seems view not receiving proper foreach argument, possibly caused because mock call returning null . for encounters problem, in case, should controller validate if returned value null (considering eloquent return empty array if no records, never null), or should mockery make sure returns value? ...

javascript - Avoiding duplicated dom queries? -

i learning avoid duplicated dom queries. recommendation far save initial query variable , re-use variable needed. question: if save following variable: var mylist = $("ul.mylist"); will following make dom query? mylist.find("li:first"); or search within variable? if so, there better way it? avoid query? yes, "dom query". have 1 look-up can save list item node jquery wrapper in variable var mylist = $("ul.mylist li:first"); or, can manually search within dom properties of unordered list, jquery, believe, won't you, using .find() method. var mylist = $("ul.mylist"); mylist[0].children[0]; // or using jquery mylist.first();

java - How can I get a specific line from a text file? -

this question has answer here: how read specific line using specific line number file in java? 15 answers i don't know how specific line of text file. let's text file is: (1) john (2) mark (3) luke how can second line of text file (mark)? need read it, not edit it. int n = 2; string linen = files.lines(paths.get("yourfile.txt")) .skip(n) .findfirst() .get(); for pre-java 8, instance int n = 2; scanner s = new scanner(new file("test.txt")); (int = 0; < n-1; i++) // discard n-1 lines s.nextline(); string linen = s.nextline();

java - JavaFX return value from task -

i new javafx programmer , having issue getting result javafx task. want object task. here simple code. public class myclass { public static void main(string[] args) { final mytask task = new mytask(); thread th = new thread(task); th.start(); myobject result; task.addeventhandler(workerstateevent.worker_state_succeeded, new eventhandler<workerstateevent>() { @override public void handle(workerstateevent t) { result = task.getvalue(); } }); } } public class mytask extends task<myobject> { myobject object; @override protected myobject call() throws exception { // basic processing return object; } } i error result object should final , if cant value in result object. have tried searching on forum , google , couldn't find answer. appreciated. thanks. you can't reassign va...

xcode - Docs for the latest version of SQLite.swift -

after updating xcode 6.3 today able totally remove sqlite.swift , reinstall it. , after having fixed 50 errors caused changing down 15 errors remaining , of them have new sqlite.swift. have searched new docs cover syntax changes no avail. errors have found other posts , able fix. so function used work complains ? after delete()?... error message "optional chain has no effect, expression produces int?'. recommendation remove ? func delete(id: int) { let rows = db[schema.tablename] rows.filter(schema.id == id).delete()? } if remove ? after delete() tells me "cannot invoke 'delete' no argument". searched source code , code completion, of not show arguments. also on update statements error: example code: rows.filter(schema.id == id) .update(schema.acctid <- acctid, schema.accesscode <- accesscode, schema.status <- 0) error: cannot invoke 'update' argument list of type '(setter, setter, setter)' swift ...

jquery - How to pass an angularjs variable value to a javascript function? -

in code i'm attempting pass angularjs paramter function : <div ng-app ng-controller="logincontroller"> <p><a href='javascript:display({{ user.firstname }});'>{{ user.firstname }}</a> </div> function logincontroller($scope) { $scope.user = { firstname: "foo" }; } function display(text){ alert(text) } when "foo" clicked "foo" should displayed how pass angularjs variable value javascript function ? fiddle : http://jsfiddle.net/lt7ap/534/ the issue value, "foo" , being written out part of code. in case, appearing variable doesn't exist. display(foo) // referenceerror: foo not defined it'll need @ least quoted understood string value. display('foo') you can use json filter include necessary escape sequences. <a href='javascript:display({{ user.firstname|json }});'>{{ user.firstname }}</a> or, if attach fu...