Posts

Showing posts from July, 2012

smtp - Linux postfix/dovecot 554 Relay access denied -

i have error 554 relay access denied when trying send email outlook client. i can read incoming mails cannot send. if connect telnet localhost 25 can send external emails, outlook client doesn't work. here's postfix , dovecot config : postconf -n alias_database = hash:/etc/aliases alias_maps = hash:/etc/aliases append_dot_mydomain = no biff = no config_directory = /etc/postfix inet_interfaces = mailbox_size_limit = 0 mydestination = localhost myhostname = mail.mydomain.com mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 myorigin = /etc/mailname readme_directory = no recipient_delimiter = + relayhost = smtpd_banner = $myhostname esmtp $mail_name (ubuntu) smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination smtpd_sasl_auth_enable = yes smtpd_sasl_path = private/auth smtpd_sasl_type = dovecot smtpd_tls_auth_only = yes smtpd_tls_cert_file = /etc/ssl/certs/dovecot.pem smtpd_tls_key_file = /etc/ssl/private/do...

c++ - Strange behavior of copy-/move-constructors & how to return large objects? -

i have been experimenting c++11 again recently, after absence, , after reading many articles on internet thoroughly confused efficient way return large objects factory functions (basically, data analysis database). i have become fan of unique_ptr, read in several articles because of new move-constructors possible return big vector by value , because of these new semantics should fast copying 1 pointer. to try out, wrote small test program outputs in various constructors: #include <iostream> #include <memory> using namespace std; class c { public: c( string n ) : _name{n} { cout << "constructing c named '" << _name << "'\n"; }; c() : _name( "empty" ) { cout << "default-constructing c named '" << _name << "'\n"; } ; // default-ctor c( const c& c ) : _name{c._name} { _name += " [copied]"; cout << "copy-c...

dds - OpenSliceDDS across a network -

i new dds world. understand basic concepts publish , subscribe, , stuff can gained documentation. attempting use openslice dds, , able through tutorial without difficulty. however, want 2 different computers on same network talk each other, seems relatively simple task, can find no documentation on it. for example, message chat room tutorial... how message board running on 1 machine, , chatter on machine? thanks! found it! http://opensplice.org/pipermail/developer/2009-july/000094.html . to summarize link: setup environment on node 1 running release file in ospl_home directory (release.bat) start opensplice daemon on node 1 (ospl start) run messageboard application on node 1 setup environment on node 1 running release file in ospl_home directory (release.bat) start opensplice daemon on node 2 (ospl start) run chatter application on node 2

javascript - switch multiple images on click -

i have code switch image , forth , works fine. however, wondering if there way rewrite script can use in multiple places. code currently: function swaparrows(obj) { var x=document.images if (x[0].src.match('images/editloadout.png')) { x[0].src="images/editloadoutopen.png"; } else if (x[0].src.match('editloadoutopen.png')) { x[0].src="images/editloadout.png"; } } <img src="images/editloadout.png" onclick="swaparrows()" /> which works 1 specific instance only. work in multiple places different pictures entirely. pass 2 images in swap function, , use actual clicked object's src: function swaparrows(obj, i1, i2) { var src = obj.getattribute('src'); if (src.match(i1)) obj.setattribute('src', i2); else obj.setattribute('src', i1); } where html is: <img src="...

python - Flask Principal granular resource on demand -

i've been looking @ post: http://pythonhosted.org/flask-principal/#granular-resource-protection now while there nothing wrong how working can't see usable since @ time of login posts read , editblogpostneed added identity. imagine if have been writing more normal number of posts long term not strategy check post access view /posts/<post_id> . is there way check on each request view using flask principal ? i can of course around lazy relationship query , filter want use flask principal . not sure understand question entirely, might help. in flask app, i'm using flask-principal role permission such admin , editor, , i'm using granular resource protection described in flask-principal docs . in case i'm checking if user has permission access particular account. in each view identity loaded , permission checked. in view : @login_required def call_list(id, page=1): dept = models.department.query.get_or_404(id) view_permission = au...

simulating phone call in Android app for a wristband -

i have android app receives tasks server, environment used noisy , vibration not work , device on user's belt. thought use "smart" wristbands vibrate or glow , show caller id. smart watches expensive such wrist band if simulate phone call application. there way create call app on android?

html - Using PHP to insert data into a MySQL Database -

i'm trying create self-submitting page create form user fill out. information stored in mysql database. form seems working, can't insert information form database reason. here's have: <!doctype html> <html> <head> <title>mysql test</title> </head> <body> <h1>mysql test</h1> <?php if($_server["request_method"] == "get") { ?> <form action="" method="post"> <input type="text" name="name" placeholder="name" /><br /> <input type="submit" value="send" /> </form> <?php } else if ($_server["request_method"] == "post") { $name = $_post["name"]; $server = new pdo("mysql:dbname=test;host=localhost", "...

