Posts

Showing posts from February, 2010

node.js - getting webpack to work on openshift -

i'm trying deploy basic nodejs app openshift. i'm not sure how webpack though. build bundle.js file locally , deploy along index.html? tried putting bundle.js file in /public directory , pointing using relative path in index.html, bundle.js not found error. (it works when run locally.) step missing? must not use relative paths in openshift? find documentation openshift rather complicated. if out there can break down i'd appreciate it! i did miss step: need add directory in server.js so: self.initializeserver = function() { self.createroutes(); self.app = express.createserver(); self.app.configure(function() { self.app.use('/public', express.static(__dirname+'/public')); }); // add handlers app (from routes). (var r in self.routes) { self.app.get(r, self.routes[r]); } };

multithreading - Why is my goroutine starving? -

overview i writing program server launched in 1 goroutine. server has few different goroutines: the main goroutine : handles initialization, launches second goroutine listens new connections (2), , goes infinite loop act on data received connections (i.e., clients). the listen goroutine : goroutine goes infinite loop, listening new connections. if new connection accepted, goroutine launched listens messages connection until closed. the server seems work well. can add many new connections, , can send data on these new connections after accepted server. my client simple. there 2 goroutines well: the main goroutine : handles intialization, registers client server, launches second goroutine read data server (2), , goes infinite loop act on data received server. the second goroutine : goroutine tries read data server until connection closed. starvation i'm having huge issue goroutine starvation on client. specifically, second goroutine of client starves. here...

php - Run shell command and send output to file? -

i need able modify openvpn auth file via php script. have made http user no-pass sudoer, machine available within home network. i have following commands: echo shell_exec("sudo echo '".$username."' > /etc/openvpn/auth.txt"); echo shell_exec("sudo echo '".$password."' >> /etc/openvpn/auth.txt"); but when run, not change file @ all, or provide output in php. how make work? when run sudo command > file only command run sudo, not redirection. as pointed out, sudo sh -c "command > file" work. unless, want run command sudo, should not it. can run redirection part sudo. answer rici covers 2 methods it. here method: command | sudo tee filename >/dev/null #to overwrite (command > file) command | sudo tee -a filename >/dev/null # append (command >> file)

aligning text fields in css html form -

i'm trying make website form right side of text fields aligned when change size of screen, text fields no longer in alignment. how can keep them aligned regardless of screen size? here code: <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>coat request form</title> </head> <body> <form target="_top" action="https://www.salesforce.com/servlet/servlet.webtolead?encoding=utf-8" method="post"> <p> <input type=hidden name="oid" value="00di0000000go95"> <input type=hidden name="returl" value="http://www.empowermentplan.org/#!thank-you/jiwpq"> <span style="display:inline-block" margin-right="30px"> <label class="required" for="first_name" style="display:block...

opencv - How to Detect Color Combination using python? -

Image
i can detect blue color using hough circle, but, need detect 5 color exist , show number of robot. how detect combination using python or opencv? suggestion? this image: i don't think need use hough circles, if image size constant per id. here's alternative: in id image, figure out approx locations of yellowed points shown below: you'll have 5 interest points- (x[0],y[0]) (x[4],y[4]) let's suppose 1 yellow interest point located @ (10,10). since you're using python, can intensity of interest points using: img=imread("id.jpg")#read image b=[]#declare empty lists g=[] r=[] x=[] y=[] #save points of interest___ x[0]=10 y[0]=10 #likewise remaining 4 points in range(5) b[i]=img(x[i],y[i],0)#img single id image g[i]=img(x[i],y[i],1) r[i]=img(x[i],y[i],2) if(b[0]==100 , g[0]==0 , r[0]==255)#pinkish colour print "1st dot pink" now have total of 15 inte...

greasemonkey - android monkeyrunner display height vs. snapshot image height -

i run below monkeyrunner script seems display.height not same snapshot image height. in case, display .height 2360 snapshot image height 2560. #!/usr/bin/env monkeyrunner import time com.android.monkeyrunner import monkeyrunner, monkeydevice #----------------------------------------# def main(): device = monkeyrunner.waitforconnection() device.wake() time.sleep(1) screenw = float(device.getproperty("display.width")) screenh = float(device.getproperty("display.height")) screend = device.getproperty("display.density") print "screen size: %dx%d density:%s"%(screenw,screenh,screend) return #----------------------------------------# def touch(device,x,y,action=monkeydevice.down_and_up): screenw = float(device.getproperty("display.width")) screenh = float(device.getproperty("display.height")) screend = device.getproperty("display.density") print int(screenw*x),...

google apps script - Sheet add-on stopped loading after project document was undeleted -

