Posts

c - How do i count the number of elements on a given line of a file? -

something along line of: int n = sscanf(%s %s ... it save how many string element on given line in int n, the file can contain many lines each line having many elements e.g. efefefef efefef dfefe fefef eef efef efef efefef efefef efefef efefe efeefef [wdfefefef] first line n = 2 ; second line n = 6 also how should remove brackets strings thr string inside bracket? regards presuming 'element' mean word, best bet use strtok , pass appropriate list of terminators (which include space, '[', ']', etc.

datetime - How to get the total hr from start time to end time using 12 Hour Format in php -

how can total hour 2 given time "hh:mm:ss" format? here code: $start = 01:00:00 pm; $end = 02:00:00 pm; expected output: $total = 1; you can try this: $start = new datetime('01:00:00 pm'); $end = new datetime('02:00:00 pm'); $diff = $start->diff($end); echo $diff->format('%h'); you can more info: http://in1.php.net/manual/en/datetime.diff.php

python - Multiprocessing incompatible with NumPy -

this question has answer here: why multiprocessing use single core after import numpy? 3 answers i trying run simple test using multiprocessing. test works until import numpy (even though not used in program). here code: from multiprocessing import pool import time import numpy np #this problematic line def costlyfunc(n): """""" tstart = time.time() x = 0 in xrange(n): j in xrange(n): if % 2: x += 2 else: x -= 2 print "costlyfunc : elapsed time %f s" % (time.time() - tstart) return x #serial application resultlist0 = [] starttime = time.time() in xrange(3): resultlist0.append(costlyfunc(5000)) print "elapsed time (serial) : ", time.time() - starttime #multiprocessing application starttime = time.time() pool = pool() asyncresult = pool.map_async(...

Clear firefox cache quicker -

i make changes js clear out cache doing cmd + shift + space (on mac) , select want clear out cache , leave cookies etc alone. i wondering there faster way clear out cache. any firefox plugin in 1 click or 1 button? thanks ctrl f5: refresh page clearing cache. reloads images, css, js , swf

package - Update multiple dependencies with Bower -

i listed (and/or installed) several dependencies bower inside bower.json file and/or bower install https://github.com/username/project.git that worked fine. now can list them with bower list and can pick name of each dependency of project , run bower update dependency-name question: how can bulk update of them? or have write shell script loop through , update them? you can update running bower update . use -h flag on command see how can use it. eg bower update -h .

Printing different than on page with JavaScript -

i've been printing images using standard window.print() function. i'm dealing image when printed, doesn't print correctly on 1 page(takes 2 pages no matter how small make image). put image in .pdf can format print size , orientation need, have no clue how make .pdf print without new popup window. there solutions out there, perhaps image size accomplish printing image onto 1 8 1/2 x 11 inch page? i've googled no luck, i'm kind of new, maybe i'm searching incorrectly.

loops - How to calculate a sum of sequence of numbers in Prolog -

the task calculate sum of natural numbers 0 m. wrote following code using swi-prolog: my_sum(from, to, _) :- > to, !. my_sum(from, to, s) :- = 0, next 1, s 1, my_sum(next, to, s). my_sum(from, to, s) :- > 0, next + 1, s s + next, my_sum(next, to, s). but when try calculate: my_sum(0,10,s), writeln(s). i got false instead of correct number. going wrong example? this surely false next \= 0: s s + next . more fundamental problem you're doing computation in 'reverse' order. is, when from > to , program stop, don't 'get back' result. should add accumulator (another parameter, propagated recursive calls) , unify partial sum @ last step... anyway, should simpler: my_sum(from, to, s) :- < to, next + 1, my_sum(next, to, t), s t + from. my_sum(n, n, n). | ?- my_sum(2, 4, n). n = 9