Posts

Showing posts from February, 2012

asynchronous - How to await a ParallelQuery with LINQ? -

i have async method, should database entries. filters name, candiate parallel execution. however, can not find simple way support both parallel execution , asynchronous tasks. here's have: private async task<list<item>> getmatchingitems(string name) { using (var entities = new entities()) { var items = item in entities.item.asparallel() item.name.contains(name) select item; return await items.tolistasync(); //complains "parallelquery<item> not contain definition tolistasync..." } } when remove asparallel() compile. not supposed use both features @ same time? or understand wrong? ihmo, both make sense: asparallel() indicate database query may split several sub-queries running @ same time, because individual matching of item not dependent on other item. update: bad idea in example, see comments , answer! tolistasync() support asynchronous execution of method, allow other match meth...

collection_select issue ruby on rails -

i'm new ruby on rails , i've issue. in app, user can publish idea , ideas belongs activities. user can choose select activity want. here's code form, used collection_select <div class="field"> <%= collection_select(:idee, :id, activite.all, :id, :nom, prompt: true) %></div> the select input work, i've activities in select input when select activity , publish idea, idea don't take value , stay empty. when edit idea, idea don't take value of activity. how can resolve ? given have idea , activity model , building form idea, think should write collection_select as: <%= collection_select(:idea, :activity_id, activity.all, :id, :nom, prompt: true) %> i suggest use form_for syntax if not doing it. check apidock reference: http://apidock.com/rails/actionview/helpers/formoptionshelper/collection_select http://apidock.com/rails/actionview/helpers/formhelper/form_for

jquery - CORS AJAX domain rest request -