Image
is there way can reach out in google apps team me outage? accidentally deleted file contained project associated sheets addon published on web , having 5000+ users (had thread here: https://stackoverflow.com/questions/36704711/i-accidentally-deleted-the-google-sheet-that-contained-code-for-my-published-add ) worked google drive support undelete file , can access it, , code fine. however, since addon installed many users stopped working everyone. gives users following error: "we're sorry, server error occurred. please wait bit , try again." i tried re-publishing new version of add-on, can't either, i'm getting following error: appreciated. was able fix reassigning sheets addon code different developers console project: resources -> developer console project... -> change project. created new empty project that. looks problem in addon being linked project reason got deleted when deleted addon code. , restoring addon code didn't restore asso...

javascript - Append a passed function parameter to $scope inside a controller -

i have ng-click="mymethod(parameter)" inside <button> element. want use parameter , in case, string inside controller can operations $scope.parameter.subproperties on it. in fact parameter alias name existing $scope.object. so aim reuse mymethod() in different places ng-click 's in <button> 's , perform same functionality on corresponding $scope objects identified parameter name. a mock code finding length of object1 inside controller like: .controller('myctrl', function($scope){ $scope.object1; $scope.object2; $scope.mymethod = function(arg){ var length = $scope.arg.length; }; }) here, value passed argument 1 of object names this: <button ng-click="mymethod(object1)">find length</button> any appreciated, thanks. you need use bracket notation when have dynamic key. $scope.object1; $scope.mymethod = function (arg) { var length = $scope[arg].length; }; but have pa...

Is there a way to pass a method CALL in C#? (not generic-function/delegate types) -

background i build queue of work methods need performed. add following 6 methods queue of work , perform them until queue exhausted. // method call #1 inputconfiguration("discrete input"); // method call #2 thread.sleep(100); // method call #3 disconnectfromground("pin 8"); // method call #4 checkforpause(); // method call #5 connectpins(7, 8); // method call $6 disconnectpin(9); question is there such structure/class can use account of different parameters , method calls? provided don't need return value, action fit bill. list<action> yourqueue = new list<action>(); yourqueue.add(() => inputconfiguration("discrete input")); yourqueue.add(() => thread.sleep(100)); // , on. perhaps instead of creating "a queue" of work, why not write new method? best performance way.

node.js - Using multiple proxies via request.js -

i trying send list of proxy addresses requestjs & want use first 1 that's working. @ possible via request.js my code var body = '<sample/>'; request.post({ url: www.google.com, proxy':'http://proxy1:8087;http://proxy2:8080',//need use multiple proxies here. headers: { //we can define headers 'content-type': 'text/xml' }, body: body, timeout:20000 } i thinking of looping through list of proxies , try use them 1 one. not sure if have been overkill or way possible. requestjs cannot loop through proxies, best possible option use agent module alongwith https://www.npmjs.com/package/pac-proxy-agent but module not iterate through list now. feasible option loop through list of proxies , use first 1 reachable now.

asp.net - how to stop update poco class when edmx file update -

i have created 1 project asp.net 4.5 , created entity classes use of "ef 4.x pocp entity generator" now problem have put variables in 1 of poco class update edmx file manually added variables been removed self if 1 has idea stop updating poco classes when edmx update let me know thanks in advance. this normal behavior. pocos generated each time update edmx. pocos partial classes it's pretty easay customize them. have article you'll find way customize pocos without having worry losing customization when generated files refreshed .

python 2.7 - NLTK synset with other languages -

right i'm trying compare words 2 different files, 1 english, 1 chinese. have identify if of english words related chinese words , if are, equal or 1 hypernym of other. can use synsets english can chinese words? it looks there chinese (cmn) wordnet available university in taiwan: http://casta-net.jp/~kuribayashi/multi/ . if wordnet has same format english wordnet, can use wordnetcorpusreader ( http://nltk.googlecode.com/svn/trunk/doc/api/nltk.corpus.reader.wordnet-pysrc.html#wordnetcorpusreader ) in nltk import mandarin data. don't know how you're doing alignments or translations between 2 datasets, assuming can map english chinese, should figure out how relation between 2 english words compares relation between 2 mandarin words. note if data uses simplified script, may need convert traditional script before using cmn wordnet.

How to get an already created JSONStore in Mobilefirst -

i trying create jsonstore in mobilefirst 7.0 hybrid app. issue having able detect jsonstore there on subsequent runs of app. documentation says have have called wl.jsonstore.init(...) before calling wl.jsonstore.get(...). so question is, on subsequent runs of app (meaning app ran first time , created jsonstore successfully) , new run, proper way check if jsonstore exists? if have call init again, how do without wiping out there? i using snippet of code detect... function checkjsonstore() { alert("in checkjsonstore"); var collectionname; try { // check see if jsonstore exists... collectionname = wl.jsonstore.get('appstore'); } catch (e) { // todo: handle exception alert("checkjsonstore: exception = " + e.message); } alert("returning checkjsonstore: " + collectionname); return collectionname; } here code create store...it runs successfully. function initjsonstore() { console.log("in initjsonstore:"); ...

Sqoop the data from oracle using HDP 2.4 on windows environment -

sqoop data oracle using hdp 2.4 on windows environment error message: the system can not find file specified. sqoop import --connect jdbc:oracle:thin:hud_reader/hud_reader_n1le@huiprd_nile:1527 --username hud_reader --password hud_reader_n1le --table <dataaggrun> --target-dir c:\hadoop\hdp\temp --m 1 help appreciated. thank you.

sql - easiest way to substract in one column and add in other -

basically i'm trying move existances 1 register another, substracting origin point , adding destiny. have 1 table of "stocks" this: country city value aa 01 500 aa 02 400 bb 01 300 cc 01 100 cc 02 1000 cc 03 2000 and receiving document of "movements" structure this: quantity origincountry origincity endcountry endcity 10 aa 01 cc 01 20 aa 01 bb 02 50 bb 01 cc 03 is there way without creating 2 normalized tables , several queries. edit the answer must this: quantity origincountry origincity endcountry endcity aa 01 470 aa 02 400 bb 01 250 cc 01 110 cc 02 1020 cc 03 2050 negative number , business rules aren't relevant try (isnull tsql): select country, city, value - isnull(p, 0) + isnull(m, 0) q stocks s left join (select origincountry, or...

edi - Is it possible that both TA1 and 999 missing in BizTalk when inbounding a bad formatted X12 file? -

this 1st time meet this. normally when received inbound x12 file. 999 generated (by configuration in biztalk) , in case of interchange level error occurs, ta1 created. but today got x12 file formatting errors, error popup in biztalk : delimiters not unique, field , component seperator same. sequence number of suspended message 1. i expecting have 999 or ta1 generated reject inbound file. none of these 2 files created. my question: what file shall expect created kind of error? 999 or ta1? is bug or normal behavior biztalk? if normal, best mechanism catch error , response trading partner. you should not expect 999 (which transaction set specific), because error prevents biztalk parsing transaction set @ - doesn't have reliable way determine kind of transaction is. a ta1 appropriate, seems grey area - might worth contacting microsoft support about. documentation indicates invalid isa should result in negative ta1, error codes ta1 don't list ...

go - How to create a custom hashcode to determine if data has mutated -

say have struct type has int64 , bools, along embedded types have more int64 , bool type fields. type t1 struct { f1 int64 f2 int64 f3 bool t2 t2 } type t2 struct { f4 int64 f5 int64 f6 bool } now using structs fields/properties, want generate hashcode. the aim of can determine if contents of instance has changed comparing before/after hashcode value. so if t1 instance has changed i.e. of own properties value of hash should different. you can use like: func (t *t1) hash() uint64 { hb := make([]byte, 8+8+1+8+8+1) binary.bigendian.putuint64(hb, uint64(t.f1)) binary.bigendian.putuint64(hb[8:], uint64(t.f2)) if t.f3 { hb[16] = 1 } binary.bigendian.putuint64(hb[17:], uint64(t.t2.f4)) binary.bigendian.putuint64(hb[25:], uint64(t.t2.f5)) if t.t2.f6 { hb[33] = 1 } f := fnv.new64a() f.write(hb) return f.sum64() } playground although if using map key, it's better directly use stru...

ruby - Sinatra does nothing with requests from a phonegap application -

i have simple sinatra server post block. if send $.post browser server receives post, when sent phonegap application nothing, no error code or output whatsoever. i wrote simple tcpserver#accept process, , since successful proceeded sinatra, found following: this post works in sinatra , tcpserver.accept post /api/v/1 http/1.1 host: localho.st:8015 content-type: application/x-www-form-urlencoded; charset=utf-8 origin: http://api.jquery.com cookie: _fitter_session=[deleted] content-length: 7 connection: keep-alive accept: */* user-agent: mozilla/5.0 (macintosh; intel mac os x 10_10_5) applewebkit/601.5.17 (khtml, gecko) version/9.1 safari/601.5.17 referer: http://api.jquery.com/jquery.post/ accept-language: en-us accept-encoding: gzip, deflate the next 1 doesn't work in sinatra though still in tcpserver post /api/v/1 http/1.1 host: localho.st:8015 connection: keep-alive content-length: 362 accept: application/json, text/javascript, */*; q=0.01 origin: file:// user-agent:...

arduino - MATLAB and Arudino, set registers (PWM) -

i using arduino mega matlab first time try , control servo motor, issue default pwm frequency pin trying use @ 976hz, while need around 50hz. found code changing timer 0 b register affects frequency use in arudino ide. so basically, need send following command arduino: tccr0b = tccr0b & b11111000 | b00000101; does know how while using arduino mega through matlab? there not way have straight arudino code in .m file through function/syntax? or there way manipulate tccr0b register via matlab? know on arduino ide need use matlab rest of project. thank time.

php - Do PDO tokens need to match the bindValue 1:1? -

i have code $query = 'insert table (foo, bar, baz) values (:foo, :bar, :baz) on duplicate key update foo = :foo, bar = :bar, baz = :baz'; $stmt = $dbc->prepare($query); $stmt->bindvalue(':foo', $foo, pdo::param_str); $stmt->bindvalue(':bar', $bar, pdo::param_str); $stmt->bindvalue(':baz', $baz, pdo::param_str); $stmt->execute(); its throwing error: fatal error: uncaught exception 'pdoexception' message 'sqlstate[hy093]: invalid parameter number: number of bound variables not match number of tokens obviously, have twice many token bound variables, have same number of unique tokens. question is, can each token used once? need rename second instance of each token work, or there way without doubling bindvalue statements? it turns out can reuse tokens. error else entirely. if ...

MySql query to pull data in matrix form from database -

i have data in database 2 columns name , year. this, name | year ----------- tim | 2001 ron | 2002 tim | 2003 ron | 2005 tim | 2004 pol | 2002 pol | 2001 tim | 2003 pol | 2004 tim | 2002 i want output result matrix this. tim | pol | ron 2001 1 | 1 | 0 2002 1 | 1 | 1 2003 2 | 0 | 0 2004 1 | 1 | 0 2005 0 | 0 | 1 tim | pol | ron arranged in descending order based on cumulative sum i.e tim(5), pol(3), ron(2). data not limited tim,pol,ron. there can n-different names. select year, sum(name='tim') tim, sum(name='pol') pol, sum(name='ron') ron yourtable group year please see fiddle here . edit: if need dynamic query because exact number of values vary, use prepared statement this: select concat('select year,', group_concat(sums), ' yourtable group year') ( select concat('sum(name=\'', name, '\') `', name, '`') sums yourtable gro...

sql server - Looking for everywhere a particular value has been used in foreign keys in one pass -

good afternoon. i using sql server 2008/tsql. important note not have write access db (i read user). not have write access db can insert temp tables if absolutely needed. i preface letting know have no formal education in sql. makes sense - may inaccurate in vocabulary etc. scope of trying do: 1. select specific recordid (value) in column (primary key) table 2. find specific number/recordid used in dependents/foreign keys 3. return tablename , columnname count of how many times value found so, example... have table information on person tied recordid, like: dbo.memberinfo recordid, name etc. the id number of member (memberinfo.recordid) used in other tables, say: dbo.awards [honoreeid] (dbo.awards.honoreeid=memberinfo.recordid) dbo.address [memberid] (dbo.address.memberid=memberinfo.recordid) dbo.contact [personid] (dbo.contact.personid=memberinfo.recordid) ...and potentially few hundred others i want run through tables , see how many times particula...

cordova - JavaScript Redirect doesn't work windows mobile app -

hey guys have error when try redirect page in windows mobile app: error: apphost9624:the app can't use script load https://google.com url because url launches app. direct user interaction can launch app. code used in js file: window.open('https://google.com'); i tried install cordova inappbrowser plugin, after code like: var app = { // application constructor initialize: function() { this.bindevents(); }, // bind event listeners // // bind events required on startup. common events are: // 'load', 'deviceready', 'offline', , 'online'. bindevents: function() { document.addeventlistener('deviceready', this.ondeviceready, false); }, // deviceready event handler // // scope of 'this' event. in order call 'receivedevent' // function, must explicitly call 'app.receivedevent(...);' ondeviceready: function() { app.receivedeven...

python - Instantiating a Flask object within a large application -

suppose create flask server has method called foo(). suppose have python app wants create instance of server , use foo(). my_server = flaskobject() my_server.foo() i want have instance of flask server can manipulate without having send http requests. i feel there simple solution i'm overlooking can't figure out. any appreciated.

mysql - Why doesn't my query return any rows -

structure table show here if use query: select idn balans outerb idn!='' group idn order ifnull((select sum(innerb.amount) balans innerb innerb.idn = outerb.idn , status='up'), 0) - ifnull((select sum(innerb.amount) balans innerb innerb.idn = outerb.idn , status='down'), 0) desc limit 15 i 2 rows. but if add condition >0 : select idn balans outerb idn!='' , ( (select sum(innerb.amount) balans innerb innerb.idn = outerb.idn , type='up') - (select sum(innerb.amount) balans innerb innerb.idn = outerb.idn , type='down') ) > 0 group idn order ifnull((select sum(innerb.amount) balans innerb innerb.idn = outerb.idn , type='up'), 0) - ifnull((select sum(innerb.amount) balans innerb innerb.idn = outerb.idn , type='down'), 0) desc limit 15 in result 0 rows... tell me please error? why getting 0 rows? you didn't include ifnull() in where conditi...

java - Sorting SOLR autosuggestion on custom score field -

i've got apache solr web application. i'm saving queries entered in database , index , query string , query string count suggestion core. here format <doc> <str name="id">superman</str> <long name="searchcount_l">10</long> //superman has been queried 10 times <doc> <doc> <str name="id">superman movie</str> <long name="searchcount_l">30</long> //superman movie has been queried 30 times <doc> configuration: <searchcomponent name="suggest" class="solr.spellcheckcomponent"> <lst name="spellchecker"> <str name="name">suggest</str> <str name="classname">org.apache.solr.spelling.suggest.suggester</str> <str name="lookupimpl">org.apache.solr.spelling.suggest.fst.wfstlookupfactory</str> <str name=...

Magento "Forgot Password" email sent in wrong language -

i have magento site multiple languages. have setup language packs , seems translate on website. transactional e-mails sent in correct language except " forgot password " e-mail sent in german. here's did: installed language packs , made sure templates , folder structures correct. example: /app/locale/nl_nl/template/email/ under system » transactional emails : applied template, chose locale , saved. then went system » configuration » sales emails , switched each language " current configuration scope " dropdown, , chose templates created in transactional emails each language (each store view). after looking around online solution, seems others had problem , mentioned magento picking "forgot password" template first locale folder found in /app/locale/ . in case had: de_de , en_us , fr_fr , nl_nl . picks template german de_de pack. note : also, in backend under "configuration" there's tab on left called "locale packs...

jquery - Element will not disappear and reappear until done manually the first time -

what should happen when click log in button, container log in form should become hidden , sidebar, search bar, tiles , log out button should appear. experience if have click log in button twice react or when click it, other elements appear should brief moment , page either reloaded or elements hidden again , log in container foo unhidden. debugging purposes have inserted <a href="#" onclick="toggle_visibility('foo');">toggle container on.</a> manually hide , unhide log in container foo. not until after log-in button appropriately desired. feel need initialize value toggle continer on. doing me stumped. have commented in code below elements correspond sections of code. have tried google chrome , mozilla firefox. appreciate insight or assistance. have found few sources online initialize element style="display:none" has not helped. here html w/ jquery: <!doctype html> <html> <head> <title>welcome f...

osx - Why when I use p2.director to install Eclipse Mars.2 on Macosx there is no launcher? -

i installing eclipse mars.2 ide on mac pointing p2.director eclipse platform 4.5.2 repository, , completes without error, there not launcher. here command use: ./eclipse -nosplash -application org.eclipse.equinox.p2.director -profileproperties org.eclipse.update.install.features=true -roaming -repository http://download.eclipse.org/eclipse/updates/4.5/r-4.5.2-201602121500 -installiu org.eclipse.sdk.ide -bundlepool /home/me/ecl452 -destination /home/me/ecl452 -p2.os macosx -p2.ws cocoa -p2.arch x86_64 -profile sdkprofile there no errors, reports it's installing org.eclipse.sdk.ide 4.5.2.m20160212-1500, , completes "operation completed in 101165 ms". there no "eclipse.app" folder in destination, , no eclipse launcher file. resulting destination folder has this: -rw-r--r-- .eclipseproduct -rw-r--r-- artifacts.xml drwxr-xr-x configuration drwxr-xr-x dropins -rw-r--r-- eclipse.ini drwxr-xr-x features drwxr-xr-x p2 drwxr-xr-x plugins drwx...

asp.net mvc - .NET MVC routing using attributes only -

does know how create route in .net mvc contains attributes only? code follows: [route("{listingcategorydescription}/")] public actionresult categorysearch(string listingcategorydescription) { as can tell want url contain category. possible? or need hard code @ least 1 part of route? many thanks. are wanting category passed in @ root url? http://localhost/apples ? if so, work, collide other routes. public class categoriescontroller : controller { [route("{listingcategorydescription}")] public actionresult index(string listingcategorydescription) { return content("you picked category: " + listingcategorydescription); } }

java - Libgdx game crashes -

my libgdx game crashes sometimes. have no idea why, don't think worth posting code yet, before knowing comoing from. running game on windows. here console output: # fatal error has been detected java runtime environment:# # internal error (os_windows_x86.cpp:144), pid=12252, tid=14156 # guarantee(result == exception_continue_execution) failed: unexpected result toplevelexceptionfilter # # jre version: java(tm) se runtime environment (8.0_65-b17) (build 1.8.0_65-b17) # java vm: java hotspot(tm) 64-bit server vm (25.65-b01 mixed mode windows-amd64 compressed oops) # failed write core dump. minidumps not enabled default on client versions of windows # # error report file more information saved as: # c:\...\assets\hs_err_pid12252.log # # if submit bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp # crash happened outside java virtual machine in native code. # see problematic frame report bug. # # process finished exit code 1 where error come from? ha...

arrays - C# For loop inside of method -

i trying create method step through array loop , if array subscript greater or equal minimum requirement string array subscript added listbox. here feeble attempt, along method i've tried below it. when calling method awardminimum, whole thing incorrect stating, "has invalid arguments". commented out every level looks like. (level <=10, level >10 && <=20, etc..) if (level <= 10) { awardminimum(perdayarray, min, awardsarray); /*for (int = 0; < statsize; i++) { if (perdayarray[i] >= 2) { awardlistbox.items.add(awardsarray[i]); } }*/ } the method itself private void awardminimum(double perday, int min, string awards) { (int = 0; < statsize; i++) { if (perday >= min) { awardlistbox.items.a...

javascript - Images inside posts re-sized gradually to be in zeros width and height in android browser -

Image
i've got many reports android visitors my blog said when browsing post blog, images inside posts re-sized gradually hidden (width , height zeros, shadow of image visible). i've tested , confirm issue in android browser , facebook browser well, google chrome shows ok. i don't know causing problem, javascript or css problem? i'm using bootstrap css code images responsiveness on mobile devices. seems line did problem: img {box-sizing:border-box}; i removed , works in android browser!

java - How do I stop an animation once a certain barrier has been reached? -

today's question rattling mind such. i'm creating program allow user jump , move left or right, problem whenever try jump program freezes... idea behind code simple, whenever users presses space(jump) rectangle "jumps" , if y of rectangle within height above obstacle(in case rectangle dimmensions brickx,bricky,brickw, , brickh obstacle) animation supposed stop , rectangle supposed wait next command while in place on top of obstacle. method stayonbrick called during each iteration of while loop , checks; during jump, if y within needed range, , if y sets boolean jump = true should break loop on next iteration setting y needed value. when space pressed, nothing happens, or should program freezes. thoughts? import java.awt.*; import java.awt.event.keyevent; import java.awt.event.keylistener; public class keytest extends core implements keylistener{ window w; public int x,y; boolean jump = true; public int brickx, bricky, brickw, brickh; public ...

javascript - Toggle Checkbox with jQuery on parent click -

i have following code example: http://jsfiddle.net/sx3w9/ $('.item').on('click', function() { var checkbox = $(this).find('input'); checkbox.attr("checked", !checkbox.attr("checked")); $(this).toggleclass('selected'); }); where user should able click div.item and/or checkbox inside , should check or uncheck checkbox , add or remove selected class div. it works when clicking div, clicking checkbox instantly unchecks again... try following code: $('.item').on('click', function() { var checkbox = $(this).find('input'); checkbox.attr("checked", !checkbox.attr("checked")); $(this).toggleclass('selected'); }); $(".item input").on("click", function(e){ e.stoppropagation(); $(this).parents(".item").toggleclass('selected'); }); t...

windows - TASM Print characters of string -

i'm trying print string character character, iterating through it. i've got: .model small .stack 64 .data string db 'something',0 len equ $-string .code xor bx, bx mov si, offset string char: mov al, byte[si + bx] inc bx cmp bx, len je fin mov ah, 2 mov dl, al int 21h jmp char fin: mov ax, 4c00h int 21h end i don't know if i'm getting right mem reference of string, because shows me weird symbols. tried adding 30 dl, thinking because of ascii representation. how can print char char? here working example tasm, not mangling begining of string. it has 1 less jump due moving of increment later , replacement of je jnz .model small .stack 64 .data string db 'something' len equ $-string .code entry: mov ax, @data ;make ds point our data segment mov ds, ax xor bx, bx ;bx <-- 0 mov si, offset string ;address of string print mov ah, 2 ...

java - Converting varchar to integer on Oracle using Hibernate -

in project score field in database varchar datatype, contains integer values need fetch records having score between 70 50. (i.e less 70). my query query count_query = stmt1.query().from(selectedtable).selectcount(). where(districtcolumn).equals(district_code). and(score).isnull().or(score).lessthan("70").toquery(); trying to_num not accepting. accepts column data types. try modify entity (tested on mysql): @formula(value = " cast(score decimal(10,0) ) ") public long getscore()

c# - sql update statement conflict with foreign key -

i trying update sql table stored procedure: set ansi_nulls on go set quoted_identifier off go create procedure [dbo].[updatepostingstatusangel] @postingstatusid tinyint, @postingid int update dbo.posting set postingstatusid = @postingstatusid postingid = @postingid when executing query getting error: the update statement conflicted foreign key constraint "fk_posting_paymentstatus". conflict occurred in database "jobsdb2008", table "dbo.paymentstatus", column 'paymentstatusid'. this weird because not updating 'paymentstatusid' column don't know why gives me conflict on column. column set null , has value already. trying update postingstatusid field. idea can reason? in advance, laziale the value stored in paymentstatusid column must not exist in paymentstatus table. ensure postingstatusid , paymentstatusid valid id's , exist in appropriate tables. select paymentstatusid, postingstatusid posti...

javascript - customClass in Angularjs uib-datepicker depends on a promise -

i'm using angularjs ui bootstap datepicker , , trying set custom classes days, it's shown @ example on provided page this part of mine controller var vm = this; ... vm.dateoptions = { customclass: gettestdaysclass; }; ... function gettestdaysclass(data) { var date = data.date, mode = data.mode; if (mode === 'day') { var daytocheck = new date(date).sethours(0,0,0,0); (var = 0; < vm.testdays.length; i++) { var currentdat = new date(vm.testdays[i].date).sethours(0,0,0,0); if (daytocheck === currentdat) { return vm.testdays[i].status; } } } return ''; } and html <uib-datepicker datepicker-options="user.dateoptions"> </uib-datepicker> the problem array vm.testdays back-end call service. , isn't in controller's scope yet, when page loaded, application crashes following error . give me hint how solve this? ...

javascript - jquery - append html doesn't append the empty String inside the div -

Image
i doing chat project in java . using server response through jquery-ajax , creating html , append html div . my jquery - html alert without empty string -name(note id='user' in alert) , after appending in chat area , after jquery-html alert with empty string -name(note id='user' in alert) , after appending in chat area , my jquery creating html , function send(name , message , time){ //name = $("#name").val(); //message = $("#message").val(); var user = "<div id='user' class='fontstyle'>"+name+"</div>"; var msg = "<div id='msg' class='fontstyle'>"+message+"</div>"; var timestamp = "<div id='time' class='fontstyle'>"+time+"</div>"; var row = "<div id='msgset' >"+ user + msg + timestamp +"</div>"; ale...

java - Applet is not going to stop running -

Image
import java.awt.eventqueue; import javax.swing.jframe; public class window1 extends jframe { private jframe frame; } when run code applet running don't want. appreciated thx applet window see this, stopping now? import java.lang.runnable; import javax.swing.swingutilities; import javax.swing.jframe; public class window1 extends jframe { public static void main(string... args){ javax.swing.swingutilities.invokelater(new java.lang.runnable() { public void run() { window1 window = new window1(); window.setdefaultcloseoperation(jframe.exit_on_close); window.setbounds(200, 200, 400, 300); window.setvisible(true); } }); } }

node.js - nodejs - every minute, on the minute -

how can wait specific system time before firing ? i want fire event when seconds = 0, i.e. every minute while (1==1) { var date = new date(); var sec = date.getseconds(); if(sec===0) { something() } } you shouldn't that, because while have blocking operation. also, there better things in javascript platform, using setinterval / settimeout functions. node docs them here . a quick example of how achieve want: setinterval(function() { var date = new date(); if ( date.getseconds() === 0 ) { dosomething(); } }, 1000); for more fine grained control on scheduled processes in node, maybe should checkout node-cron .

javascript - What two array indexes mean when placed one after another? -

i'm learning loops , can't part of below script - values [i][0] mean here? (code found in answer , described stopping condition). end , start of array? function getfirstemptyrowbycolumnarray() { var ss = spreadsheetapp.getactivespreadsheet(); var values = ss.getrange( 'a:a' ).getvalues(); var = 0; while ( values[ ] && values[ ] [ 0 ] != "" ) { i++; } return ( +1 ); } values more dimensional array. first index points array , second index gives element of array. can imagine matrix rows , columns. first index row , second column. if want know more multi dimensional arrays in javascript can check out answers question: how can create 2 dimensional array in javascript?

c++ - Add addresses of Objects to a vector in loop -

i need create several objects , put them in list (for using std::vector). also, need list items point addresses of objects changes make objects reflected in list too. thing is, every item in list pointing last object created in loop. for(int i=0;i<50;i++){ for(int j=0;j<50;j++){ grass g1; g1.position.x = i; g1.position.y = j; grasslist.push_back(&g1); } } the attributes of grass objects in list should be.. [0,0] [0,1] [0,2] . . . . [49,49] but it's coming out be.. [49,49] [49,49] [49,49] [49,49] . . . [49,49] you're pushing pointers local variables vector. local variables destroyed @ end of scope (the second-to-last } in case). therefore, dereferencing of pointers after } undefined behavior . output you're seeing valid result of undefined behavior. using pointers here doesn't make sense. use them (including new ) when absolutely necessary. more info, see why s...

c# - Include XML CDATA in an element -

update: added more detail per request i trying create xml configuration file application. file contains list of criteria search , replace in html document. problem is, need search character strings &nbsp . not want code read decoded item, text itself. admitting being new xml, did make attempts @ meeting requirements. read load of links here on stackoverflow regarding cdata , attributes , on, examples here (and elsewhere) seem focus on creating 1 single line in xml file, not multiple. here 1 of many attempts have made no avail: <?xml version="1.0" encoding="utf-8" ?> <!doctype item [ <!element item (id, replacewith)> <!element id (#cdata)> <!element replacewith (#cdata)> ]> ]> <item id=" " replacewith="&nbsp;">non breaking space</item> <item id="&#8209;" replacewith="-">non breaking hyphen</item> this document gives me number of errors,...

ios - UIButton change font and text at the same time -

we have uibutton in our app change , forth between displaying normal system font string , fontawesome icon (which unicode character specific font). can switch , forth between these fine, except ios animates 2 changes 1 after other, there brief amount of time text shows strangely after first change before second. tried using uiview.beginanimations commitanimations counterpart, animatewithduration:animations: , neither had effect. how can change both text , font @ same time? edit: updated code per comment func changetosend() { sendbutton.titlelabel?.font = uifont(name: "system", size: 15) sendbutton.settitle("send", forstate: uicontrolstate.normal) } func changetomicrophone() { sendbutton.titlelabel?.font = uifont(name: "fontawesome", size: 24) sendbutton.settitle("\u{f130}", forstate: uicontrolstate.normal) } try this: func changetosend() { uiview.performwithoutanimation { self.se...

opencv - Measure size of box from camera image(s) -

i'm working on grasping cuboid objects (aka small cardboard boxes) placed on table robot has camera attached gripper. need exact size of box (error ~ 1mm) , position on box. have ideas hear other approaches before start implementing. some additional info: the boxes textured, although edges commonly white don't appear in edge image. i change surface, objects placed on, use kind of pattern simplify segmentation process or use electro-luminous foils have perfect edges (at boundary of object). i can actively move arm (which has (<1 mm) odometry) take 2 images different positions my strategy far: take 2 images known positions @ least can compute height of box. find edges of box (segmentation against background) , use intersections of edges find corners of box in image. known height can compute size , position of box on table. in cases corners sufficient there 1 hard case: if i'm looking straight on box (no sides visible), can detect 4 corners in edge image. , in...

How to get ID of user set default keyboard in Android -

i want make button in custom keyboard when pressed switch keyboard default user keyboard. have figured out how set input keyboard this: final string latin = "com.android.inputmethod.latin/.latinime"; final ibinder token = this.getwindow().getwindow().getattributes().token; imm.setinputmethod(token, latin); in case, pressing button want implement switch keyboard default user specified keyboard (latin keyboard). the problem in particular example string given. how find string of id of default user specified keyboard can set inputmethod . you can active keyboard's id in following example: string id = settings.secure.getstring( getcontentresolver(), settings.secure.default_input_method) if soft keyboard being used input, above code return keyboard's id. but, can this: when input picker button clicked, can show list of input methods, , let user choose whatever input method likes: inputmethodmanager inputmanager ...

Cannot get value of certain cookies - Javascript -

i have been using this code found on github collect utm/other url parameters. i have been able save parameters in cookie, , pass values hidden input form. this code loaded through google tag manager on every page of website. scenario: -the cookie sessions exist on every page of site expected. -the main website on non-secure http connection ( http://www.example.com ). -a secure page exists on subdomain. ( https://www.subdomain.example.com ). problem: on secure, subdomain page, cannot values none of utm cookies. can values visitors, ireferrer, lreferrer, , ilandingpage cookies, not utm cookies. here code using: <script type="text/javascript" charset="utf-8"> jquery(document).ready(function(){ var _uf = _uf || {}; _uf.domain = ".exampledomain.com"; var utmcookie; utmcookie = (function() { function utmcookie(options) { if (options == null) { options = {}; } this._cookienameprefix = '_uc_'; ...