Posts

memcached - Compare and Swap (CAS) implementation in EhCache -

i trying find equivalent of memcache's casmutator.cas in ehcache. essentially, swapping out ehcache memcache , need implement interface calls setting value via cas. have insight this? also, given i'm not purporting expert in of this, if has high level overview of how cas works / doing, appreciated well. the compare , swap method equivalent in ehcache replace(element old, element element) method found in net.sf.ehcache.cache. method compares "old" element against element in cache and, if matches, replaces element in cache "element." following method provides simple usage example assumes "acache" cache object method has access , "acache" used cache objects of type long. // replace cached value associated key newvalue , // return original value public long replace(string key, long newvalue, long maxtries) boolean success = false; long originalvalue; element originalelement; element newelement = new elemen...

yacc - Bison: Give left precedence to a rule? -

with bison have many %left's (+,*, etc) , few %right's (=, +=, etc). these tokens. have rule. its | rval | attrdata rval the problem is, attrdata rval returns rval attrdata 1+1 either (attrdata 1) +1 or attrdata (1+1). apply left rule attrdata doesnt work cause isnt token. tried %prec , error too. i can fix writing | attrdata '(' rval ')' dont want , rather have users write attrdata (1+1) since of time they'll mean (attrdata 1)+1. how give rule left precedence? the thing similar have else, solved forcing braces no confusion (if cond { if cond } else ) you can set explicit precedences may you if else example %nonassoc lower_than_else %nonassoc else %% stmt : if expr stmt %prec lower_than_else ; | if expr stmt else stmt;

php - In Komodo IDE, is it possible to tell a file what's included in it so that IntelliSense works? -

file includes files b , c. c has access stuff defined in , b, c doesn't know that. how can tell c has access intellisense works? perhaps more clear example: if master.php includes library.php , page.php page.php has access library.php , there's no way page.php know that. want manually tell page.php library.php included, , have komodo save in meta data or project file. the basic answer that, depending on komodo settings, automatically gather (though in experience it's not 100% reliable). can set directories automatically import intellisense in ide settings. 2 places check: go edit->preferences->code intelligence in komodo ide , make sure 'include files , directories project base directory' go edit->preferences->languages->php , add other directories import zend framework, instance.

c# - Async CTP and "finally" -

here's code: static class asyncfinally { static async task<int> func( int n ) { try { console.writeline( " func: begin #{0}", n ); await taskex.delay( 100 ); console.writeline( " func: end #{0}", n ); return 0; } { console.writeline( " func: #{0}", n ); } } static async task consumer() { ( int = 1; <= 2; i++ ) { console.writeline( "consumer: before await #{0}", ); int u = await func( ); console.writeline( "consumer: after await #{0}", ); } console.writeline( "consumer: after loop" ); } public static void asynctest() { task t = taskex.runex( consumer ); t.wait(); console.writeline( "after wait" ); } } here's output: consumer: before await #1 fun...

java - Quick question on If statements with multiple conditions -

possible duplicate: && (and) , || (or) in java if statements this question should have known answer years ago if writing if statement in java has if(x != null && y == null && x.equals(z)) safe? assume if statement conditions interpreted left right checking if x != null begin assure no null pointer exception thrown (at least x) on x.equals(z) part of condition. accurate? yes. it's called short-circuited logic: http://en.wikipedia.org/wiki/short-circuit_evaluation .

vb.net - How to remove blank pages from PDF using PDFSHarp? -

how able remove blank page pdf file? have sample pdf file 1st page contains few strings , 2nd page absolutely nothing in it. tried loop pdf pages , element count per page funny thing same number between 2 pages =| how did happen if 1st page has few strings , 2nd page absolutely blank??? this code dim inputdocument pdfdocument = pdfreader.open("") dim elemountcount integer = 0 dim elemountcount2 integer = 0 dim pdfpagecount integer = inputdocument.pagecount for x integer = 0 pdfpagecount - 1 elemountcount = inputdocument.pages(x).contents.elements.count elemountcount2 = inputdocument.pages(x).elements.count next try check length of each element: public bool hascontent(pdfpage page) { for(var = 0; < page.contents.elements.count; i++) { if (page.contents.elements.getdictionary(i).stream.length > 76) { return true; } } return false; }

ASP.NET - What is the easiest generic way to save form data and retrieve it when the user navigates back to the page? -

what easiest way save form data , retrieve when user navigates page? we have application process consists of several web forms. if user clicks go step auto-populate fields. assuming there common generic way without having mess individual controls - it? put forms on same page , enable viewstate. that is, instead of using 3 distinct pages, use single page has panels each of virtual "pages." keep track of page user on (with viewstate-managed property), , show/hide forms appropriate page. the next/back controls should post , increment/decrement current page. since it's same form, , it's posting itself, viewstate persist field values automatically. the thing won't work if click browser's "back" button. block using window.onbeforeunload prevent it.