sql server - How do I insert a record from one table into another table? -

i trying set couple tables, , noticed error, created blank database , tried recreate error. the error reads "the columns in table "" not match existing primary key or unique constraint. now i've read site, has primary key. however want (my primary concern) have 1 table, have roles, salaries , job description in 1 table, , in table, have names, , roles. example, if there 2 accountants in 2nd table, 1 accountant entry in first table apply twice second table. doing have let's 20 "roles" , 30 employees unique roles, same roles. how set table work way? ps: i using sql server management studio create database (which creating scratch). how created problem, created table , inserted 2 columns, column 1 rolesid, , column 2 salary. in second table made of 2 columns, column 1 name, , column 2 position. add 3rd column table 2, labelled salary (or pay or something) in if had 2 of same roleid 2 different names, 3rd table give salary. haven't insert...

photoshop - How do you automate making gifs from videos? -

i have around 50 video clips need make gifs. i'm aware of process make gif using photoshop. wondering if there way automate don't have spend time doing it. you can creating actions in photoshop. open 1 clip, create new action , record doing. open clips , press play. haven't tried clips yet that's auto way. other way, there websites convert clips gifs. both take same amount of time, websites more prepared this.

Using MongoDB's for storing files of size est. 500KB -

in gridfs faq there said 1 should store in aforementioned gridfs files of size >16mb. have lot of files ~500kb. question is: approach more efficient - storing files' content inside document or storing file in gridfs? should consider other approaches? as efficiency, either approach same. gridfs implemented @ driver level paging >16mb data across multiple documents. mongodb unaware you're storing "file", knows how store documents , doesn't ask questions. so, depending on driver (php/nodejs/ruby), may find metadata features nice , opt use gridfs because of that. otherwise, if absolutely sure document not larger 16mb, storing raw content in document should simple , fast (or faster). generally, i'd recommend against storing files in database. can have negative impact on working set , overall speed.

google chrome - Find out if Developer Console is active in the current webbrower (JavaScript) -

while developing logging tool websites, javascript code need know if developement tools (ie: developer tools, chrome: f12, firefox: firebug etc.) open . until know possibily have found in research in ie10 asking for window.__ie_devtoolbar_console_command_line are there variables or functions can called in chrome, firefox (and opera) status of browsers developent tools. i know there console object object not tell me if devtools open or closed. you might find other thread useful: find out whether chrome console open there information both firefox , chrome in there.

c# - Copy All Files/Subdirectories In a File to Another -

i trying copy folder source destination. source , destination folder in same directory. structure of folder vary each copy, needs generic. folder contain files, , subdirectories need copied over. in entire contents of 1 folder should copied no matter contains folder. i hope isnt vauge. quick example of i'm looking for: source folder path: c:\directories\versions\11.0.2 destination folder path: c:\directories\versions\11.0.3 copy of 11.0.2 contents 11.0.3 here code have isn't effective: //create of directories foreach (string dirpath in directory.getdirectories(sourcedir, "*", searchoption.alldirectories)) directory.createdirectory(dirpath.replace(sourcedir, targetdir)); //copy files foreach (string newpath in directory.getfiles(sourcedir, "*.*", searchoption.alldirectories)) file.copy(newpath, newpath.replace(sourcedir, targetdir)); any ideas of how accomplish this? well msdn example this example demonstrates how use i/o classe...

ruby - Nokogiri XSLT tagging document as XML type when using JSON -

i using nokogiri transform xml document json. code straight forward: @document = nokogiri::xml(entry.data) xslt = nokogiri::xslt(file.read("#{file.dirname(__file__)}/../../xslt/my.xslt")) transform = xslt.transform(@document) entry in case mongoid based model , data xml blob attribute stored string on mongodb. when dump contents of transform , json there. problem is, nokogiri tagging top of document with: <?xml version="1.0"?> what's correct way of addressing that? try #apply_to method below( source ): require 'nokogiri' doc = nokogiri::xml('<?xml version="1.0"><root />') xslt = nokogiri::xslt("<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/xsl/transform'/>") puts xslt.transform(doc) puts "######" puts xslt.apply_to(doc) # >> <?xml version="1.0"?> # >> ###### # >>

matlab - Convert 3D array to cell of 2D arrays -

i use octave, matlab users helpful. i have an array defined in space m x n , in time, t . therefore has size m x n x t . function, more helpful convert 3d dimension cell following structure: consider a m x n x t array. cell = {a(:,:,1), a(:,:,2), ..., a(:,:,t)} , has t element, each element m x n array. i don't know how dynamic t . you can use mat2cell achieve it: [m n t] = size(a); b=mat2cell(a, m, n, ones(1,t));

