Posts

regex - Regexp: is it possible to search for string 'string' but not 'string({' -

i trying find out occurences of concrete word (method call deprecated api) in files in directory. need regexp find such occurences not contain updated call (new api). can me please? example: deprecated api: method(a,b,c) new api: method({a:a, b:b, c:c}) the regexp should find files containing 'method' not 'method({'. thank you. i'd proper way use negative look-ahead operator, ?! /method(?!\(\{)/ the above states, "any occurence of method not followed ({ " it meets requirements better suggested /method([^{]/ latter not match string end (i.e. abc abc method ) , doesn't handle combination of 2 characters ({ requested well.

floating point - Is if(double) valid C++? -

i ran line of code: if( linedirection.length2() ){...} where length2 returns double . kind of puzzles me 0.0 equivalent 0, null , and/or false . is part of c++ standard or undefined behaviour? it standard behavior (boolean conversion) $4.12/1 - "an rvalue of arithmetic, enumeration, pointer, or pointer member type can converted rvalue of type bool. 0 value, null pointer value, or null member pointer value converted false; other value converted true."

How to implement custom client-side wcf caching -

i need implement custom caching of client proxy of wcf service. i've implemented ioperationbehavior interface. on server-side can set operationdescription.invoke property in applydispatchbehavior method , implement ioperationinvoker interface control operation execution. on client-side can't it. in client-side can use iclientmessageinspector, iparameterinspector, iclientmessageformatter interfaces control message flow. main problem have store in cache service answer without information message format. when restore values cache should create message again in case of service response. cannot break following internal message processing. on moment lose necessary information message such encoding, content-type(json, xml) in case of restful services. final result - wcf cannot process such message. want disable message processing if cached value exists. how can it? i choose absolutely different approach. instead of injecting functionality wcf pipeline define interface w...

.net - GridView HeaderText is empty in some cases -

it returns empty string! <asp:templatefield headertext='<%= "2323" %>'> how solve it? want invoke page method. using headertemplate solved problem, doesn't explain why. :/

iphone - NSRunLoops in Cocoa? -

let's have 2 threads, 1 main thread , one, secondary thread. main thread being used most, (rarely) want secondary thread work based on calls main thread. of time secondary thread should sleep. after searching understand way use runloops. tried read apple's docs ( http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/multithreading/runloopmanagement/runloopmanagement.html#//apple_ref/doc/uid/10000057i-ch16-sw5 ) but looks me complex , i'm having hard time there. there elegant , simple way achieve described? similar runloop code examples out there can run , play with? thanks matt gallagher has nice blog article comparing secondary thread approach other ways of getting background work done. http://cocoawithlove.com/2010/09/overhead-of-spawning-threads.html in case, don't have concerned thread-creation overhead. matt's code examples might provide insight managing secondary thread's runloop. all said, go joshua's advice , u...

javascript - Avoiding repetition when using callback functions and asynchronous requests -

i writing javascript/jquery code requires me make lots of requests various apis. have come across problem many times , basic example of 1 instance of it. the code makes asynchronous request server , if condition returned data not met, code makes request. second request has callback contains of same logic parent. know avoiding repetition calling returnfunction in each callback there way avoid altogether? var container = []; $.getjson("http://www.url.com/api/?callback=?", { data: "mydata" }, function(data) { if(!data.length) { // no results } else { // put results array $(data).each(function(k, v){ container.push(v.some_data); }); // if query did not return enough results if(data.length < limit) { var number_missing = limit - data.length; // more results , append array myfunctiontogetsomethingelse(number_missing, function(response){ ...

c - CPU-Core thread classification Function -

i'm going writing multi-threaded shared memory messaging system ultra high-volume message delivery between processes. messages originate worker threads of web-server. i'd exploit cpu cache locality cores on same cpu share. when wake worker thread on receiving end of ipc system, wake thread on same cpu. i need linux (prefferably posix in genaral) , windows api calls , bitmasking need extract information let me classify executing thread-id -- context of said thread -- using following struct: struct thread_core_id { uint16_t cpu_id; uint16_t core_id; }; functions both platforms appreciated. i'm hoping can done without system calls -- i.e., context-switches. -- edit -- i'm focusing on x86 @ moment, other architectures useful well. for linux should able required information out of /proc/cpuinfo , /sys/devices/system/cpu/cpu*/cache , use sched_{s|g}etaffinity() calls. take @ what every programmer should know memory , if haven't already, a...