Posts

chess - how to communicate with uci protocol using matlab -

i'm looking method communicate chess engine uci protocol using matlab. chess engine rybka , exe file. when run rybka.exe, can communicate via dos command prompt want via matlab. think have use streampipe , stdin , stdout don't know how use it. i found code in python , works fine i'm looking matlab version: import subprocess, time engine = subprocess.popen( 'a.exe', universal_newlines=true, stdin=subprocess.pipe, stdout=subprocess.pipe, ) def put(command): print('\nyou:\n\t'+command) engine.stdin.write(command+'\n') def get(): # using 'isready' command (engine has answer 'readyok') # indicate current last line of stdout engine.stdin.write('isready\n') print('\nengine:') while true: text = engine.stdout.readline().strip() if text == 'readyok': break if text !='': print('\t'+text) if it...

DataNucleus JDO on MySQL fails with FK violation on 1:1 relations -

i have issues persisting simple 2 classes on datanucleus 3.1.3 on mysql, datanucleus seems create invalid foreign-keys, ending in "foreign key constraint fails" -exception database. here classes: // datastore since dont care identity here @persistencecapable(identitytype = identitytype.datastore) class { @persistent int x; @persistent int y; } // identity type:application here enable id lookups @persistencecapable class b { @primarykey @persistent(valuestrategy = idgeneratorstrategy.native) long id; @persistent double longitude; @persistent double latitude; // simple 1:1 unidirectional @persistent a; } the schematool created tables (innodb) looks good, insert fails, here logs: 12:54:11,369 debug [datanucleus.datastore.native] - insert `a` (`x`,`y`) values (<1>,<1>) 12:54:11,387 debug [datanucleus.datastore.persist] - execution time = 18 ms (number of rows = 1) 12:54:11,398 debug [datanucleus.dat...

unit testing - Missing DbAdapter dependencies in Zend Framework 2 PHPUnit -

i have simple controller action <?php namespace application\controller; use zend\mvc\controller\abstractactioncontroller; use zend\view\model\viewmodel; class indexcontroller extends abstractactioncontroller { public function myaction() { return new viewmodel(); } } and want test it: <?php namespace applicationtest\controller; use zend\test\phpunit\controller\abstracthttpcontrollertestcase; class indexcontrollertest extends abstracthttpcontrollertestcase { public function setup() { $this->setapplicationconfig( include '../../../config/application.config.php' ); /* $test = $this->getapplicationconfig(); print_r($test); die('~~~'); */ parent::setup(); } public function testindexactioncanbeaccessed() { $this->dispatch('/my'); $this->assertresponsestatuscode(200); $this->assertmodulename('applic...

Displaying errors in Ruby on Rails -

i have trouble displaying errors in rails. here controller def new if current_user @edible = edible.new else flash[:notice] = "you need signed in action" redirect_to root_path end end def create @edible = edible.new(params[:edible]) if @edible.valid? && current_user.edibles.push(@edible) if(params[:edible][:pickup] == "1") respond_to |format| format.html { redirect_to new_user_edible_pick_up_adress(current_user.id, @edible.id) } end else respond_to |format| format.html { redirect_to(user_edible_path(current_user.id, @edible.id), :success => "product saved") } end end else respond_to |format| format.html { redirect_to(new_user_edible_path(current_user.id, :alert => "error happend...

nfc - Android Beam: Is there any callback or error code if receiver is not authorised -

i developing android application uses beam send custom message device. if application present on both devices works fine. if not present @ receiver end still @ sender onndefpushcomplete() success callback. i wondering if there result code or callback tell has been delivered default application or may contraint might cause message delivered authorised application(in case same application). appreciate help. the call onndefpushcomplete() tells (low-level) nfc peer-to-peer data transfer successful. not provide information app data has been delivered to. on android, way force data delivered particular app, add android application record. however, can still overridden on receiving device app running in foreground , has activated nfc foreground dispatching (forcing nfc intents delivered app long in foreground).

android - how can I get image id on button click on and get off image id on button click off -

i want add picture gallery favorite categories when click on button , delate favorite categories when click off button.i dont know how this.i'm new in android.i think first need id of background image when click on button on , after send picture id in database it's can safe , delate.i'm right on way?button switch when click on her.(grey , yellow color) there sorce code final string my_log = "mylog"; gallery gallery; imageview imageview; button sportbutton; int[] imgid = { r.drawable.sport_0, r.drawable.sport_1, r.drawable.sport_2, r.drawable.sport_3, r.drawable.sport_4, r.drawable.sport_5, r.drawable.sport_6, r.drawable.sport_7, r.drawable.sport_8, r.drawable.sport_9, }; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.sport); imageview = (imageview) findviewbyid(r.id.imagesportview); imageview.setimageresource(imgid[0]); gallery = (gal...

swing - Java Adding JScrollPane to JComponent -

java: have jcomponent draws image can rescaled. need have scroll bars appear when image becomes large. passed jcomponent jscrollpane , added jscrollpane north section of jframe, scroll bars appeared when jframe resized not when image rescaled. set preferred size of jcomponent didn't work. i tried adding jcomponent jpanel first passing jpanel jscrollpane didn't work either. here portion of code inside constructor of jframe: jcomponent component = new jcomponent() { public void paintcomponent(graphics g) { graphics2d g2 = (graphics2d) g; g2.drawimage(image1, zoom, this); } }; component.setpreferredsize(new dimension(800, 600)); jscrollpane scroller = new jscrollpane(component); add(scroller, borderlayout.center); override getpreferredscrollableviewportsize jscrollpane override getpreferredsize instead of component.setpreferredsize(new dimension(800, 600)); dimension returns jpanel must larger dimension jviewport (visible re...