Posts

Showing posts from August, 2014

javascript - ExtJS - Differentiate items in MultiSelect -

i have 2 multiselects in itemselector , in formpanel . each multiselect composed of 2 stores : left side, , right side (with arrows move items between 2). when load panel, feed reference, in order highlight items moved 1 side other (e.g. set style red moved items) because today there no way differentiate them. i managed catch event afteradd on stores , apply style through dom access. works during trace, later on remaining extjs standard calls performed, overriding style applied... i feel i'm doing not way, i'm new extjs i'm bit lost here... ! edit : here sample of code, forgot tell worked on extjs 3.2 (hum...). pool_cnx_to_rule formpanel : pool_cnx_to_rule.aftermethod('add', function () { //var pools_available_ = ext.getcmp('pools_available').getvalue(); var pools_selected_ = ext.getcmp('pools_selected').getvalue(); var i, j; (i = 0; < pool_cnx_to_rule.data.length; ++i) { var pool_descr_ = pool_cnx_

Assert Javascript value in C# with Selenium -

i'm writing test webapp. @ 1 point in application webpage completed using javascript. testing i'm using visual studio 2012 nunit , selenium . want check if box id=j_idt13:jnumber has text value of sometext . ijavascriptexecutor js = driver ijavascriptexecutor; string valoare = (string)js.executescript("return $('#j_idt13\\:jnumber').val();"); assert.istrue(valoare.equals("sometext")); i keep getting error: "syntax error, unrecognized expression: unsupported pseudo:jnumber". what missing here? i know have works i'd caution avoid using javascript fetch value of element, in fact in general should avoided when doing tests except when there no other way want do. reason selenium supposed behave typical user would. typical users don't type javascript page or interact directly. goes using jquery tests should not assume jquery exists on page , functioning. selenium provides ability fetch values of fields i'd re

Titanium Android webView evalJS does not deal well with typeof -

i've got webview in titanium app returns empty string when ask check typeof variable. point of exercise figuring out if function exists on page reloads in different forms. var hasauth = self.registerview.evaljs("typeof authenticate;") this works fine in ios, , in fact in android works on many occasions well. yet on android, return nothingness, represented 'undefined.' ps: no, problem not including 'return' in javascript string. titanium , causes errors if too. the solution in case turns out be: var hasauth = self.registerview.evaljs("'' + typeof authenticate;") somehow evaljs can typeof work, not if line starts typeof.

java - How to handle collision after detecting it -

