Posts

javascript - how to make a function that returns sql result set with jQuery? -

i want make function return value of sql result set list (datalite).the problem is, can't read value of variable(datalite) outside db.transaction , return null value . new javascript , jquery hope can find answer here. here's part of function function functiona(){ var datalite=null; db.transaction(function (tx) { tx.executesql('select * tablea', [], function (tx, results) { var len = results.rows.length, i; msg = "<p>found rows: " + len + "</p>"; alert(msg); datalite=results.rows; }, null); }); alert(datalite+'>>>'); return datalite; } you can't return asynchronous code, data not yet available when function returns, come later. such situations (ajax requests, animations, etc.) have patterns. 1 callbacks: function functiona(callback) { db.transaction(function (tx) { tx.executesql('select * tablea', [], function (tx, res...

javascript - Submit form while key press in Angular JS -

i have login form follows. login controller called when login button clicked , working fine. need same function called on "enter" key press after entering username , password. <form class="form-horizontal"> <fieldset> <div class="form-group"> <input type="text" class="form-control input-lg input-round text-center" placeholder="username" ng-model="uservals"> </div> <div class="form-group"> <input type="password" class="form-control input-lg input-round text-center" placeholder="password" ng-model="passvals"> </div> <div class="form-group"> <a href="#/" class="btn btn-primary btn-lg btn-round btn-block text-center" ng-click="log_me()">log in</a> </div> </fieldset> ...

regex - How to substitue a pattern with a whole array using sed? -

i have array, looks this: snakes=(python boa cornsnake milksnake) i wondering if it's possible substitute pattern whole array using sed. thinking this: sed -i "s/snakes like/& $(echo ${snakes[@]})/g" snakes.txt and have output here separated , : snakes python, boa, cornsnake, milksnake any ideas or suggestions appreciated. you expanding array correctly. suppose want edit file called languages (snakes gross): $ cat languages languages like. and array this: $ langs=(python perl ruby lua) you have to set ifs=, (internal field separator) convert elements of array single string ${langs[*]} prepend space before each 1 of them replacing beginning of each string ( # in bash, ^ in regex) space the final command one: $ ifs=, ; sed -i "s|languages like|&${langs[*]/#/ }|" languages (i used | in sed command clarity, / fine too, since shell converting ${langs[*]/#/ } final string before passing sed) the languages...

google chrome app - How to use cca with standard webview? -

currently cca build android produce 2 apk's x86 , arm (reflecting 2 versions of crosswalk). i create third uses default webview, i.e., target api 19+ has chromium. how go this? should start? my first brutish instinct clone whole project , package cordova. voice in head wrong. to opt out of crosswalk webview simple, add "webview": "system" manifest.mobile.json . you can read more details in our using crosswalk in chrome apps mobile document. you want set "minsdkversion" cordova config.xml preference build, system webview not used pre-kitkat. actually, may want use crosswalk on kitkat, , system webview on android-l (21+), you. the combined flow use is: leave "webview": "system" off, , set "minsdkversion" 14 (ics). run cca build android --release , copy out 2 apks. finally, switch system webview , set min sdk 19/21, , copy out third apk. upload of play store , test! this isn't neede...

iphone - How to use Image assets in iOS -

Image
i use launch images xcasset; i've tried ways can't works. i've standard launchimage asset, , image file called default[@2x,...] . using [uiimage imagenamed:@"launchimage"]; return nil. i've tried @"default" , no results. if want use compiled images separately in application: by-default launchimage asset generate following files: launchimage-700-landscape@2x~ipad.png launchimage-700-landscape~ipad.png launchimage-700-portrait@2x~ipad.png launchimage-700-portrait~ipad.png to find them use below: uiimage* image = [uiimage imagenamed:@"launchimage-700-portrait"]; note: 3 steps required setup assets mentioned below. missing ? my images: updating images in launch image source: drag , drop images in launchimage asset:

android - Uncaught Error: Error calling method on NPObject. at -

deviceready not working because of error. e/web console﹕ uncaught error: error calling method on npobject. @ file:///android_asset/www/cordova.js:924 line : var messages = nativeapiprovider.get().exec(service, action, callbackid, argsjson); i think have try change device or reinstall application in device might help.

class - In the following code why does the last line of execution give an error? -

in following code why last line of execution give error ? shouldn't dot operator in x.bf() pass on instance 'x' function bf ( x.af() ) ? class a: = 6 def af (self): return "hello-people" class b: b = 7 def bf (self): return "bye-people" >>> x = a() >>> b = b() >>> x.bf = b.bf >>> x.bf() traceback (most recent call last): file "<stdin>", line 1, in <module> typeerror: bf() missing 1 required positional argument: 'self' x.bf = b.bf error, because b class, not instance of object. you can't assign x.bf directly class. need assign x.bf instance 'b.bf' or instantiate class properly ie. either change line to: # instantiated class b , invoke bf via lazy loading (loading @ last possible minute) x.bf = b().bf or # use existing instance of b , call bf x.bf = b.bf more information: a , b classes. don't until instantiate...