Google Doc's (Spreadsheet) get Revision Id -

i'm testing page: https://developers.google.com/drive/v2/reference/revisions/get#try-it i can't find revision id , when try put think revision id, error displayed saying: "message": "revision not found: " how can find revision id of file (i'm trying spreadsheet)? later i'll try use (in java): revisionlist revisions = service.revisions().list(fileid).execute(); return revisions.getitems(); but need manually. it works fine. need correct file id , revision id. for eg - file id = 0vs336abx5r3mdhjz1tzaci1kb0jsoexoshjdmwfzvue revision id = 13723331213000 steps - get valid file id here. in try out - maxresults = 5 https://developers.google.com/drive/v2/reference/files/list json reply select file id. get revisions file - https://developers.google.com/drive/v2/reference/revisions/list try out - fieldid = enter file id copied above step. from json reply select revision id now use file id , revision id here - https://de...

css - How can I set my navbar to collapse when my page falls within the breakpoint for col-md? -

when using bootstrap i'm having issues navbar turning 2 rows before collapses. how can increase point @ collapse happens? bootstrap example here shows issue i'm dealing with: http://getbootstrap.com/examples/jumbotron/ if decrease size of browser form inputs drop second line before whole navbar collapses button. you'd need go bootstrap's customize section , there you'll find option named @grid-float-breakpoint description reads point @ navbar stops collapsing. set value @screen-md , download custom css

python 3.x - Referring to variables of a function outside the function -

#!/usr/bin/python3 def func(): = 1 print(a+12) print(a) the result is: nameerror: name 'a' not defined is possible use a outside function? in python scope function, or class body, or module; whenever have assignment statement foo = bar , creates new variable (name) in scope assignment statement located (by default). a variable set in outer scope readable within inner scope: a = 5 def do_print(): print(a) do_print() a variable set in inner scope cannot seen in outer scope. notice code not ever set variable line not ever run. def func(): = 1 # line not ever run, unless function called print(a + 12) print(a) to make wanted, variable set within function, can try this: a = 0 print(a) def func(): global # when use a, mean variable # defined 4 lines above = 1 print(a + 12) func() # call function print(a)

ios - Objective-c: How to invoke method in container view controller -

this question has answer here: calling method of 1 view controller view controller 4 answers solution problem below with iskindofclass. @julian! -(void)callcontainerviewcontroller { (uiviewcontroller *childviewcontroller in [self childviewcontrollers]) { if ([childviewcontroller iskindofclass:[containerviewcontroller class]]) { //found container view controller containerviewcontroller *cvc = (containerviewcontroller *)childviewcontroller; //do container view viewcontroller [cvc callfunction]; break; } } } /// my problem i'm using storyboard. i've read child view controller of container view instantiated automatically. how call method within blueviewcontroller redviewcontroller? i've tried several solutions here, nothing worked in case. structure currently: entryviewcontroller.h/.m .. vi...

html - How do i make an embedded youtube video shrink with the page when I have a nav bar being floated left, and a nav bar being floated right -

i making page on site in have put nav bar(float: right) , nav bar(float:left), whenever try embed youtube video, right nav bar ends @ bottom of page. know css code can use fix problem? have: html: <div class="video-wrapper"> <iframe width="700" height="525" src="http://www.youtube.com/embed/myn5abpmpze?rel=0" frameborder="0" allowfullscreen></iframe> </div> css: .videowrapper { position: relative; padding-bottom: 56.25%; /* 16:9 */ padding-top: 25px; height: 0; } .videowrapper iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } james first , foremost, question little ambiguous, since stated nav bar {float:left} , same nav bar floated again right. assuming different nav bars. if same there problem concept. check code, css code has class named videowrapper assigned video-wrapper youtube video iframe. since, video-wrapper not defined in css file, browser renders i...

Receiving streaming output from ssh connection in Python -

i running script remotely on server via ssh , python. script looks through log files , returns information based on each log entry encounters. problem running although script spits out information hits each log entry, local machine needs wait entire process finish before can read lines ssh connection's stdout. ssh = subprocess.popen(cmd.split(' '), stdout=subprocess.pipe) open(remote_ip+'.hits', 'w') f: line in ssh.stdout: print line essentially code prints of results @ once, @ end. wondering if there way me print out contents of stdout being produced on server. sorry if unclear, if ambiguous best clarify it. thanks! edit: should add preferably without external packages, built-in modules 2.6 if possible.

github - How to refactoring a cloned rails repo? -

being new rails, git , terminal. best method of renaming local version of cloned repo github. e.g. angular+rails+yeoman think great bootstrap project. problem being after clone, want give app own name. best method in accomplishing this? yeoman-rails-angular becomes clients-app i found resource? doesnt seems "rails-y" i may misunderstanding, if cloning repository, can rename with: $ git clone https://github.com/vlad/yeoman-rails-angular.git clients-app

Move variables in global environment to a dataframe in R -

how save multiple variables in global environment dataframe in r? can 1 one using $. there command moves variables @ once? thanks. you can do: do.call(data.frame, lapply(ls(), get)) but let me sounds horrible idea.

javascript - JSON into Options of a Input Select -

i have string of json i'm trying put options of select input field. i'd type_label go in type_lable , value type number. here json: var servicecodes = [{ "type_label": "medical care", "type": "1", }, { "type_label": "surgical", "type": "2", }, { "type_label": "consultation", "type": "3", }] here html , js <select id="datas" name="datas" > <script> var $select = $('#datas'); $.each(servicecodes, function(i, val){ $select.append($('<option />', { value: (i+1), text: val[i+1] })); }); </script> for reason isn't working. appreciated. thanks! try this: $select.append('<option value="' + + '">' + val.type_label + '</option>'); in cases, when you're confusing of how retrieve data in loop, take on a...

sql - Find the Last Price that is different from the Current Price -

i have sales transactions in sql server table this: itemnumber, trxdate, unitprice abc, 1/1/2013, 10.00 abc, 2/1/2013, 10.00 abc, 3/1/2013, 13.00 abc, 4/1/2013, 14.00 abc, 5/1/2013, 14.00 xyz, 1/1/2013, 18.00 xyz, 2/1/2013, 18.00 xyz, 3/1/2013, 20.00 xyz, 4/1/2013, 20.00 xyz, 5/1/2013, 20.00 i need stored procedure produce output this itemnumber, lastprice, priorprice abc, 14.00, 13.00 xyz, 20.00, 18.00 assmunig sql server 2005+: ;with cte ( select *, rn=row_number() over(partition itemnumber order trxdate desc) ( select itemnumber, max(trxdate) trxdate, unitprice yourtable group itemnumber, unitprice) ) select itemnumber, min(case when rn = 1 unitprice end) lastprice, min(case when rn = 2 unitprice end) priorprice cte group itemnumber

xml - XSLT using value-of to retrieve text from node with attribute -

i interested in retrieving foo following xml: <a> <b> <c num="2">foo</c> <c num="3">bar</c> </b> </a> using xslt+xpath, i'm attempting similar to: <xsl:value-of select="a/b/c/@num=2/current()"> but don't think retrieve foo properly. there better way of going this? use this: <xsl:value-of select="/a/b/c[@num='2']" /> complete example: xsl: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="/"> <xsl:value-of select="/a/b/c[@num='2']" /> </xsl:template> </xsl:stylesheet> xml: <?xml version="1.0"?> <a> <b> <c num="2">foo</c> <c num="3">bar</c> </b> </a> ...

javascript - IE object required error from xml loaded via AJAX -

i have script parses xml document. ie gives error on line. alarmlog[j][0] = ealog[j].getelementsbytagname("ldsp")[0].childnodes[0].nodevalue; i checked make sure value available. can alert value, , looks good. ie keeps showing error webpage error details user agent: mozilla/4.0 (compatible; msie 8.0; windows nt 5.1; trident/4.0; gtb7.3; chromeframe/28.0.1500.95; .net clr 2.0.50727; .net clr 3.0.04506.30; .net clr 1.1.4322; .net clr 3.0.04506.648; infopath.2; .net clr 3.0.4506.2152; .net clr 3.5.30729) timestamp: mon, 19 aug 2013 20:44:12 utc message: object required line: 503 char: 4 code: 0 uri: http://192.168.254.105/sensorlog.html hoping hints. thanks can alert alarmlog[j][0] ? assuming on right side of assignment operator working undefined value on alarmlog[j] produce error. update: my next guess data related. possibly invalid characters or white-space. need provide more information xml snippet , more of code. have @ common ie javascript mis...

jquery - Trying to hide submit if overdraft -

i trying determine if table row on page (including ajaxed content) has class of "overdraft" , if on page does, hide button. code using isn't working. don't know if code using takes account dynamic data or if runs @ page-load. (function() { if( $('tr').hasclass('overdraft'){ $('#btnsamsubmit').hide(); } // end if })(); if( $('.overdraft').length > 0) { $('#btnsamsubmit').hide(); }

c# - how to trigger visibility change to child controls with a trigger -

i have databound listbox thet generates items in datatemplate of type wrappanel other controls within it. have behavior to, when change visibility affect differently controls within wrappanel <wrappanel orientation="horizontal" tag="{binding .}" horizontalalignment="stretch" visibility="{binding editmode, converter={staticresource visibilityconverter}}"> <label width="150" content="{binding path=avaiableattribute.text}" name="lblname"/> <label width="150" content="{binding path=informationitem.itemstring, mode=twoway, updatesourcetrigger=propertychanged}" initialized="label_initialized" name="lbltext" /> <contentpresenter minwidth="200" maxheight="200" content="{binding ., convert...

video - Draw on canvas from within C++ XPCOM code -

is possible draw on element c++ xpcom add-on? (long time ago probably) 1 object of nsidomcanvasrenderingcontext2d interface , use ti's method putimagedata_explicit in order draw image on canvas. nowadays, nsidomcanvasrenderingcontext2d hides , have no clue how achieve this. in general - there way render video (let's obtained remote host) add-on on web-page? any advice appreciated. thank there putimagedata_explicit now. protected member. you may cheat system , break encapsulation purposes, e.g. deriving , downcasting (and protected members yours). or hard way, , use putimagedata while having mess around imagedata , errorresult . downcasting protected member: #include <string> #include <iostream> class base { protected: std::string myname() { return "base"; } }; class derived : public base { public: std::string myname() { return base::myname(); } }; int main() { base *base = new base(); d...

Remove "Move all to next tab group" from Visual Studio? -

is possible remove context menu item "move next tab group" tab context menu? the following applies visual studio 2013: select menu item "tools / customize" select "commands" tab. select "context menu" radio button. select "other context menus | easy mdi document window" combo box. select "move previous tab group" item , press "delete" button. select "move next tab group" item , press "delete" button.

objective c - drawing a Line in a couple of frames with Quartz 2d -

i objective c programmer. developing universal app. in app want use quartz draw square, not in 1 frame, rather frame frame. in code below there possibility. not good, because want draw rectangles, circles , other stuff. so, there better way draw such things. -(void)drawrect:(cgrect)rect { [self drawarect]; cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextsetlinewidth(context, 20.0); cgcolorspaceref colorspace = cgcolorspacecreatedevicergb(); cgfloat components[] = {0.0, 0.0, 1.0, 1.0}; cgcolorref color = cgcolorcreate(colorspace, components); cgcontextsetstrokecolorwithcolor(context, color); if (!firstlineready) { cgcontextmovetopoint(context, 200, 200); cgcontextaddlinetopoint(context, x, y); } if (firstlineready && !secondlineready) { cgcontextmovetopoint(context, 200, 200); cgcontextaddlinetopoint(context, 600, 200); cgcontextmovetopoint(context, 600, 200); cgcontexta...

database - NullPointerException in android project -

i tried launch addeditrecipesactivity.java recipesactivity.java. in recipesactivity there list of data datatable. pressing add button in recipesactivity, addeditrecipesactivity.java called, insert data in datatable. when pressed button, application crashed. this logcat messages. 08-20 04:13:20.315: e/your tag,(9425): message - 08-20 04:13:20.315: e/your tag,(9425): java.lang.runtimeexception: unable instantiate activity componentinfo{com.example.behealthy/com.example.behealthy.addeditrecipesactivity}: java.lang.nullpointerexception - 08-20 04:13:20.315: e/your tag,(9425): @ android.app.activitythread.performlaunchactivity(activitythread.java:2024) - 08-20 04:13:20.315: e/your tag,(9425): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2125) - 08-20 04:13:20.315: e/your tag,(9425): @ android.app.activitythread.access$600(activitythread.java:140) - 08-20 04:13:20.315: e/your tag,(9425): @ android.app.activitythread$h.handlemess...

javascript - Force ng-dirty in angularjs form validation -

doing form validation angularjs want mark required fields erroneous when user click submit. i using input.ng-dirty.ng-invalid style controls error. want set ng-dirty on required controls (or controls.. same me) when user submits form. validation working. understand why, trying wrong, found no other way same effect, except think complicated right. what tried was: <div ng-app> <form novalidate> <input name="formvalue" type="text" ng-model="formvalue" required /> <input type="submit" /> </form> </div> http://jsfiddle.net/yq4ng/ let's start adding angular jsfiddle wrapping in <div ng-app>...</div> http://jsfiddle.net/yq4ng/1/ by default required field validated on input (dirty). if want have them validated on submit before input (pristine), can run function on submit button check pristine fields , dirty them. that have done in example: http://js...

cygwin - bash shell script error works on command line, not in script -

when running shell script via cygwin64, getting error (output below). relevant portion of script follows. interesting if copy , paste echoed command, runs without complaint. so, failing properly? [worldwidewilly@sal9000 resources]$ makebook mybook generating dblatex pdf output via a2x a2x -v -f pdf -l --asciidoc-opts='-a lang=en -v -b docbook -d book' --dblatex-opts='-v -t db2latex' mybook.asciidoc usage: a2x [options] source_file a2x: error: option -d: invalid choice: "book'" (choose 'article', 'manpage', 'book') done. here script logic: asciidoc_opts="--asciidoc-opts='-a lang=en -v -b docbook -d book'" dblatex_opts="--dblatex-opts='-v -t db2latex'" echo "generating dblatex pdf output via a2x" cmd="a2x -v -f pdf -l ${asciidoc_opts} ${dblatex_opts} $1.asciidoc" echo $cmd $cmd echo "done." the script has been saved utf-8 *nix file endings. fresh install ...

tricky Android Google Map zoom while maintaining center point -

it's not easy explaining problem try. i have android googlemap, on top of it, have imageview positioned @ center @ times. if drag/pan map, pin in center of googlemap. now, add marker, somewhere on map. want zoom such center point remains in center of map, , marker visible within map, , highest zoom level. the problem if check if marker within boundaries of map or not, , keep zooming in/out till is, process repeat itself, i.e. trying zoom in , if marker became outside, zoom out. the problem rely on oncamerachange listener keep calling everytime zoom in or out, hence, process of zooming in/out keep occuring indefinitely journeygooglemap.setoncamerachangelistener(new oncamerachangelistener() { @override public void oncamerachange(final cameraposition position) { basically, need function can provide center latlng , markerlatlng , automatically calculate latlngbounds making sure center within center of latlng bounds, , can use public static cameraupdate newlat...

Snake Game Artificial Intelligence -

i developing snake game ios: https://github.com/scottbouloutian/snake my goal have ai complete game of snake optimally (have snake fill board). i using ida* find path snake's current location food. works. however, algorithm doesn't take account fact may need more food in future. result, tends box in. i.e. snake's goal @ given time find food, whereas it's goal should fill board (finding food along way). how can add or modify approach make ai win game of snake? there better approach should use instead? i'm trying come ideas. thanks! if board static rectangle (not torus - no crossing though borders) optimal strategy find set of longest closed paths through board, such each point in board in @ least 1 path. if board empty (there no obstacles) there exists "ultimate" path in form 16|.1|.6|.7 15|.2|.5|.8 14|.3|.4|.9 13|12|11|10 which goes through tiles, snake following pattern eat food, , fill whole board if there obstacles, suc...

android - Can't install apk via adb, file DNE despite showing up using adb shell ls -

i uploaded apk using adb adb push myappname.apk /sdcard/ to double check: adb shell ls /sdcard/ sure enough, it's there. then: adb install /sdcard/myappname.apk can't find '/sdcard/myappname.apk' install note* tried adding path in parentheses suggested on xda post didn't help. there multiple sdcard directories push defaults 1 , install defaults another? tried using root explorer find files adb install /sdcard/<tab> suggests can't file these files in dir. adb install takes file on pc install it. doesn't on phone.

android - How can I use response message from google tv to smart phone -

i'm developer korea. have 1 question, enter site. problem using response message google tv smart phone. want send question google tv smart phone, question show in google tv , reply in smart phone. @ time, how can send message google tv smart phone? use anymote library? or call method? if know question, please reply it. thank you!! it depends on how latency desire. use google cloud messaging send tv -> phone. on other hand, listen on socket when app wish signal open , send tv phone. this, of course, potentially use substantially more power.

lucene.net - How to index state abbreviations with the lucene standard analyzer? -

i'm having trouble indexing state abbreviation codes such in, or lucene .net. if use standard analyzer when indexing, cannot retreive documents these state abbreviations. if use simple analyzer when indexing, can retreive documents based on these abbreviations, other queries such zipcodes indexed strings no longer work. any suggestions on best practice type of lucene dilemna appreciated. thanks thanks i4v, post same issue. resolved changing code from this duplicate question. after reading post _standardanalyzer = new lucene.net.analysis.standard.standardanalyzer(lucene.net.util.version.lucene_30 to: this duplicate question. after reading post _standardanalyzer = new lucene.net.analysis.standard.standardanalyzer(lucene.net.util.version.lucene_30, new hashset<string>());

#2006 - MySQL server has gone away && phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection -

i uninstalled xampp , installed wamp , got error error mysql said: documentation 2006 - mysql server has gone away phpmyadmin tried connect mysql server, , server rejected connection. should check host, username , password in configuration , make sure correspond information given administrator of mysql server. (first xampp wamp.)

php - How to add day on this js time script? -

this js/php displaying function: <script type="text/javascript"> $.fn.cycle.defaults.speed = 900; $.fn.cycle.defaults.timeout = 5000; $(function() { $('#demos pre code').each(function() { eval($(this).text()); }); $('#demos2 pre code').each(function() { eval($(this).text()); }); }); $(function($) { var pstoptions = { timenotation: '12h', am_pm: true, utc: true, utc_offset: <%setting_timeoffset%>, fontfamily: 'verdana, times new roman', fontsize: '11px', foreground: 'white', background: 'black' } $('.jclockpst').jclock(pstoptions); }); </script> and full js script: /* * jquery jclock - cl...

java - regular expression to find special character & between xml tags -

a xml string generated model pass me, may contains special character such & in text of xml tag. e.g. <entry> <key>state</key> <value xsi:type="xs:string">adddress 3 & addr 4, 12345, hong kong</value> </entry> when build xml string have invalid character error, need escape special character & . want use regex find & between <value></value> tag , replace &amp; have tried fail on regex. can give me clue on regex? besides use java 1.6 you can use lookahead: replace &(?!\w*;)(?=[^<]*</value>) by &amp; this works specifying 2 lookaheads. first lookahead (?!\w*;) prevents valid html escape sequences being matched. second lookahead (?=[^<]*</value>) specifies </value> tag must follow text (after amount of non-xml-tag content). try here .

Java HashMap associative multi dimensional array can not create or add elements -

okay have spent several hours trying wrap head around concept of hashmap in java not able figure out. have looked @ many tutorials none seem address exact requirement , cannot work. i trying create associative multi dimensional array in java (or similar) can both save , retrieve array keys strings. this how in php , explains best trying do: //loop 1 - assign names myarray['en']['name'] = "english name"; myarray['fr']['name'] = "french name"; myarray['es']['name'] = "spanish name"; //loop 2 - assign description myarray['en']['desc'] = "english description"; myarray['fr']['desc'] = "french description"; myarray['es']['desc'] = "spanish description"; //loop 3 - assign keywords myarray['en']['keys'] = "english keywords"; myarray['fr']['keys'] = "french keywords"; myarray[...

Ruby on Rails "Template is missing" Error -

Image
i getting following error: template missing missing template admin/settings {:formats=>[:html], :locale=>[:en, :en], :handlers=>[:rxml, :erb, :builder, :rjs, :rhtml]} in view paths "c:/users/me/desktop/application/app/views" but seems in place. made sure properties allow full access file troubleshooting, still no go. missing here? ruby 1.8.7 rails 3.0.3 the name of template file should "settings.html.erb". you're missing "e" in file extension. note part of error says :handlers=>[:rxml, :erb, :builder, :rjs, :rhtml] . file extension of view must 1 of these template processed.

Creating a PHP PDO database class, trouble with the OOP -

this current database class: class database { private $db; function connect() { $db_host = "localhost"; $db_name = "database1"; $db_user = "root"; $db_pass = "root"; try { $this->db = new pdo("mysql:host=" . $db_host . ";dbname=" . $db_name, $db_user, $db_pass); } catch(pdoexception $e) { die($e); } } public function getcolumn($tablename, $unknowncolumnname, $columnonename, $columnonevalue, $columntwoname = "1", $columntwovalue = "1") { $stmt = $this->db->query("select $tablename $unknowncolumnname $columnonename='$columnonevalue' , $columntwoname='$columntwovalue'"); $results = $stmt->fetchall(pdo::fetch_assoc); return $results[0][$unknowncolumnname]; } } i'm trying run using following code: $db = new database(); $db->connect()...

php - Input not detected in jQuery -

this not fire code, , i'm not sure why. i've tried .change , .on('input') , can find. problem simple. wrong? $(function() { alert('hie'); //the min chars username var min_chars = 3; //result texts var characters_error = 'minimum amount of chars 3'; var checking_html = 'checking...'; //when button clicked $('#myusername').bind("change paste keyup", function() { //run character number check if ($('#myusername').val().length < min_chars) { //if it's bellow minimum show characters_error text $('#username_availability_result').html(characters_error); $('#checkuser').show(fast); alert('hsdi'); } else { //else show cheking_text , run function check $('#username_availability_result').html(checking_html); $(...

C# dynamic GridView/DataTable set up -

i'm working on table that's going dynamic company work for. hacked way around getting gridview work way wanted. but changed bit... i have gridview. every single column , row going textbox put numbers into. you start out 1 column , can add multiple ones @ push of button. there's fixed amount of rows (23). i tried adding textbox data row below, shows string of namespaces textbox in. should do? i'd avoid asp stuff, don't have slightest clue it's doing here have done far. datatable dt = new datatable(); datacolumn dc = new datacolumn("microns",typeof(textbox)); dt.columns.add(dc); (int = 0; < 23; ++i) { textbox tb = new textbox(); datarow row = dt.newrow(); row["microns"] = tb; dt.rows.add(row); } foreach (datacolumn col in dt.columns) { boundfield bfield = new boundfield(); bfield.datafield = col.columnname; bfield.headertext = col.columnname; gridview1.columns.add(bfield); } gridview1.d...

jdbc - StelsDBF java.lang.OutOfMemoryError: Java heap space -

i using evaluation version of stelsdbf jdbc driver 5.2 have dbf file 8302 rows , 43 cols 5mb , stelsdbf seems not working. stelsdbf works fine other smaller files. my query select codi,descrip \"data.dbf\" limit 10 when try results following exception in thread "'data.dbf' producer" java.lang.outofmemoryerror: java heap space @ jstels.database.b.d.if(unknown source) @ jstels.database.b.e.do(unknown source) @ jstels.jdbc.dbf.a.b.a(unknown source) @ jstels.jdbc.common.h2.operationtable$a.do(unknown source) @ jstels.jdbc.common.h2.operationtable$a.a(unknown source) @ jstels.utils.b.b$a.run(unknown source) i added parameter &dbpath=d:/juan/sync/syncro_db&temppath=c:/temp , next exception in thread "'data.dbf' producer" java.lang.outofmemoryerror: java heap space @ jstels.database.b.d.if(unknown source) @ jstels.database.b.e.do(unknown source) @ jstels.jdbc.dbf.a.b.a(unknown source) ...

php - org.json.JSONException: No value for item -

i no value {"username":"sara"}{"username":"john"} jsonexception when attempt view data mysql database using android app. 08-20 04:26:39.396: w/system.err(4732): org.json.jsonexception: no value {"username":"sara"}{"username":"john"} 08-20 04:26:39.497: w/system.err(4732): @ org.json.jsonobject.get(jsonobject.java:354) 08-20 04:26:39.497: w/system.err(4732): @ org.json.jsonobject.getjsonarray(jsonobject.java:544) 08-20 04:26:39.517: w/system.err(4732): @ com.example.phpapp.viewdata$mytask.doinbackground(viewdata.java:69) 08-20 04:26:39.577: w/system.err(4732): @ com.example.phpapp.viewdata$mytask.doinbackground(viewdata.java:1) 08-20 04:26:39.606: w/system.err(4732): @ android.os.asynctask$2.call(asynctask.java:287) 08-20 04:26:39.606: w/system.err(4732): @ java.util.concurrent.futuretask.run(futuretask.java:234) 08-20 04:26:39.631: w/system.err(4732): @ android.os.async...

vbscript - Unzip a password protected file in vbsript -

i facing trouble here,could please tell me how unzip password protected field in vbscript? have code runs perfectly,but asking password each time when runs pathtozipfile="c:\folder.zip" extractto="c:\" set sa = createobject("shell.application") set filesinzip=sa.namespace(pathtozipfile).items sa.namespace(extractto).copyhere(filesinzip) i need code not ask password in run,please help,thank you!! afaik shell.application object doesn't support providing password. try 7-zip instead: pass = "..." zipfile = "your.zip" createobject("wscript.shell").run "7za.exe x -p" & pass & " " & zipfile, 0, true if necessary add path 7za.exe and/or file.zip . if path contains spaces, you'll need put double quotes around it, e.g. this: function qq(str) : qq = chr(34) & str & chr(34) : end function zipfile = qq("c:\path\with spaces\to\your.zip")

java - NPE on a session filter -

i trying check cookies on pages in filter. code follows: public class sessionfilter implements filter { private arraylist<string> urllist; @override public void destroy() { // todo auto-generated method stub } @override public void dofilter(servletrequest req, servletresponse resp, filterchain chain) throws ioexception, servletexception { httpservletrequest request = (httpservletrequest) req; httpservletresponse response = (httpservletresponse) resp; string url = request.getservletpath(); boolean allowedrequest = false; if (urllist.contains(url)) { allowedrequest = true; } string username = null; string password = null; string loggedin = null; if (!allowedrequest) { cookie[] cookies = request.getcookies(); (int = 0; < cookies.length; i++) { string name = cookies[i].getname(); string value = cookies[i].getvalue(); if (name.equals("bccn_username")) username = value; else if (name.equals("bccn_password")) pas...

code generation - Automake, generated source files and VPATH builds -

i'm doing vpath builds automake. i'm using generated source, swig. i've got rules in makefile.am like: dist_noinst_data = whatever.swig whatever.cpp: whatever.swig swig -c++ -php $^ then file gets used later: myprogram_sources = ... whatever.cpp it works fine when $builddir == $srcdir . when doing vpath builds (e.g. mkdir build; cd build; ../configure; make ), error messages missing whatever.cpp . should generated source files go $builddir or $srcdir ? (i reckon $builddir .) how should dependencies , rules specified put generated files in right place? simple answer you should assume $srcdir read-only, must not write there. so, generated source-code end in $(builddir) . by default, autotool-generated makefiles source-files in $srcdir , have tell check $builddir well. adding following makefile.am should help: vpath = $(srcdir) $(builddir) after might end no rule make target ... error, should able fix updating source-generating rule...