i've been trying past few days put simple collision simple game. i've looked in lots of places on internet haven't found helpful. i'm using bounding boxes , want player box stop when hits block of 4 sides (and not stuck or bounce against block). doesn't sound difficult i've found incredibly difficult. wanna know code need put in if statement's brackets, i've read , heard theory can take. please if can. if(bb_collide(player,block)){ //detection works fine, //just not sure afterwards } else{ player.setx((player.getx() + velx)); player.sety((player.gety() - vely)); player.set_coll(player.getx(),player.gety(),player.getwidth(),player.getheight()); block.set_coll(block.getx(),block.gety(),block.getwidth(),block.getheight()); } i figured out, having couple of bad days, sorry if had bad attitude or got wanted to. heres did if anyone's interested because works 1

eclipse gef - Add a newly created/custom component on the palette -

i wondering if possible add newly created diagram component on palette. i adding components on diagram programmatically (with wizard ask user variables add in/on component). , give user possibility make similar component dragging , dropping palette. (say created component "wheel" variables, nice able create 4 of them without having use wizard every time)

performance - Difference between Hierarchical and Non Hierarchical Clustering? -

i trying see if performance of both can compared based on objective functions work on? hierarchical : single linkage, complete linkage , average linkage algorithms non hierarchical : fuzzy c means , k means don't confuse algorithms , tasks . there more 1 algorithm k-means. there @ least 2 dozen. use k-d-trees acceleration, example. , heuristics, because finding optimal k-means solution shown np-hard in general, believe. similarly, there naive o(n^3) runtime , o(n^2) memory approach hierarchical clustering, , there algorithms such slink single-linkage hierarchical clustering , clink complete-linkage hierarchical clustering run in o(n^2) time , o(n) memory. last not least, if use dbscan , set minpts=2 , result same single-link hierarchical clustering when cut @ height of epsilon . yet, appropriate index, dbscan runs in o(n log n) (e.g. in elki - scipy implementation not clever, needs o(n^2) memory , runtime). so why can have such different runtimes

java - How to make the 'open with' dialog box? -

i made program search .txt files. if click file means "open with" dialog box should appear, , dialog box contain list of installed programs. i using code searching through files: public file[] finder( string dirname) { // create file object on directory. file dir = new file(dirname); // return list of files in directory. return dir.listfiles(new filenamefilter(); } public boolean accept(file dir, string filename) { return filename.endswith(".txt"); } what java code can use make "open with" dialog box appear? you should use filechooser this. take here : //create file chooser final jfilechooser fc = new jfilechooser(); ... //in response button click: int returnval = fc.showopendialog(acomponent); public void actionperformed(actionevent e) { //handle open button action. if (e.getsource() == openbutton) { int returnval = fc.showopendialog(filechooserdemo.this); i

asp.net - .net framework execution was aborted by escalation policy because of out of memory -

i using net framework 4.0 , sql server 2012 development. there error occurring randomly while performing database operation in web application in asp.net. have call sql queries code behind file. occurring large document size greater 300kb. how increase size. edit : it occurring while view image files , saving binary data in database below code got error int isupdateidproof = 1; sqlparameter paraminsertidproof = null; sqlcommand cmdinsertidproof = new sqlcommand("onboarding_insertuploadedidproof", con); cmdinsertidproof.commandtype = commandtype.storedprocedure; paraminsertidproof = new sqlparameter("@filecaption", sqldbtype.varchar, 100); paraminsertidproof.direction = parameterdirection.input; paraminsertidproof.value = txtidproofdescription.text; cmdinsertidproof.parameters.add(paraminsertidproof); paraminsertidproof = new sqlparameter("@filedata", sqldbtype.varbinary,

iphone - Subview with UIButton isn't clickable -

here's code i'm working with: uibutton *mainbutton = [[uibutton alloc] initwithframe:cgrectmake(0, 0, 100, 100)]; [mainbutton setimage:[uiimage imagenamed:@"circleshape.png"] forstate:uicontrolstatenormal]; mainbutton.center = cgpointmake(self.view.frame.size.width/2.0f, self.view.frame.size.height/2.0f); [self.view addsubview:mainbutton]; uiview *subview = [[uiview alloc] initwithframe:cgrectmake(0, 100, 200, 100)]; [subview setbackgroundcolor:[uicolor purplecolor]]; [mainbutton addsubview:subview]; uibutton *secondbutton = [[uibutton alloc] initwithframe:cgrectmake(0, 0, 100, 100)]; [secondbutton setimage:[uiimage imagenamed:@"circleshape.png"] forstate:uicontrolstatenormal]; secondbutton.center = cgpointmake(subview.frame.size.width/2.0f, subview.frame.size.height/2.0f); [subview addsubview:secondbutton]; why mainbutton clickable secondbutton isn't? k should add sub view on self.view. uiview *subview = [[uiview alloc] initwithfram

android - RotationVector Sensor ArrayIndexOutOfBounds exception -

i coding app information sensors. have problem on rotation vector one. saw on official android website have 4 values sensor : type_rotation_vector : sensorevent.values[0] rotation vector component along x axis (x * sin(θ/2)). sensorevent.values[1] rotation vector component along y axis (y * sin(θ/2)). sensorevent.values[2] rotation vector component along z axis (z * sin(θ/2)). sensorevent.values[3] scalar component of rotation vector ((cos(θ/2)).1 here's code : @override public void onsensorchanged(sensorevent event) { // todo auto-generated method stub //get sensors values float x, y, z, s; string s1 = "stringx", s2 = "stringy", s3 = "stringz", s4 = "strings"; if (event.sensor.gettype() == sensor.type_rotation_vector) { x = event.values[0]; y = event.values[1]; z = event.values[2]; s = event.values[3]; // <====

objective c - How to forbid copy or paste operation in NSTextField? -

as title mentions. how can forbid copy (command + c) , paste (command + v) operations in nstextfield or nssecuretextfield ? http://www.cocoabuilder.com/archive/cocoa/129465-disabling-right-mouse-click-and-ctrl-click.html#129471 this answer question.

php - Symfony 1.4 Passing variables from action to view -

i symfony 1.4 newbie , i'm joining project need create new dashboard. i've created following controller in analyse/actions/actions.class.php public function executetestdashboard(sfwebrequest $request){ $foo = "foobar"; $this->foo = "thisfoobar"; return $this->renderpartial('analyse/testdashboard', array('foo' => $foo); } and analyse/templates/_testdashboard.php view, partial included in home/templates/indexsuccess.php : <div class="testdashboard"> <h1>test</h1> <?php var_dump($foo);?> </div> it doesn't work, $foo neither "foobar" nor "thisfoobar", "null". how should proceed, in order make work? (or check if executetestdashboard controller processed ?) you should read partials , components in symfony 1.4. if you're including partial in template using include_partial() partial rendered , no controller c

database - How to assign values to store gender information? -

i'm creating application stores data users. wondering mapping of gender appropriate: male - false; female - true or female - false; male - true is there standard this? i have seen bit (sql server) type being used genders, mentioned. places i've worked used char(1) column that, because thought someday might have store genders other male , female (i.e.: androginous/assexual, transexual (both male or female), hermaphrodite, unknown etc.). , knows? in case, both solutions work. i'm inclined bit solution may have better performance if scalability issue, though should matter huge databases.

android - How to know if the keyboard layout changes between numbers and letters? -

i have edittext users normaly enter numbers. therefore i'm using inputtype.type_class_number numerical soft keyboard. occationally though, users may want enter letters, have button switches between inputtype.type_class_number , inputtype.type_class_text. works fine, found behaviour becomes strange on devices hardware keyboard. found this answer solves issue, can exclude keyboard switching functionality devices. but there devices, e.g. asus transformer prime tablet, never changes software keyboard layout when switching between inputtype.type_class_number , inputtype.type_class_text. how can know if software keyboard change layout or not? how can know if software keyboard change layout or not? you can't. inputtype hint, not demand. input method editors ("software keyboards") don't have buttons (see graffiti). there no means of interrogating system determine capability of input method editors, largely because authors of input method editors

c++ - how to change the hsv of texture in opengl -

this question has answer here: opengl es - change hue of colors in texture 1 answer im having 3 dimensional array of rgba texture , im displaying on viewport. how can change color hue, saturation , value input user gave . im new opengl need guidance change hsv according user selection . get glm , @ implementation in gtx/color_space.inl of these functions template<typename valtype > detail::tvec3< valtype > hsvcolor (detail::tvec3< valtype > const &rgbvalue) template<typename valtype > detail::tvec3< valtype > rgbcolor (detail::tvec3< valtype > const &hsvvalue) prototyped in gtx/color_space.hpp

Java os path operations, joins, and moving up levels -

i have 2 related questions regarding files, , file class in java. i gather best practice way build path - , have os agnostic - this: file file = new file("dir" + file.separator + "filename.ext"); my first question is, "is there java equivalent of python os.path.join function built java?" i.e. there function can this: string path = some_func("arbitrary", "number", "of", "subdirs", "filename.ext"); i suspect if such thing exists, may need pass array of strings function, rather arbitrary number of args, above ideal. but regardless of answer question above, second question is, "is there built in way move level when specifying path?" i.e. correct way, this: string rel_path = ".." + file.separator + "filename.ext"; or there this: string rel_path = file.level_up + file.separator + "filename.ext"; cheers all! i gather best practice way bu

Simple mysql query not working in php -

suddenly sql query not woking in add table. it works in other table though. there wrong in code? $sql="select index,name add limit 0,10"; $result=mysql_query($sql); while($row=mysql_fetch_assoc($result)) { echo $row['name']; } the index name filled random data. add reserved word in mysql. have quote it.

reverse engineering - how do you understand javascript code that is not written by you -

suppose have 200 pages of code. or amount. not written you. in javascript can done anywhere. how read , understand? decode or reverse engineer. tools in process? in general find reading else code beside mine impossible unless if less half page. what typically follow call-in logic outer layers of code inward , instead of trying grok thousands of lines of someones program, try figure out how pieces need work on function. you don't read code top-down read book (pages?), follow calls (initially can ignore class instantiation) outmost position inwards. javascript not nice language in regard still if compiler/interpreter can read it, can you. it's important write readable code, , professional should, on policy level, expect other people, on technical level, need able cut through bushes.

sql - To find a table related to others table -

i getting problem in finding tables related 1 table in same or different db. thanks smruti. relations between tables can defined in foreign keys. without these, 2 tables can not connected implicitly. things udfs in check constraints not count: opaque. foreign keys exist in same database too. there should no related tables in database anyway: if have, can never transactionally consistent , can never relied upon have same data. in sql server 2005+ can use this msdn article explain how works. there no single answer or query use.

java - Multiply long or BigInteger by double without loss of precision -

i want multiply high precision integer (long or biginteger) small double (think > 0 , < 1) , arithmetically rounded integer (long or biginteger) of exact arithmetic value of operation result. converting double integer not work, because fractional value gets lost. converting integer double, multiply , converting result integer not work either, because double not precise enough. of course argue, because double operand not precise enough in first place, might not matter result not precise same order of magnitude, in case, does. bonus question: using bigdecimal works, seems inefficient. converting long double , multiplying , converting seems run 500 times faster (albeit losing precision) converting bigdecimal. there more efficient possibility? possible gain performance when multiplying several different long each same double? you want use bigdecimal in order preserve precision. biginteger mybi = new biginteger("99999999999999999"); double d = 0.123;

php - unable to use variables defined in class -

hi trying import configuration variables config file had created config.php has class config { public $servername = '*******'; public $susername = '*********'; public $spassword = '*********'; public $dbname2 = '********'; } for importing variable in file tried include('./config.php') or die("error"); $cnfig = new config(); but when try use $cnfig->dbname2 not working please sole problem. thank you. edit it working in localsystem , when tied upload through web hosting not working. try below one include ('./config.php'); $cnfig = new config(); echo "<pre>";print_r($cnfig); edit: i getting below output should working too. config object ( [servername] => ******* [susername] => ********* [spassword] => ********* [dbname2] => ******** ) edit:2 you can this (include('./config.php')) or die("error"); $cnfig =

swing - Java keeps giving me my coordinates multiplied by 93 -

when set x , y values array of jbutton s, correct values multiplied 93. can solve problem dividing value 93 rather find out bug in first place. i have 2 classes in code, 1 actual program, , 1 button object along coordinates. here's code: import javax.swing.*; import java.awt.*; import java.awt.event.actionlistener; import java.awt.event.actionevent; import java.awt.gridlayout; import java.io.*; public class connectfour implements actionlistener { jframe frame = new jframe(); button [][] buttons = new button[6][7]; public connectfour() { frame.setsize(700,600); frame.setdefaultcloseoperation(jframe.exit_on_close); frame.setlayout(new gridlayout(6,7)); frame.setlocationrelativeto(null); frame.settitle("connect four"); for(int filler = 0; filler <= 5; filler++) { for(int filler2 = 0; filler2 <= 6; filler2++) { buttons[filler][f

javascript - setInterval() speeds up when using multiple from object method -

i have been having problems setintervals() . know these issues appear lot can't seem work out exact problem implementation is. every time instantiate new obstacle() clears set interval used rotate instance of obstacle, , next instantiation of obstacle seem rotate twice fast! i'm sure it's scope i'm relative beginner i'm not quite sure what's going on here. more info can provided. var obstaclecount = 1; function obstacle(){ this.angle = 0; this.id = obstaclecount; this.elprefix = "cookie-"; this.el = '.' + this.elprefix + this.id; $('#game-wrapper').append('<div class="' + this.elprefix + this.id + '"></div>'); obstaclecount += 1; } var intervals = new array(); obstacle.prototype.roll = function() { self = this; intervals[self.id] = setinterval(function(){ self.angle -= 3; $(self.el).rotate(self.angle); }, 5); $(self.el).animate({

raspberry pi - How to schedule an action in python? -

i'd know how preform action every hour in python. raspberry pi should send me information temp , on every hour. possible? i new python , linux, detailed explanation nice. write python code having readings sensors in text or csv files , send them or dropbox account and put cron job in linux run python script every hour type in command line sudo su then type crontab -e in opened file enter: / 0 * * * * /home/pi/yourscript.py where /home/pi/yourscript.py fullpath python script , execute "yourscript.py" every 60 min. to send code - have choose way- 1) can send inbox 2) dropbox account 3) sql data base in case have write script that.

mysql - Select Values based on Distinct Dates -

i puzzled while now. have table phone numbers , dates(timestamp). if number exists more once particular date, number should returned once. date number 2013-05-14 15:39:19 1234567890 2013-05-14 15:39:19 1234567890 2013-05-14 15:39:19 9876543210 2013-05-14 15:39:20 1234567890 output: date number 2013-05-14 15:39:19 1234567890 2013-05-14 15:39:19 9876543210 2013-05-14 15:39:20 1234567890 i know doesn't serve need tried select * table name group date , didn't desired result expected. how should go about? select * table name group date,number sql fiddle demo

javascript - Which jPlayer event designates the ability to start playing? -

i have basic jplayer set plays (150mb) audio file aws s3. setup looks this. jquery(function() { var $player, jplayerdefaults, progresscount; $player = $('<div>'); progresscount = 0; jplayerdefaults = { ready: function(e) { console.log("player ready"); $player.jplayer('setmedia', { mp3: 'http://s3-eu-west-1.amazonaws.com/some/file.mp3' }); return $player.jplayer('play', 1234); }, seeking: function(e) { return console.log("seeking"); }, seeked: function(e) { return console.log("seeked"); }, canplay: function(e) { console.log('canplay'); }, progress: function(e) { return console.log("progress", progresscount += 1); }, playing: function(e) { return console.log("playing"); }, error: function(e) { re

installer - Recursivly opening WiX bootstrapper -

i'm using wix 3.7's generatebootstrapper generate bootstrappers i've used in visual studio deployment project. my bundle.wxs chain single item, referencing msi file. <chain> <msipackage id="myprograminstaller" sourcefile="$(var.myprograminstaller.targetpath)" compressed="no"/> </chain> i modified bootstrapper project's .wixproj include bootstrapper generation of various components. ... <itemgroup> <projectreference include="..\myprograminstaller\myprograminstaller.wixproj"> <name>myprograminstaller</name> <project>{my-guid}</project> <private>true</private> <donotharvest>true</donotharvest> <refprojectoutputgroups>binaries;content;satellites</refprojectoutputgroups> <reftargetdir>installfolder</reftargetdir> </projectre

php - Magento method "removeTab" doesn't work -

i made observer triggers on event adminhtml_block_html_before , when try remove tab nothing happens. here's code: public function altermenu($observer) { $block = $observer->getblock(); if ($block instanceof mage_adminhtml_block_sales_order_view_tabs) $block->removetab('order_rma'); } after, if use print_r($block->gettabsids()); there following situation: array ( [0] => order_info [1] => order_invoices [2] => order_creditmemos [3] => order_shipments [4] => order_history [5] => order_transactions ) but tab still visible. i'm using magento ee 1.12. suggestions? thanks! resolved event core_block_abstract_to_html_before instead of adminhtml_block_html_before , event tab removed before rendered.

rabbitmq - Need help identify host name -

i'm new rabbitmq, installed rabbitmq-server on 1 ec2 instance, , want create consumer on ec2 instance. but i'm getting error: socket.gaierror: [errno -2] name or service not known that's node status: ubuntu@ip-10-147-xxx-xxx:~$ sudo rabbitmq-server restart error: node name "rabbit" running on "ip-10-147-xxx-xxx" diagnostics =========== nodes in question: ['rabbit@ip-10-147-xxx-xxx'] hosts, running nodes , ports: - ip-10-147-xxx-xxx: [{rabbit,46074},{rabbitmqprelaunch4603,51638}] current node details: - node name: 'rabbitmqprelaunch4603@ip-10-147-xxx-xxx' - home dir: /var/lib/rabbitmq - cookie hash: gsnt2qhd7wwdeoaofby= and that's consumer code: import pika cred = pika.plaincredentials('guest', 'guest') conn_params = pika.connectionparameters('10-147-xxx-xxx', credentials=cred) conn_broker = pika.blockingconnection(conn_params) conn_broker = pika.blockingconnection(conn_params) channel = co

javascript - Computed function issue with KnockOut -

working knockout - i'm trying build basics of master detail/items app before adding mvc .net code. all want have simple item, price, tax - , computed column show amount including tax each item: the client side knockout viewmodel is: var giftmodel = function(gifts) { var self = this; self.gifts = ko.observablearray(gifts); self.formattedprice = ko.computed(function() { var pricet = self.gifts().price; return pricet ? "$" + pricet.tofixed(2) * (1 + self.gifts().tax : "none"; }); self.addgift = function() { self.gifts.push({ name: "", price: "", tax:0 }); }; self.removegift = function(gift) { self.gifts.remove(gift); }; self.save = function(form) { alert("could transmit server: " + ko.utils.stringifyjson(self.gifts)); // transmit server regular form post, write this: ko.utils.postjson($("form")[0], self.gifts); }; }; var viewmodel = new giftmodel([ { na

rascal - In a visit expression, can the default be labeled like the cases? -

example: visit(sometree) { case a:somenodea(_,_): handlenodea(a); default: handle(???); } so want handle other cases using default , how can this? visit not support default because needs specific bind while visiting. instead can write pattern matches everything. example: visit(sometree) { case node x : handlealltreelikethings(x); case str y(value x, value y) : handleallbinarytrees(y, x, y); case value x : handleallvalueswhatsoever(x); }

ico - Wand Python multi-size icon -

Image
i'm trying use wand create multi-size ico, don't find talking that, normal conversion, ico... i've found "sequences": https://wand.readthedocs.org/en/latest/roadmap.html and sequences need, see samples trying read multiple images, not how create, missing something? or not possible? or possible using pil/pillow? you can append() single image image.sequence list. example: from wand.color import color wand.image import image image(width=32, height=32, background=color('red')) ico: image(width=16, height=16, background=color('green')) s16: ico.sequence.append(s16) ico.save(filename='multisized.ico') result ( multisized.ico ):

java - cannot load the oracle driver -

hey guys 1 more question following informations tell me in comments if more info needed info: destroying singletons in org.springframework.beans.factory.support.defaultlistablebeanfactory@7471dc3d: defining beans [datasource,studentjdbctemplate]; root of factory hierarchy exception in thread "main" org.springframework.beans.factory.beancreationexception: error creating bean name 'studentjdbctemplate' defined in class path resource [pack1/config.xml]: error setting property values; nested exception org.springframework.beans.propertybatchupdateexception; nested propertyaccessexceptions (1) are: propertyaccessexception 1: org.springframework.beans.methodinvocationexception: property 'datasource' threw exception; nested exception java.lang.illegalargumentexception: property 'datasource' required <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi=&quo

asp.net - How to fetch only number from the string using between value? -

Image
i have string in want show 1568.41 using regex how can that string `*pqs« price quote record - summary name number retained fare name pq type tkt des created tkt ttl 1.1 1 14may usd 1568.41 2.1 1 14may usd 1568.41 3.1 2 cnn ch25 14may usd 1363.41 ` i used 1.1\s{2,5}\d\s(.+) regex fetch complete line. i used (?<=usd)\s{2,5}\d{1,4}.\d{2}(?=\s(.+)) didn't work there string in same want fetch number wpncb« 19aug departure date-----last day purchase 21may/2359 base fare equiv amt taxes total 1- dkk790 usd139.00 179.40xt usd318.40adt xt 109.80yq 19.20yr 29.00zo 5.40ua 2.00ud 14.00yk

jQuery Date Validation (YYYY-MM-DD) -

i need validate date using this script in format of yyyy-mm-dd, can't seem working perfectly. regular expression i'm using, allows users enter 10 numbers without dashes, instead of 8 dashes in correct places. there way modify script fix this? jquery.validator.addmethod("date", function(date, element) { return this.optional(element) || date.match(/^[-0-9]{10}$/); }, "please specify valid date"); you have wrong regex. you can use 1 instead : ^\d{4}-((0\d)|(1[012]))-(([012]\d)|3[01])$ so : return this.optional(element) || date.match(/^\d{4}-((0\d)|(1[012]))-(([012]\d)|3[01])$/);

cuda - OpenCL application with 3 different kernels -

i started opencl , want port app have in cuda. problem i'm facing kernel stuff. in cuda have kernel functions in same file, on contrary, opencl asks read file kernel source code , other stuff. my question is: can have 1 single file kernel functions , build program in opencl or have have 1 file each of kernel functions? it nice if give little example. the difference between opencl , cuda (in specific regard) cuda allows mix device host code in same source file, while opencl requires load program source external string , compile @ runtime. but nevertheless absolutely no problem put many kernel functions single opencl program, or single opencl program source string. kernels (say c api kernel objects) extracted program object using respective function names. pseudocode simplifying opencl's ugly c interface: single opencl file: __kernel void a(...) {} __kernel void b(...) {} c file: source = read_cl_file(); program = clcreateprogramwithsource(source); c

Data not parsing fully via webview/other html converting method in android app -

i have created app works on transaction.in app sending request api used transaction in various values sent. response in form of html. parsing response response not converting fully. help me regarding code , if other method present sent variables url via post only use webview view result , pass of values via url. can achieve as webview.posturl(url, encodingutils.getbytes(postdata, "base64")); postdata string parameters.

mysql - sql - insert into multiple tables in one query -

assuming have 2 tables, names , phones , want insert data input tables, in 1 query- how can done? please, if can done, explain syntax. mysql doesn't support multi-table insertion in single insert statement . oracle 1 i'm aware of does, oddly... insert names values(...) insert phones values(...)

jsf 2 - EJB3 injection into JSF managed beans failed -

i developping maven enterprise application using netbeans, glassfish3.1, ejb3 , jsf2. want inject daofacade ejb jsf managed bean does'nt work. here error message: caused by: javax.naming.namingexception: exception resolving ejb 'remote ejb-ref name=com.procc.beans.alertcontroller/ejbfacade,remote 3.x interface =com.procc.dao.alertfacade,ejb-link=null,lookup=,mappedname=,jndi-name=com.procc.dao.alertfacade,reftype=session' . actual (possibly internal) remote jndi name used lookup 'com.procc.dao.alertfacade#com.procc.dao.alertfacade' [root exception javax.naming.namingexception: lookup failed 'com.procc.dao.alertfacade#com.procc.dao.alertfacade' in serialcontext[myenv={java.naming.factory.initial=com.sun.enterprise.naming.impl.serialinitcontextfactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.jndistatefactoryimpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [root exception javax.naming.namenotfoundexception: com.procc

c++ - Design for generic utility code with no 'member' data -

i creating generic utility functions no persistent class type data used in project. so thinking have following options: create global functions inside namespace. create global functions (in global namespace). create class static functions. i realise b) not particularly practice. when choose a) or when c)? or indeed other options haven't thought of? i choose options below: c - if functions can relate each other closely a - if functions can relate each other moderately b - if functions not related each other (keep @ least in same folder) below examples can template well. example c : struct sort { // sorting data structure operations static void quick (..); static void bubble (..); static void merge (..); }; example a : namespace util { // data structures operations static void sort (..); static void binary_tree (..); static void hash_map (..); } example b : // operations void swap (..); void erase (..); void destroy (..);

How to Publish/Update website through FinalBuilder taking code from subversion? -

what doing 'checkout' (if new) or 'update' website code subversion. compile code, proceeds if compiled , ftp compiled location website hosted replacing existing code. done in final builder 7. my question how put changed files (last commit on subversion) on ftp location after successful build , compiled in fb7, , files should published? sounds if need keep cache of files previous build, , check , compare each of them using "file compare" action. but motivation behind it? replace whole build output. attempting segmental updates inevitably lead not being copied or updated.

java - Traverse some methods to main "call handling" activity -

i'm curious if there possibility traverse methods application main call handling app. example if phone called, show different activity "response" button , if user presses it, send message main call handling activity on device. i know how show activity before main call handling activity via broadcastreceiver , type of actions way less trivial that. so here's list of questions: is possible send messages call handling app on device, after catch phone state ..ringing? if yes (look up), app feature recognized play store non-viral (of course user notified app has such feature)? and if both answer yes previous two, should start research regarding topic (are there tutorials or blogs describe same/like mechanisms)? any great... i'm curious if there possibility traverse methods application main call handling app. no, because "main call handling app" not app, , not in process. is possible send messages call handling app on device

Validate an image in PHP -

i'm using gd create jpegs files user uploads. what best way validate image user has uploaded valid? by valid mean file not corrupt image gd won't like, extension testing client side can upload jpegs/gifs/pngs. thanks you use getimagesize . return false if image not loaded. has support image types.

xml parsing - JAXB XmlJavaTypeAdapter unmarshal method not being called -

i trying marshal/unmarshal color xml. jaxb project had example code doing exact thing via xmljavatypeadapter https://jaxb.java.net/guide/xml_layout_and_in_memory_data_layout.html . the marshaling works fine , output expect: <?xml version="1.0" encoding="utf-8" standalone="yes"?> <beanwithcolor> <foreground>#ff0000ff</foreground> <name>clevername</name> </beanwithcolor> however, when trying go xml object unmarshal method never called. can provide insight why? after unmarshalled foreground color null , have confirmed debugger unmarshal never being called: beanwithcolor{foreground=null, name='clevername'} scce: @xmlrootelement public class beanwithcolor { private string name; private color foreground; public beanwithcolor() { } public beanwithcolor(color foreground, string name) { this.foreground = foreground; this.name = name; } @xmljavatypeadapter(coloradapter.class) publi

"response code: 502" using socket.io and nginx 1.4.x (stable) with proxy_pass -

i trying make running app (using socket.io) under nginx, , websocket connection 'ws://...' failed: unexpected response code: 502 error on server side. have read nginx suport websockets since v.1.3 have upgrade nginx v1.4.1 (stable) . here conf: server { listen 80; server_name website.com; location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header upgrade $http_upgrade; proxy_set_header connection "upgrade"; access_log /var/log/nginx/website/access.log; error_log /var/log/nginx/website/error.log; } } update: i have can reach app (so listen port 3000) , socket.io working unless error, in cases, emit call desn't send arguments undefined . what missing here avoid error? i have found avoid error: io.set('transports', ['xhr-polling']); so socket.io ajax calls, job way more slowly, if has real key i

python - Can I configure IDLE to automatically convert tabs to spaces? -

i know spaces preferred on tabs in python, there way convert tabs spaces in idle or automatically that? from idle documentation : tab inserts 1-4 spaces (in python shell window 1 tab). you can use edit > untabify region convert tabs spaces (for instance if copy/pasted code edit window uses tabs). of course, best solution go download real ide. there plenty of free editors better @ being ide idle is. mean they're (imo) more user-friendly, more customizable, , better @ supporting things you'd want in full-featured ide.

session - Worklight: Challenge-handler not working as expected -

i used sample challenge handler comes form based authentication module. modified per requirements. in app, have 1 landing (home) page , have link login page. want function when user click on login button. i face various problems here: on first click on login button, authenticate wl server unable proceed further execute login function logic. after first click, have 2nd time click on login button. @ 2nd login click execute login function perfectly. when log out,either not removing session server or what? execute log-out function code (given below). again after specified session time out, prompts 2nd/3rd time , shows "time out message". although user not loged in again. log-out. purpose: want app login when user click on log-in button, 1 click. , when log-out or time out, should not keep session active or shows "session timeout" message after specified time again & again. my challenge handler: var aahadapprealmchallengehandler = wl.client.createch

c# - Ajax post to ASP.net MVC controller - object properties are null -

i've got ajax post being constructed this: var mydata = [ { id: "a", name: "name 1" }, { id: "b", name: "name 2" } ]; $.ajax({ type: 'post', url: '/myurl/myaction', data: { items: mydata }, datatype: 'json', error: function (err) { alert("error - " + err); } }); and mvc controller: [httppost] public jsonresult myaction(myclass[] items) { } myclass simple representation of data: public class myclass { public string name {get; set; } public string id {get; set; } } when javascript makes post request, controller action indeed receive 2 items, properties (id, name) in these items null. checking request in fiddler, body looks this: name | value items[0][name] | name 1 items[0][id] | items[1][name] | name 2 items[1][id] | b have missed something? h

php - RegEx for Twitter username not working -

the following regular expression function validating twitter username not working because twitter name can minimum of 1 character , maximum of 20. however, when tested this, allows usernames greater 20 characters. did go wrong? public function val_username($subject) { return (bool)preg_match('/[a-za-z0-9_]{1,20}/', $subject); } you forgot $ , ^ /^[a-za-z0-9_]{1,20}$/ should work public function val_username($subject) { return (bool)preg_match('/^[a-za-z0-9_]{1,20}$/', $subject); }

c# - ServiceStack multiple services web API -

i'm newbie servicestack , learn how works, i'll develop web api northwind database (using repository pattern). i've checked sample project servicestack.northwind , there 2 services (customers , orders). i'd develop complete api (customers, orders, products, etc..). matt cowan has done . basically, services same operation: receive request. execute (repository.get, repository.add, repository.update, repository.delete). send response. for this, thought making base class work. first started like: public class baseservice<trepository, tentity, tdto> : service { ... } the problem of class don't know types request , response each operation. thought i'd pass them type arguments: public class baseservice<trepository, tentity, tdto, trequest, tsingleresponse, tcollectionresponse> : service { ... } i don't this. i'm sure can done without passing n type arguments class. how approach development of base class?. thank

mysql - Last working day in DB -

i have data days of week , want find data recent working day i.e dayofweek != 1 , dayofweek != 7 my clumsy case along lines of where case when dayofweek(curdate()) = 1 day(time) = date_sub(day(time), interval 2 day) when dayofweek(curdate()) = 7 day(time) = date_sub(day(time), interval 1 day) when dayofweek(curdate()) != 7 , dayofweek(curdate()) != 1 day(time) = day(curdate()) else 1 = 1 end this code, day(time) = date_sub(day(time), interval 2 day) never matches, because day(time) never ever equals day(time) - 1 day . same saying x=x-1 in algebra... can not true. suspect mean this: where case when dayofweek(curdate()) = 1 date(time) = date(date_sub(curdate(), interval 2 day)) ... ... ... part left exercise asker. the date() function removes time part, can compare day. the date_sub() function needs subtract curdate() recent workday. in code subtracting datetime stored in table.

orbeon - Smart European Date input control -

using orbeon-4.1.0.201304182144-pe, i'm having problem smart date completion. i've included configuration property: <property as="xs:string" name="oxf.xforms.format.input.date" value="[d]/[m]/[y]"/> to take european-style dates input. the condition smart date completion: when oxf.xforms.format.input.date property starts [d: e.g. 20/10 from input control-forms doesn't seem trigger. get: input output 20 20/5/2013 (correct) 20/5 not valid (incorrect, should 20/5/2013) 20/5/13 20/5/2013 (correct) 5/20 20/5/2013 (incorrect, should not valid) is bug? this bug , , fixed. fix in next release of orbeon forms, @ time of writing 4.2.

java - Generic List and reflection -

i'd call via reflection following method, have problem specify correct signature: public void executerule(list<node> params, somethingstrangefound callmeback) throws ioexception { ... } i tried this: class partypes[] = new class[2]; partypes[0] = class.forname("java.util.list"); partypes[1] = class.forname("vp.somethingstrangefound"); method meth = cls.getmethod("executerule", partypes); it doesn't work because use "java.util.list" when must "list<node>", have no idea how specify it. if use "java.util.list", have following error calling cls.getmethod("executerule", partypes): nosuchmethodexception: vp.rulewebxmlcontextparamfacesportletrenderstyles.executerule(java.util.list, vp.somethingstrangefound) any help? p.s. @ debug time, see "list<node>" resolved with: (ljava/util/list<lorg/w3c/dom/node;>;lit/vp/somet

Custom setter method won't accept blank values in Ruby on Rails? -

i have class: class project < activerecord::base attr_accessible :hourly_rate validates :hourly_rate, :numericality => { :greater_than => 0 }, :allow_blank => true, :allow_nil => true def hourly_rate read_attribute(:hourly_rate_in_cents) / 100 end def hourly_rate=(number) write_attribute(:hourly_rate_in_cents, number.to_d * 100) end end the problem setter method doesn't behave in way want it. in form, when leave hourly_rate input field blank , hit update , 0 appears in input field again if magic , validation error: hourly rate must greater 0 can tell me i'm missing here? want field optional. thanks help! i imagine problem if leave field blank, params[:project][:hourly_rate] "" . if @project.hourly_rate = "" @project.hourly_rate 0 , not nil. this because "".to_d 0 . therefore write_attribute(:hourly_rate_in_cents, number.to_d