Tuesday, 15 July 2014

Node.js server is breaking without any error -



Node.js server is breaking without any error -

i using border module (https://github.com/tjanczuk/edge) read sql database. function follows:

function getbetweenrows(cb) { //console.log("lastcheckedid within function ", lastcheckedid); //console.log("lastinsertid within function ", lastinsertid); console.log("here 2"); var query = { connectionstring: "data source=localhost;initial catalog=db-name;integrated security=true", //source: "select * customermaster customerid between '" + lastcheckedid + "' , '" + lastinsertid + "';" source: "select * customermaster customerid between '2965' , '2972';" }; console.log("query ", query.source); console.log("here 3"); var getrows = edge.func('sql', query); console.log("here 4"); getrows(null, function(error, result) { console.log("here 5"); if (error) { console.log(error); throw error; log.error({rows:error}); } rows = result; log.info({rows:rows}); console.log(rows); console.log("here 6"); cb(rows); }); }

funny thing code working on other systems. on particular system, prints till here 4 , server breaks. doesn't show error whatsoever. how find out what's problem?

sorry, don't know posted happening diferently on diferent systems if want debug , find step step diferences on 2 systems, utilize node debugger:

http://nodejs.org/api/debugger.html

it's worth getting know.

also, have noticed occasional issues cannot yet explain, when throwing errors. seek commenting out throw line on offending scheme (an maybe log.js phone call well.) if fixes issue, know errors.

let me know find.

node.js

c++ - Would std::count_if be faster without an if? -



c++ - Would std::count_if be faster without an if? -

here's gcc std::count_if code

template<typename _inputiterator, typename _predicate> typename iterator_traits<_inputiterator>::difference_type count_if(_inputiterator __first, _inputiterator __last, _predicate __pred) { [snip] typename iterator_traits<_inputiterator>::difference_type __n = 0; (; __first != __last; ++__first) if (__pred(*__first)) ++__n; homecoming __n; }

my question: work improve (i.e., faster) use

__n += __pred(*__first); // instead of if statement

this version add, doesn't branch.

the replacement gave is not equivalent, because there far fewer restrictions on predicate think:

anything can used in conditional context (can contextually converted bool), valid return-type predicate (an explicit conversion bool enough). that return-type can react funny beingness added iterators difference-type. 25 algorithms library [algorithms] 25.1 general [algorithms.general]

8 predicate parameter used whenever algorithm expects function object (20.9) that, when applied result of dereferencing corresponding iterator, returns value testable true. in other words, if algorithm takes predicate pred argument , first iterator argument, should work correctly in build pred(*first) contextually converted bool (clause 4). function object pred shall not apply non-constant function through dereferenced iterator.

the homecoming giving replacement indigestion standard integer-type, , value neither 0 nor 1.

also, maintain in mind compilers can optimize nowadays (and c++ ones need to, template-stuff layered deep).

c++ performance gcc stl

performance - JMS queue consumer: synchronous receive() or single-threaded onMessage() -



performance - JMS queue consumer: synchronous receive() or single-threaded onMessage() -

i need consume q, , stamp sequence key on each message indicate ordering. i.e. consumption needs sequential. performance/throughput point of view, improve off using blocking receive() method, or async listener single-threaded configuration on onmessage() method?

thanks.

there many aspects impact performance , throughput; in pure jms terms it's not possible state sync or async model of getting messages less or more efficient. depend on big number of factors how application written, other resources it's using, implementation of chosen messaging provider , other factors such machine performance , configuration of both client , server machines.

this discussion, single vs multi-threaded jms producer, covered of these topics.

to sequence, if single threaded, single session jms specification gives assurances on message ordering; best review spec see if matches overall requirements.

often people insert application sequence number @ message production time; consumer can hence check getting right message in order. adding sequence number @ consumption time won't help consumer.

keep in mind stricter requirement messaging ordering more restrictive overall architecture gets , harder implement horizontal scalabilty.

performance queue order jms consumer

Installing New Relic .NET Agent in an Azure Web Role -



Installing New Relic .NET Agent in an Azure Web Role -

i configured free standard version of new relic in azure portal in add-ons section. created new web role , i'm deploying asp.net application web role. added newrelicwindowsazure bundle nuget. re-deployed web application , i'm getting nil registering in new relic command panel.

i believe issue not having agent installed on machines when new total installation. when rdp instance , install agent seems work fine.

how can shoehorn installation deployment? see nuget bundle added newrelic.cmd in root of web app, tried add together azure cloud service project in servicedefinition.csdef file so:

<startup> <task commandline="newrelic.cmd" executioncontext="elevated" /> </startup>

it seems installing -something-, looks new relic server agent installed not started, , don't see base of operations apm agent. how can automate installation successfully?

here answer. had apply more settings task:

<task commandline="newrelic.cmd" executioncontext="elevated" tasktype="simple"> <environment> <variable name="emulated"> <roleinstancevalue xpath="/roleenvironment/deployment/@emulated" /> </variable> <variable name="isworkerrole" value="false" /> <variable name="license_key"> <roleinstancevalue xpath="/roleenvironment/currentinstance/configurationsettings/configurationsetting[@name='newrelic.licensekey']/@value" /> </variable> </environment> </task>

azure azure-web-roles newrelic

java - JDBC insert error -



java - JDBC insert error -

i trying insert info database jdbc. using right table, db name, , parameters. checked.

code

public static void main(string[] args) throws ioexception/*, classnotfoundexception, sqlexception*/ { datainputstream d = new datainputstream(system.in); system.out.println("enter employee id : "); @suppresswarnings("deprecation") int empid = integer.parseint(d.readline()); system.out.println("enter employee name : "); @suppresswarnings("deprecation") string empname = d.readline(); system.out.println("enter employee id : "); @suppresswarnings("deprecation") double empsalary = double.parsedouble(d.readline()); seek { class.forname("com.mysql.jdbc.driver"); } grab (classnotfoundexception e) { e.printstacktrace(); } connection con; seek { con = drivermanager.getconnection("jdbc:mysql://localhost:3306/testdb","root",""); preparedstatement pst = con.preparestatement("insert `employee` values(?,?,?"); pst.setint(1, empid); pst.setstring(2, empname); pst.setdouble(3, empsalary); int rowcount = pst.executeupdate(); system.out.println(rowcount + " row has been instered"); } grab (sqlexception e) { e.printstacktrace(); }

and here errors gives me when seek run it:

com.mysql.jdbc.exceptions.mysqlsyntaxerrorexception: have error in sql syntax; check manual corresponds mysql server version right syntax utilize near '' @ line 1 @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:936) @ com.mysql.jdbc.mysqlio.checkerrorpacket(mysqlio.java:2985) @ com.mysql.jdbc.mysqlio.sendcommand(mysqlio.java:1631) @ com.mysql.jdbc.mysqlio.sqlquerydirect(mysqlio.java:1723) @ com.mysql.jdbc.connection.execsql(connection.java:3283) @ com.mysql.jdbc.preparedstatement.executeinternal(preparedstatement.java:1332) @ com.mysql.jdbc.preparedstatement.executeupdate(preparedstatement.java:1604) @ com.mysql.jdbc.preparedstatement.executeupdate(preparedstatement.java:1519) @ com.mysql.jdbc.preparedstatement.executeupdate(preparedstatement.java:1504) @ com.test.jdbcexample.main(jdbcexample.java:47)

you have syntax error in line:

preparedstatement pst = con.preparestatement("insert `employee` values(?,?,?");

you missing closing parenthesis values clause.

java mysql sql jdbc insert

c++ - distinguish 2 keyboards keystrokes using eventfilter (embedded linux) -



c++ - distinguish 2 keyboards keystrokes using eventfilter (embedded linux) -

i know there has been few topics similar one, don't inquire same question , answers not need. seek explain briefly situation.

i have 2 keyboards, 1 standard usb keyboard (hid), other gpio keyboard. there keys commonly reported both keyboards need take different actions in qt application depending on keyboard key pressed.

at moment both keyboards work fine @ same time, can't find way identify keyboard comes pressed key.

is possible? i'm, using qt 4.8.5 , can recompile in case needed accomplish need.

any help, hint, tip highly appreciated.

thank help,

william

qt not have feature observe keyboard pressed. should utilize linux event interface distinguish between 2 inputs. when input available 1 of hardwares, can access reading character devices under /dev/input/ directory. instance have file /dev/input/by-id/usb-0b38_0010-event-kbd read see input specific keyboard.

you can read specific files 2 keyboards in 2 separate threads , each time read new info 1 of them, send signal main thread notify input of keyboards :

in first thread :

qfile file("/dev/input/by-id/fileforkeyboard1"); if(file.open( qiodevice::readonly | qiodevice::text ) ) { qtextstream stream( &file ); while(true) { stream.read(1); emit keyboard1_pressed(); } }

in sec thread :

qfile file("/dev/input/by-id/fileforkeyboard2"); if(file.open( qiodevice::readonly | qiodevice::text ) ) { qtextstream stream( &file ); while(true) { stream.read(1); emit keyboard2_pressed(); } }

note should have root access read these files.

c++ linux qt keyboard keystrokes

android - graphview unable to zoom -



android - graphview unable to zoom -

following simple sine wave graph display. want zoom in , out using pinch zoom gesture.

info = new graphviewdata[num]; double v=0; (int i=0; i<num; i++) { v = 2*math.pi*30*i; data[i] = new graphviewdata(i, math.sin(v/num)); } graphview = new linegraphview(this, "graphviewdemo"); // add together info graphview.addseries(new graphviewseries(data)); // set view port, here num = 256 graphview.setviewport(0, num-1); graphview.setscrollable(true); linearlayout layout = (linearlayout) findviewbyid(r.id.graph1); layout.addview(graphview);

is there property enabled utilize zoom feature, or should implement setviewport() manually , handle zoom feature?

graphview.setscalable(true);

add line zooming graph.

android android-graphview