i have url returns xml data , uses url username , password. $.ajax({ url: 'http://myserver.com:port/bc/rest/productslist/', data: { 'username': 'username', 'password': 'password' }, datatype: "jsonp", // cross domain contenttype: "application/xml; charset=utf-8", type: 'get', crossdomain: true, beforesend : function(xhr) { xhr.setrequestheader("authorization", "basic" + window.btoa("username" + ":"+ "password")); }, success: function(sucessresponse) { alert('put completed' + sucessresponse); } , error: function(failresponse){ alert("error: went wrong" + json.stringify(failresponse)); } }); problem: when testing code showing error: uncaught syntaxerror: unexpected token <' error. any suggestions? thanks

xcode - Xamarin OpenEars Native Binding Not working on Device but works on Simulator -

Image
i have been working on using openears v2.03 ios framework project in xamarin ios binding project. let me explain did far,.i'm new xcode, xamarin , binding things. gonna big questions, hold breath… 1) build openears framework project in xcode simulator. copied “openears” file framework/openears.framework/versions/current/ , renamed “ libopenears-i386.a ” likewise build same library iphone 4s device connecting device mac , chosen target iphone. copied generated openears , renamed “ libopenears-armv7.a ” 2) using lipo command bundled 2 file (libopenears-i386.a, libopenears-armv7.a) single file “libopenears.a” using below command. lipo -create -output libopenears.a libopenears-i386.a libopenears-armv7.a 3) created binding project in xamarin studio , added libopenears.a, generates libopenears.linkwith.cs automatically. below following code, using system; using objcruntime; [assembly: linkwith ("libopenears.a", linktarget.armv7 | linktarget.simulator, smart...

javascript - Using HTML5 with Angularjs and Node/Express and the MEAN.js boilerplate -

i'm using mean.js ( http://meanjs.org/generator.html ) boilerplate starting point app, love inbuilt authentication/authorization. however, i'm having problem using html5. in angular app i've set html5(true) , know need set catchall route other requests redirected. i have following routes on express root , catchall: ///this app/controllers/core.server.controller: exports.index = function(req, res) { res.render('index', { user: req.user || null, request: req }); }; exports.catchall = function(req, res){ res.redirect('/'); }; and routing itself 'use strict'; module.exports = function(app) { // root routing var core = require('../../app/controllers/core.server.controller'); app.route('/').get(core.index); app.route('*').get(core.catchall); }; now pages redirecting no problem when enter routes garbage, when enter route exists in express (with no associated view i...

python - Stopping running code -

i'd stop code while running in spyder, ctrl c / ctrl z nor cmd c / cmd z not work me, blue stop button (normally used debug). i work under yosemite 10.10.3 , using spyder 2.3.4 , python 2.7 has encountered same issue? the consoles both python , ipython, when executing code have stop button in top right corner of panes. the debug button has no business rightly said debugging, unless debugging should not expect stop non debugging session.

osx - Parse OS X issue -

i'm creating os x app using parse. correctly set appid in appdelegate , when running it, console shows: failed set (contentviewcontroller) user defined inspected property on (nswindow): have call setapplicationid:clientkey: on parse configure parse. and content of view controller can not loaded. if comment code in -viewdidload: of view controller, works well... -viewdidload: called before -applicationdidfinishlaunching:options:" ? func applicationdidfinishlaunching(anotification: nsnotification) { parse.enablelocaldatastore() parse.setapplicationid("lackhyskt33a7hoepkgk3x1k8af1eyhik1yhy7ch", clientkey:"pr1pe5roc9amopquzsfa9fltizik6qlkdnxxh5fx") println("fait") //pfuser.enableautomaticuser() let defaultacl: pfacl = pfacl() defaultacl.setpublicreadaccess(true) pfacl.setdefaultacl(defaultacl, withaccessforcurrentuser: true) } any reason such strange behavior??

robolectric - Is it necessary to use gradle with roboelectric for android unit testing? -

i , team have built android library project. built on eclipse using ant build it. presently aren't using gradle. have roboelectric dependencies jar file instead. when use this, while running unit tests, following error comes up warning: multiple versions of ant detected in path junit [junit] jar:file:/users/prateekarora/desktop/eclipse/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant.jar!/org/apache/tools/ant/project.class [junit] , jar:file:/users/prateekarora/trunk/client/android/mccmobileclient/test2/libs/robolectric-2.3-with-dependencies.jar!/org/apache/tools/ant/project.class when remove apache ant eclipse's plugin folder, stops working. can explain why happening? also, necessary use roboelectric gradle? if no, can find roboelectric's jar files with/without dependencies? it not necessary use gradle robolectric. running specified java class (from junit) proper classpath (including source, test code , dependencies). fixing case not easy ...

php - Filter a version number out of a string -

i want filter number out of string php preg_match (they versions of software): 1.6.2 1.6.2#2 1.7 (1.6.2#2 2. beta of 1.6.2) so when there string like: lorem ipsum dolor sit amet, consetetur sadipscing elitr, 1.6.2# sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. now want string contains "1.6.2#2" i tried (\d?[.|#]?)* not work use regular expression /(\d+\.\d+(\.\d+)?(#\d+)?)/

node.js - KoaJS middleware and database access -

if had show index users model: app.use(route.get('/user', list)); function *list() { var res = yield users.find({}); this.body = res; }; is possible put database access part own middleware , call next? how pass resulting list of users down next middleware? , somehow pass next through route? so first middleware db access needed, , second middleware presentation? essentially attach information request context or this keyword within middleware. i created screencast on writing middleware might helpful: http://knowthen.com/episode-4-writing-middleware-in-koajs/ here example of how pass information downstream middleware. let koa = require('koa'), users = require('./users'), app = koa(); function *firstmiddleware (next) { this.session = { user: yield users.find({}); } yield next; } function *secondmiddleware (next) { // this.session.user available here yield next; } app.use(firstmiddleware); app.use(secon...

caching - Varnish Cache - Cache a 403 response -

we're using varnish in front of aws s3 bucket , things have been running we've had 98.4% hit rate has saved large s3 bills! our applications need able make requests files may or may not exist yet. when happens varnish make request s3 , receive 403 (permission denied) response. catch response in vcl_error function allows display custom error message. since we're expecting 400-500 requests per second 40% being files don't exist yet run cost issues s3. my question is, possible have varnish remember file returned 403 , return cached response? varnish wait 5 minutes before requesting file backend. we're running varnish 3. i've read documentation appears sugest can use "set obj.ttl = 5m;" in vcl_error function doesn't seem work. thanks! alan yes, can cache it. check status code of response s3 , set ttl. varnish 3: sub vcl_fetch { if (beresp.status == 403 || beresp.status == 404 || beresp.status >= 500) { set be...

CSS to change the size of a TextField in javafx -

i know can textfield tempfield = new textfield(); tempfield.setminsize(500,500); within javafx have 45 text fields change i'd change them @ once setting css on scene. can me out? figured out .text-field{ -fx-min-width: 50; -fx-min-height: 50; }

Marklogic v1/transactions create by REST API : error -

i getting below error while calling below rest service in soapui tool : http://localhost:7060/v1/transactions error : http/1.1 401 unauthorized server: marklogic www-authenticate: basic realm=public content-type: application/json; charset=utf-8 content-length: 104 connection: keep-alive keep-alive: timeout=5 {"errorresponse": {"statuscode":401, "status":"unauthorized", "message":"401 unauthorized" } } after going through below link think related content-type, tried text/plain still not working, around ? marklogic v1/transactions create rest api try changing authentication setting in marklogic rest api server in admin console "digestbasic" , use http basic auth ("basic {token}") in rest client ensure login credentials in authorization header correct.

android - White background when rotating a webview -

i trying "play" webview. slide , rotate it, , works fine. problem when rotate it, ugly white rectangle in background emcompassing webview. tried change background color it's still there, , it's still white , ugly. idea how can make go away? i guess it's background color of window. can change in theme file

multithreading - C++ code - Coverity (or some other static code analyzer) + thread safety -

i wondering today following: there tool or extension (for coverity or other code analyzer), can following?: first, set set of rules, codes generating new threads, analyzer knows, code run other thread. the tool must follow, code parts in threads, in same, or in different ones. i set "rules", kind of codes ensuring me thread safety: example mylock class locking between threads. and reason previous 3: tool should show me warnings, codes called different threads , doesn't have thread-safety usage in it. thanks try intel inspector (also known thread checker). dynamic analysis, not static. far remember, allowed annotation/instrumentation custom locks, threading libs in general.

javascript - How to call SOAP service from phonegap application? -

how call soap service phonegap application with/without using additional library ? should work on os's ( atleast android, ios) examples can more appreciated. my input service <parm> <processid>105</processid> <attrname>attrvalue</attrname> </parm> you should able away building xml manually , posting soap end point. need generate expected soap body, in soap message , post end point. you'll need know version of soap expected, message request looks , message response looks like. you can handle xml side want. there's no right answer (aside not parsing raw xml string methods), whatever you're comfortable using.

oracle - SQL: MAX(id) in where clause subquery with group by -

Image
i have query , subquery in query, should give string of dates of different rows in group (group by). this works: want string in report other rows same max(id) because can't use max(inner.id) min(outer.id) in clause of inner query don't know how that, suggestion? my code (simple version): select (select listagg(to_timestamp('1970/01/01 00:00:00 ', 'yyyy/mm/dd hh24:mi:ss') + timestamp/86400, ', ') within group (order id) timestamps tbl inner max(inner.id) max(outer.id) , mrdin.timestamp between time , time group customer having count (2) > 1) alias tbl outer timestamp between time , time group customer; i want strings (timestamp) of first picture in dates column of second picture using max(id) of both compare. can't because of can't user max() function in clausule of inner select. i don't understand trying do, work you? select (select listagg(to_timestamp('1970/01/01 00:00:00 ', 'yyy...

c# - Whats the best/safest way to run an async method on pageload? -

i have async method loads data disk (using json). however, when run method in startuppage() or onnavigatedto() can't use await operator these aren't async methods. code still run, warnings isn't 'awaited'. is there way of running async method on startup/navigatedto? you need use async on onnavigatedto() avoid warning .. protected override async void onnavigatedto(navigationeventargs e) { try { if (!app.viewmodel.isdataloaded) { await app.viewmodel.loaddata(); } } catch (exception ex) { ... } }

rest - How to rename Request/Response object properties in ASP.Net MVC Web API? -

could me please minimize response of web api route. public class product { public string uniqueid {get;set;} public string title {get;set;} ... } public class productscontroller : apicontroller { public ienumerable<product> getallproducts() { return repository.getall(); } // .... } the response contains full names of entity properties: [{ uniqueid: 123, title: 'book 1' },...] i minimize traffic using short aliases dto properties , see this: [{ u: 123, t: 'book 1' },...] i'm wondering if special attributes used rename properties in request/response. btw i'm talking requests because have same issue post requests. try applying following attribute on dto's properties: [jsonproperty(propertyname = "u")] public string uniqueid {get; set;} in way, json.net know name use when serializing or deserializing dtos.

bash - How to exclude folders and directory path from find command -

this question has answer here: how file name linux `find`? 6 answers i've got following command find /tmp/sjohal/archivetest > list however need output show filenames in folder without directory path. what best way this? my current output looks follows: /tmp/sjohal/archivetest /tmp/sjohal/archivetest/test2 /tmp/sjohal/archivetest/test1 /tmp/sjohal/archivetest/test3 /tmp/sjohal/archivetest/list.txt i require output show files: test2 test1 test3 try using ls command: ls /tmp/sjohal/archivetest > list.txt

javascript - jQuery not working offline still after downloading the jQuery library -

i have downloaded jquery library , put html,css , javascript files in same folder.but still not working.following code $(document).ready(function() { $('button').click(function() { $('div').fadeout('slow'); }); }); div { height: 100px; width: 100px; display: inline-block; background-color: green; border-radius: 5px; } <html> <head> <link rel="stylesheet" type="text/css" href="x.css" /> <script type="text/javascript" src="jquery-1.11.3.min.js"></script> <body> <div> <button>good</button> </div> </body> </html> you need add own js file: <html> <head> <link rel="stylesheet" type="text/css" href="x.css"/> <script type="text/javascript" src="jquery-1.11.3.min.js"></script>...

Can't select the value form auto complete in selenium webdriver -

webelement t= driver.findelement(by.xpath("/html/body/div[1]/div[4]/div[1] /div[1]/div/div/div/fr m/div/div[1]/input")); t.sendkeys("boston"); t.sendkeys(keys.tab); t.sendkeys(keys.arrowdown); thread.sleep(1000); arrow down not working. tab , rightarrow , other keys working

c# - ILArrays as input arguments to BeginInvoke delegate -

in application, have background thread performs calculations , pushes resultant ilnumerics arrays view. having issues ilnumerics arrays getting disposed off when trigger view update function control.begininvoke. are there specific function rules follow when passsing ilarrays input arguments begininvoke delegate? here sample code. void imainview.updatespectrumdata(ilinarray<float> wfmdata) { if (invokerequired) { begininvoke(new methodinvoker(() => addwfmtoview(wfmdata)), new object[] { wfmdata }); } else { addwfmtoview(wfmdata); } } } void addwfmtoview(ilinarray<float> wfmdata) { using(ilscope.enter(wfmdata)) { // update panel } } the problem compiler create anonymous class behind scenes. needed capture variables ...

java - Ctrl mask passing from mouse event to action performed -

in code have menu item action attached action map ( menuitem.setactionname("somestring") ). in action map, values, have objects of classes extends abstractaction , implemented actionperformed method. problem is, how pass modifiers mouse event (mouse released when clicked on menuitem ) actionperformed ? have check if action or without ctrl called in actionperformed method. information modifiers in mouseevent , call stack shows doclick on menu item called, invokes actionperformed (through setpressed ). in moment, information modifiers mouseevent aren't passed needed information lost. thanks! try overwriting processmouseevent on class extending jmenuitem . can modifier mouseevent @ processmouseevent method.

raygun - RaygunMessage does not list request data -

it critical not log post data (i.e. post body of http post requests) in raygun. however, other request data fine. we calling overload of raygunclient.send() accepts exception, this: client.send(myexeption, null, mycustomdata); this gathering data request , logging it. great, except logging post data, sensitive. i made modifications based on this link involved calling overload of raygunclient.send() accepts raygunmessage: var message = raygunmessagebuilder.new .setenvironmentdetails() .setmachinename(environment.machinename) .setexceptiondetails(myexception) .setclientdetails() .setversion("a build") .settags(new[] { "a tag" }) .setusercustomdata(mycustomdata) .build(); raygun.send(message); (note haven't yet attempted nix post data.) i'm finding logs contain no request data whatsoever! appears eithe...

wordpress - PHP ZipArchive still remains the path to the file even if the file is added without path -

guys! saw lot of posts talking using ziparchive , how rid of path structure inside zip. so, here's code: $zipname = $post->post_title.".zip"; $zip = new ziparchive; $zip->open($zipname, ziparchive::create); foreach($gallery $img) { $attachment = get_attached_file($img['id']); $zip->addfile($attachment, pathinfo($attachment,pathinfo_basename)); } $zip->close(); header('content-type: application/zip'); header('content-disposition: attachment; filename='.$zipname); header('content-length: ' . filesize($zipname)); readfile($zipname); exit; the problem is, zip file contains image without path, f.e. /image.jpg , same image in multiple directories appears on server /path/to/the/file/image.jpg. so, i'm not sure why happening. can on this? looking @ documentation of addfile : $zip->addfile($attachment, pathinfo($attachment,pathinfo_basename)); pathinfo($attachment,pathinfo_basename) returning ...

zend framework - How to exclude directory in code coverage in phpunit -

i have directory structure of testproject of zend application like -source files -application -library -zend -public -test files -application -phpunit.xml and phpunit.xml configuratio is <phpunit bootstrap="./bootstrap.php"> <testsuite name="application test suite"> <directory>./application</directory> </testsuite> <!--<testsuite name="library test suite"> <directory>./library</directory> </testsuite>--> <filter> <!-- if zend framework inside project's library, uncomment filter --> <whitelist> <directory suffix=".php">../../library/zend</directory> </whitelist> </filter> <logging> <log type="coverage-html" target="./log/htmlreport" charset="utf-8" yui="true" highlight="tr...

multithreading - TThreadList and "with" statement -

just short question regarding how use tthreadlist. safe use "with" statement follows: fenginelist.daqengines.locklist begin try idx := 0 count - 1 items[idx].param1 := cos(2*pi*i/count); ... ... fenginelist.daqengines.unlocklist; end; end; or should explicitly here: uengines := fenginelist.daqengines.locklist; try uengines begin idx := 0 count - 1 items[idx].param1 := cos(2*pi*i/count); ... ... end; fenginelist.daqengines.unlocklist; end; thanks! it's upon variant choose. with tells compiler get members write in code. yes, safe, long you're accessing members wanted to. doesn't affect runtime. i prefer first way, without begin..end block (if i'd forced use with ), it's personal preference , free write wish: with fenginelist.daqengines.locklist try ... fenginelist.daqengines.unlocklist; end;

mysql - socket.io performance one emit per database row -

i trying understand best way read , send huge amount of database rows (50k-100k) client. should read rows @ once database @ backend , send rows in json format? isn't responsive user waiting long time, faster small no. of rows. should stream rows database , upon each reading of row database, call socket.emit()? causes many socket emits, more responsive, slow... i using node.js, socket.io rethink interface first off, user interface design shows 50-100k rows on client not best user interface in first place. not large amount of data send down client , client manage , perhaps impractical in mobile devices, it's way more rows single user going read in given interaction page. so, first order might rethink user interface design , create sort of more demand-driven interface (paged, virtual scroll, keyed letter, etc...). there lots of different possibilities different (and better) user interface design lessens data transfer amount. design best depends entirely u...

javascript - AngularJS: ngRepeat for select on change ngOptions-list -

i have angularjs app, has select filled options arry, using ngoptions. every time user clicks button add one, ngrepeat directive generates new select @ bottom. i want make sure user cannot select duplicate values. so if list contains 3 items: item1, item2 , item3, , user selects item3 , presses button, last generated select list should contain items 'item1' , 'item2'. if user select 'item1' , presses button, user should see next select generated 'item2' option. so generally, in case above, generated html should this: <div data-ng-repeat="item in selectedoptions"> <select> <option value="1">item1</option> <option value="2">item2</option> <option value="3">item3</option> </select> <select> <option value="1">item1</option> <option value="2">item2</option> </select> <sele...

javascript - Password Match with Angular.js -

i try create form validation. new @ angular.js. copied code samples couldn't make work. here html , script: <body ng-app="myapp"> <script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> <h2>validation example</h2> <form name="myform" novalidate> <p>username:<br> <input type="text" name="user" ng-model="user" required> <span style="color:red" ng-show="myform.user.$dirty && myform.user.$invalid"> <span ng-show="myform.user.$error.required">username required.</span> </span> </p> <p>email:<br> <input type="email" name="email" ng-model="email" required> <span style="color:red" ng-show="myform.email.$dirty ...

php - Fetching and submitting data to database -

Image
my code fetches entries database , prints them separate forms accept or deny each of them using buttons of different actions. whenever perform action on 1 of forms, not operation on same form instead moves order starting first entry in database. in picture above, if accepted second form, perform function on first form. code: <?php } else if ($usertype == 1) { ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(-1); $server = ""; $user = ""; $pass = "r=~"; $db = ""; $db3 = "aukwizcq_professors"; $user1 = $_session['username']; $mysqli = new mysqli($server, $user, $pass, $db) or mysqli_error($mysqli); $mysqli5 = new mysqli($server, $user, $pass, $db3) or mysqli_error($mysqli); $name= $mysqli5->query("select name professor username= '$user1'")->fetch_object()->name; //taking name list of professors equal userid logged in (if hes professor,...

ios - Progress View stuttering when animating with loop -

Image
i'm trying update progress view using property observer updated in loop sleep. see tutorial - http://www.ioscreator.com/tutorials/progress-view-tutorial-in-ios8-with-swift i'm having same problem 1 of comments. the animation stuttering. jumps 0 64% , 100%. any idea how can create smoother animation? try replacing sleep(1) sleep(arc4random_uniform(10)). check out example apple - https://developer.apple.com/library/ios/samplecode/uicatalog/listings/swift_uicatalog_progressviewcontroller_swift.html hope helps.

caching - Is there a way to cache a key value pair in ios watchkit extension app similar to images? -

in watchkit app, can cache image files given in link https://developer.apple.com/library/ios/documentation/general/conceptual/watchkitprogrammingguide/images.html so asking way cache key value pair similarly? i think you'll find nsuserdefaults you're looking for. can store simple key/values, though should use keychain sensitive. here's docs: https://developer.apple.com/library/prerelease/ios/documentation/cocoa/reference/foundation/classes/nsuserdefaults_class/index.html

javascript - Call a function after the Twitter widget has fully loaded -

i'm having bit of issue @ moment twitter api. have sidebar uses javascript dynamically measure height of footer upon page load , page resize. i've placed twitter widget footer, causing issue twitter widget loads last, no matter place within javascript file. i've tried use event handler calling measuring function after twitter widget has loaded, still doesn't make difference. does have suggestions? you have few options solve problem. use js method such .setinterval continue loop until twitter widget in dom , execute function. or alternatively use settimeout , force update footer function wait until twitter widget present. recommend former. if you're not comfortable using setinterval - might want check out handy plugin waits until specified element inserted dom. check it: https://gist.github.com/buu700/4200601 asynchronous loading of third party widgets typically causes few headaches. above solutions should point in right direction sorting out p...

winforms - How can I know when a value is “re-selected” in a UltraComboEditor? -

similar threads: how can know when value "re-selected" in combobox? what event handler use combobox item selected (selected item not changed) i using infragistics ultracomobeditor show values filling it's valuelist property items. selected item template , require update elements using template. to apply again need fire it's selectionchangecommitted event, not fire if item selected. i in quest find drop down list element selected before dropdownclosed event fire. there way element selected or element under mouse point after dropdown event?

javascript - JQuery flot remove bar border -

here's jsfiddle how can remove border or same bar (not darker) ? edit : actually, need remove border completely. possible? var chartoptions = { xaxis: { ticks: chartticks }, grid: { clickable: true, hoverable: true }, series: { stack: true, bars: { fill: '#000', show: true, align:'center', barwidth: 0.5 } } }; you can use linewidth option remove outline / border of bars , / or fillcolor option change filling (this can used gradients ): series: { stack: true, bars: { show: true, align: 'center', barwidth: 0.5, linewidth: 0, fillcolor: { colors: [{ opacity: 1.0 }, { opacity: 1.0 }] } } } see fiddle example.

How to rotate image using HTML5 canvas library like: KineticJS or KonvaJS? -

i able rotate rectangle (shape) using kineticjs library rotate image, how can that? var stage = new kinetic.stage({ container: 'container', width: 530, height: 530 }); var layer = new kinetic.layer(); var bg = new kinetic.image({ x: 0, y: 0, width: 530, height: 530, fill: '#d7d7d7', }); /****************** image **********************/ //sticker.setrotationdeg(90); var imageobj = new image(); function sticker(v) { if(!imageobj.src){ var sticker = new kinetic.image({ x: 280, y: 300, image: imageobj, draggable: true }); layer.add(sticker); } imageobj.src = 'http://cdn.sstatic.net/photo/img/apple-touch-icon.png'; layer.draw(); } /****************** image **********************/ layer.add(bg); stage.add(layer); <script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v4.4.2.min.js"></script> <div id="container"></div>...

Javascript validate empty fields -

can me on how validate javascript form if following fields empty? doesn't seem work code. function addvalidation(){ var w = document.forms["shop"]["w"].value; var t = document.forms["shop"]["t"].value; var = document.forms["shop"]["a"].value; var c = document.forms["shop"]["c"].value; var s = document.forms["shop"]["s"].value; var c = document.forms["shop"]["c"].value; if (w == "" || t =="" || == ""|| c == "" || s == "" || c == "") { alert("mandatory fields must filled out"); return false; } http://jsfiddle.net/tn2fvh4p/91/ http://jsfiddle.net/tn2fvh4p/68/ please use following code function addvalidation(){ var w = document.getelementbyid("w").value; var t = d...

javascript - JSON array zero length even with elements? -

Image
i getting json response server , creating javascript object. structure this: var response = { key1:[], key2:[], key3:[], key4:[], key5:[] } when request completes response object completed this: object (*expandable): key1: array[0] key2: array[0] key3: array[0] key4: array[20] key5: array[113] now later on want store information database. have created function , console.log response object make sure it's ok (here getting interesting - see comments): function setupdatabase(){ console.log(response); // prints response correctly (see response above) console.log(response.key5); //prints key5: array[0]. if expand array[0] elements inside. console.log("key5: "+response.key5.length);//prints 0!! } it's normal first 3 keys 0 because there no elements returned them. rest 2 ok. why log, while run 3 console.log commands on same object in row? missing something? this issue how console.log works on br...

XML to XML Using XSLT without namespace -

i'm able convert 1 xml when input xml doesn't have namespace i'm not able desired output when input xml has namespace. input.xml(w/o namespace) <?xml version="1.0" encoding="utf-8"?> <addressbook> <address> <addressee>john smith</addressee> <streetaddress>250 18th ave se</streetaddress> <city>rochester</city> <state>mn</state> <postalcode>55902</postalcode> </address> <address> <addressee>yogesh</addressee> <streetaddress>saligramam</streetaddress> <city>chennai</city> <state>tamil nadu</state> <postalcode>600026</postalcode> </address> </addressbook> xsl <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="xml" version="1...

php - Can't send image to server with Retrofit -

i'm using retrofit library upload file php server unknow error occurs. here android code : retrofit service : @multipart @post("/upload_image.php") public void uploadimage(@part("file") typedfile file, @query("id_client") long id_client, @query("id_obj") long id_obj, callback<boolean> callback); upload code : public void uploadimage(string imagepath, long, clientid, obj obj, callback<boolean> callback) { typedfile typedfile = new typedfile("application/octet-stream", new file(imagepath)); mservice.uploadimage(typedfile, clientid, obj.getid(), callback); } php code : if(move_uploaded_file($_files["file"]["tmp_name"], $destination)){ echo ("stored in".$_server[document_root]."/uploader/uploadedfiles/".$_files["file"]["name"]); } else { $html_body = '<h1>file upload error!</h1>'; switch ($_files[0]['error...

ruby - Force return after render in rails controller? -

using rails 4.2.1 i want write function forces controller called in render , return. possible? def error! # stuff define error # render error render end def somecontroller < actioncontroller::metal include abstractcontroller::rendering include actioncontroller::rendering include abstractcontroller::callbacks include actioncontroller::renderers::all include actioncontroller::implicitrender def some_action if # - continue else # bad - error! error! # how force controller stop execution , return here? # return error! # # in error! function? end puts 'still running' end end check def some_action if # - continue else return error! end puts 'still running' end another option raise exception within error! , , have rescue_from block @ applicationcontroller level

javascript - Open a form after clicking more cell table (jquery/php) -

i have page calendar table , i've used script change bgcolor (css class .clicked) value of 1 or more td tag. $(document).mousedown(function() { $("td#target").bind('mouseover',function(){ $(this).toggleclass('clicked'); }); }) .mouseup(function() { $("td#target").unbind('mouseover'); }); $("td#target").mousedown(function() { $(this).toggleclass('clicked'); }); now need on mouseup open popup form, i'm not able it. can me? example: i'm selecting cells 15 20 may, on mouse click open popup form "compile these fields day 15-16-17-18-19-20" thank you you can make divs positioned fixed or absolute , overlay underlaying content. overlaying div(popup) normal div can make forms , whatever want. here quick jsfiddle threw toghether: http://jsfiddle.net/0zvqm5nr/35/ here code of jsfiddle: html <div class="calendar...

user interface - Java, Drawing on an JPanel with colors -

i coded program can insert coordinates , size of sqaure , draw on jpanel . used: panel.getgraphics().drawrect(x,y,h,b); now want add color-chooser that: color farbe = jcolorchooser.showdialog(null, "color-chooser", null); so how draw square color? tried doesn't work: panel.getgraphics().drawrect(x,y,h,b, farbe); panel.getgraphics() not how custom painting should performed. see painting in awt , swing , performing custom painting more details start creating custom component extends jpanel , override it's paintcomponent method (and make sure call super.paintcomponent before custom painting). place "drawing" logic within it. panel should provide setter , getter allows external classes change color of rectangle been draw, way, when paintcomponent called, can change color of graphics context accordingly. also, take @ 2d graphics more details how painting done don't forget call repaint when color changed encourage pa...

java - JSP Error 404 on Firefox and Chrome -

i'm working on java project (servlet, jsp...) tomcat. when use url http://localhost:8080/namehere/ have following error : not found requested url /namehere/ not found on server. i have firefox , chrome works ie , eclipse web browser. uninstall firefox several times, same chrome nothing happened. day worked everywhere , day after (with no change between) doesn't ... any idea ? how doing servlet/jsp mapping. @ web.xml (or configuring mapping) make sure have servlet/jsp mapped @ name.

Ruby HTTParty soundcloud gem error -

i experimenting soundcloud gem , error every request make. for example following code: require 'soundcloud' client = soundcloud.new(:client_id => my_client_id) track_url = 'https://soundcloud.com/sohight/sohight-cheevy-money-is-love-out-now' track = client.get('/resolve', :url => track_url) puts track.genre anyone knows why error? /users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/hash_conversions.rb:33:in `normalize_param': uninitialized constant httparty::hashconversions::erb (nameerror) /users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/hash_conversions.rb:15:in `block in to_params' /users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/hash_conversions.rb:15:in `each' /users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/hash_conversions.rb:15:in `map' /users/angel/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.4/lib/httparty/hash_conversions.rb:15:in `to_params' /...

c# - Returning an unknown object -

as example, have base class called baseabstractclass , couple of derived classes: public class derived : baseabstractclass { public derived() { } // abstract methods go here } public class derivedex : baseabstractclass { // code goes here } and have class: public class someclass { public someclass() { } object returnmeanobject(int whichobject) { object toreturn = null; if (whichobject == 0) { toreturn = new derived(); } else if (whichobject == 1) { toreturn = new derivedex(); } return toreturn; } } in main function: public class start { static void main() { someclass someclass = new someclass() derived derived = (derived)someclass.returnmeanobject(0); } } the object i'm returning unknown until runtime, in reality don't know type of object going returned - deriv...

Dumping only stack trace in linux core dumps -

is there way create minidumps process crash [like in windows] in linux. usual core dumps large in size wish stack trace dumped. possible dump stack trace? i'm guessing setting ulimit value maximum size wouldn't me since don't care size, don't need full memory dump. also, read google breakpad breakpad make me have delve code set up. don't wish modify code. you can set /proc/$pid/coredump_filter 0x10 . see http://man7.org/linux/man-pages/man5/core.5.html

How to get client connection object in tornado websocket, Python -

i using tornado websocket simple test code. in test code, want tornado.websocket.websockethandler . for example, used way below. class convplayerinterface(object): class websockethandler(tornado.websocket.websockethandler): client = none queue = ipcqueue.ipcqueue() def open(self): print 'new connection' self.client = self #in simple code, handles 1 client. self.write_message("connection open") def on_message(self, message): self.queue.put(message) def on_close(self): print 'connection closed' def __init__(self, url='/ws'): self.application = tornado.web.application([(url, self.websockethandler),]) self.httpserver = tornado.httpserver.httpserver(self.application) self.httpserver.listen(8888) self.queue = self.websockethandler.queue self.ioloop = threading.thread(target = tornado.ioloop....