Posts

c - Marienbad game wrong XOR -

i working on programming puzzle, need code ai best current move win game. the loser 1 picks last sticks. here board : | ||| ||||| | so use xor operator on numbers number of sticks need remove give me : 1 xor 3 xor 5 xor 1 = 6 now : 1 xor 6 = 7 (since increased won't select case) 3 xor 6 = 5 (since increased won't select case) 5 xor 6 = 3 (since decreased reduce 5 3 removing 2 sticks. the problem playing in "misere" version of game loser if 1 take last sticks , seems method perfect normal play winner 1 take last stick. could explain me should in case. the winning strategy isn't xor piles , remove many sticks 1 pile. instead, want choose number of sticks remove such xor of piles zero. example, if remove 2 sticks pile containing 5 sticks, remaining xor 1 xor 3 xor 3 xor 1 = 0. hope helps!

c++ - Making templatized optimization more maintainable -

sometimes piece of code can better-optimized compiler using templatized internal implementation invariant. example, if have known number of channels in image, instead of doing like: image::dooperation() { (unsigned int = 0; < numpixels; i++) { (unsigned int j = 0; j mchannels; j++) { // ... } } } you can this: template<unsigned int c> image::dooperationinternal() { (unsigned int = 0; < numpixels; i++) { (unsigned int j = 0; j < c; j++) { // ... } } } image::dooperation() { switch (mchannels) { case 1: dooperation<1>(); break; case 2: dooperation<2>(); break; case 3: dooperation<3>(); break; case 4: dooperation<4>(); break; } } which allows compiler generate different unrolled loops different channel counts (which can in turn vastly improve runtime efficiency , open different optimizations such simd instructions , forth). h...

extjs - Possible to filter user stories on name starts with? -

is possible filter user stories on name? example: filters: [{properrty: 'name', operator: 'startswith', value: 'epic'}] i using 2.0p5 rally sdk. there documentation can @ app sdk? explains querying on different attributes? there isn't startswith operator, can use contains: filters: [{property: 'name', operator: 'contains', value: 'epic'}] all possible values filter operators can found here: https://help.rallydev.com/apps/2.0p5/doc/#!/api/rally.data.queryfilter-cfg-operator you can use filterby method further narrow down result set once store has been loaded server: store.filterby(function(record) { return record.get('name').indexof('epic') === 0; }); the full app sdk documentation (including guides , links wsapi documentation) can found here: https://help.rallydev.com/apps/2.0p5/doc/ i recommend upgrading recent version of sdk app development (2.0rc2 of writing). https://help.rall...

php - Most efficient way to do batch INSERT IGNORE using doctrine 2 -

i have script needs go list of entries in database iterate on creating new entries in table if dont exists. currently im doing: foreach($entries $entry){ $newitem = new item(); $newitem->setattribute($entry->getattribute()); $entitymanager->persist($newitem); try{ $entitymanager->flush(); } catch(\exception $e){ if(!strpos($e->getmessage(),'duplicate')){ throw $e; } $entitymanager = $this->getdoctrine()->getmanager(); //refreshes entity manager } } however doing way time intensive, there 1000's of entries , script times takes upwards of 10 minutes complete. have seen other posts suggest when doing batch processing flush every 20 or records problem if 1 of 20 duplicate whole transaction dies, im not sure how go , try , find offending entry exclude before resubmitting them again. any appreciated. you can 1 select fetch records exist in database, , later ski...

Wordpress Custom Post Types and fields -

i have 2 custom post types… book , book author. i want to… list book's author on respective author page. so if have 10 books stephen king. want list them (and him) on stephen king page. having real trouble working out how query posts this. any advice? using advanced custom fields plugin if helps, can't work out how query , display post information. i use following code display of releases, how specific ones on specific author pages? <?php $args=array( 'post_type' => 'book', 'post_status' => 'publish', 'posts_per_page' => 12, 'caller_get_posts'=> 1, 'orderby'=> 'date', 'order' => 'desc' ); $my_query = null; $my_query = new wp_query($args); if( $my_query->have_posts() ) { echo ''; $i = 0; while ($my_query->have_posts()) : $my_query->the_post(); if($i % 6 == 0) { ?> <...

css - Fixed header position in bootstrap 3 modal -

i want use fixed header in bootstrap modal, if set .modal-header position:fixed scrolls along moda content. how create trully fixed header in bs modal? instead of trying make header fixed, fix height of body , make scrollable. way header (and footer) visible. you can using css3 vh unit calc . both vh calc have pretty browser support (ie9+). the vh unit relative viewport (= browser window) height. 1 vh 1% of height , 100vh means 100% of viewport height. we need substract height of modal's header, footer , margins. it's going difficult dynamic. if sizes fixed, add heights. set either height or max-height calc(100vh - header+footer px) . .modal-body { max-height: calc(100vh - 210px); overflow-y: auto; } see jsfiddle

linux - Using wget on a directory -

i'm new shell , i'm trying use wget download .zip file 1 directory another. file in directory copying file .zip file. when use wget ip address/directory downloads index.html file instead of .zip. there missing download .zip without having explicitly state it? wget utility download file web. you have mentioned want copy 1 directory other. meant on same server/node? in case can use cp command and if want if other server/node [file transfer] can use scp or ftp