Posts

Showing posts from June, 2014

android - Ignore a certain webpage when pressing back button -

recently added local error page android webview app. when webpage fails load properly, shows local html file. webview.setwebviewclient(new webviewclient() { //on error, open local file public void onreceivederror(webview view, int errorcode, string description, string failingurl) { webview.loadurl("file:///android_asset/www/myerrorpage.html"); } }); my code when button pressed: private boolean exit = false; private long timestamp = 0; private handler handler = new handler(); @override // detect when button pressed public void onbackpressed() { if(webview.cangoback()) { webview.goback(); } else { if (exit) { exit = false; //added this.finish(); } else { //added: if (timestamp == 0 || (system.currenttimemillis() - timestamp) > 3000) { toast.maketext(this, "press again close.", toast.l...

transactions - App Engine: Mechanics of creating a unique entity if it doesn't exist -

we have issue want lazily create entity if not exist. there discussion going on how , clarify things around app engine transactions. limit query single entity group transactions. i using go in examples, hope code clear enough non-go programmers. my understanding transaction, on single entity group, succeed if entity group not modified externally during transaction. 'entity group timestamp' indicating when entity group changed stored in root entity of entity group. during transaction current 'entity group timestamp' read , transaction can succeed if hasn't changed end of transaction. key := datastore.newkey(c, "counter", "mycounter", 0, nil) count := new(counter) err := datastore.runintransaction(c, func(c appengine.context) error { err := datastore.get(c, key, count) if err != nil && err != datastore.errnosuchentity { return err } count.count++ _, err = datastore.put(c, key, count) return err }, nil) in example...

ruby - Request halts in rails server. Happens randomly, can't regenerate the issue on purpose -

so have rails app running on apache2 - passenger. (usually first request after server goes stand by/sleep mode) server not respond request. on checking apache logs, see request got halted i, [2015-05-14t08:34:57.867684 #29618] info -- : started post "/v1/reply" x.x.x.x @ 2015-05-14 08:34:57 +0000 after started post there no log entries. can going wrong? going mad on issue. using ruby 2.2, rails 4.0, apache2, passenger 4.0.50. using latest version of passenger reverted old version see if fixes issue. no luck.

ruby - Websocket Rails Rspec tests -

i have problem test message triggering controller after dispatching event. here rspec test: describe "product.delete" "should trigger message" event = create_event("product.delete", :data => "some") expect(event.dispatch).to trigger_message :any end end here event.rb file event routing specified: namespace :product subscribe :delete, :to => productcontroller, :with_method => :delete_product end then controller code: class productcontroller < websocketrails::basecontroller def delete_product websocketrails[:product].trigger :data => "something" end end and here getting after tests run: should trigger message (failed - 1) failures: 1) product.delete should trigger message failure/error: expect(event.dispatch).to trigger_message :any expected product.delete trigger message data, instead did not trigger message # ./spec/requests/product.rb:11:i...

javascript - Why isn't this lodash uniq isSorted not working? -

so, expect sort, isn't. _.uniq(array, [issorted], [iteratee], [thisarg]) so _.uniq([10,3,13,1,0,2], true); i run that, , doesn't sort. i'd expect return: [0,1,2,3,10,13] that's not issorted parameter does. [issorted] (boolean): specify array sorted. - https://lodash.com/docs#uniq does not mean sort array if set true it's expecting sorted array. providing true issorted performs faster search algorithm sorted arrays. it's optimization in algorithm "creates duplicate-free version of array" lot faster if array sorted.

java - ArrayIndexOutOfBoundsException: 1 in web server -

i have made simple restful web service using tomcat web container , jersey library. i have overridden post method, rest default settings used. while sending post query curl server machine expected response. other machine also, getting expected response get query, post java.lang. arrayindexoutofboundsexception: 1 exception error. post method goes this: @post @produces(mediatype.text_plain) public string post(string str) { string[] parts = str.split("&"); string[] param1 = parts[0].split("=");//value1=param1[1] (one/two): query type string[] param2 = parts[1].split("=");//value2=param2[1] string[] param3 = parts[2].split("=");//value3=param3[1] string[] param4 = parts[3].split("=");//value4=param4[1] if(param1[1].equals("one")){ return hashgenerator(param2[1],param3[1]); }else if(param1[1].equals("two")){ return saveinput(param2[1],param3[1],param4[1]); } return ...

javascript - String to regular expression -

i regular expression string server. example js_pattern = "/^9\d+$/" and need string same regular expression (without modifications) js_regexp = /^9\d+$/ re = new regexp(js_pattern) doesn't work me because in case /\/^9d+$\// are there correct variants convert string regular expression in javascript? any non-special character gets evaluated character in string . for example // true, because it's non-special gets evaluated character. console.log("\a" === "a"); // true // false, because it's new line special character. console.log("\n" === "n"); // false javascript special characters solution: escape backslashes on server before send over.

asp.net mvc - How to Map Enum Values to a Lookup Table - Code First -

i'm using code first , migration update db. have lookup table , correspond enum. table: states id | state ---|------- | my enum: public enum states { = 1, bad = 2 } i want fill state table values of enum, if change enum values - table changed in accordance. googled lot couldn't find clear it. any basic example appreciated. a google turns ef-enum-to-lookup project, looks want. creates lookup tables , foreign key constraints based on enums used in model. install nuget... install-package ef-enum-to-lookup you can run with... var enumtolookup = new enumtolookup(); enumtolookup.apply(context); you run migrations seed method, you'll need aware adding enum member not change model, if you're using explicit migrations seed method won't run.

python 2.7 - Partner Ledger Report using ORM methods in Odoo8 -

i working on partner ledger report , have prepared report using sql query def lines(self, partner): move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] full_account = [] if self.reconcil: reconcile_tag = " " else: reconcile_tag = "and l.reconcile_id null" self.cr.execute( "select l.id, l.date, j.code, acc.code a_code, acc.name a_name,inv.state,inv.date_due, l.ref, m.name move_name, l.name, l.debit, l.credit, l.amount_currency,l.currency_id, c.symbol currency_code " \ "from account_move_line l " \ "left join account_journal j " \ "on (l.journal_id = j.id) " \ "left join account_account acc " \ "on (l.account_id = acc.id) " \ "left join res_currency c on (l.currency_id=c.id)" \ "left join account_move ...

php - Laravel return simplified JSON from query -

so i'm performing query , getting data this: [ { "part_number": "mac0009", "description": "accessory stand foot" }, { "part_number": "mac0010", "description": "accessory stand collar tapped m5" }, { "part_number": "mac0011", "description": "accessory stand top collar" }, { "part_number": "mac0012", "description": "25mm round knob 2 rail holes" } ] however ajax script i'm trying implement need data in format: [ { "mac0009" : "accessory stand foot" }, { "mac00010" : "accessory stand collar tapped m5" }, { "mac00012" : "accessory stand top collar" } ] so need plain data without table names. all have far query. $result = db::table('macs')->select('part_number', 'description')->get(); which fine don...

php - How can I get a unknown number from a string within a certain part of the string? -

my string: how rate ease , comfort required undertake session?@question_value_0 how able value above string? don't know value (apart integer): (some question)@question_value_x x integer, want x. i looked regex, suck @ regular expressions, i'm @ loss, cheers guys! about far got regex /@question_value_[0-9]+/ but can't number out of string. how can grab number? this should work you: just put escape sequence \d (which means 0-9 ) quantifier + (which means 1 or more times ) group ( () ) capture the number can access in array $m . <?php $str = "how rate ease , comfort required undertake session?@question_value_0"; preg_match("/@question_value_(\d+)/", $str, $m); echo $m[1]; ?> output: 0 if print_r($m); see structure of array: array ( [0] => @question_value_0 [1] => 0 ) and see ^ have full match in first element , first group ( (\d+) ) in second element.

java - What could happen if I use resultset.getString() by passing a blob? -

i have blob column in table, using mysql. i'm trying value getstring method of resultset, rs.getstring("xxxxxx") i'm not sure if there problem in situation. dose depend on stored in column? can this? it doesn't matter stored in database. doesn't matter string or int. data query result , interpreted string. string not sequence of bytes. reference object expected string. means reference points structure in memory structure of other references. so, when take sequence of bytes , assume reference object then, likely, have runtime exception. classcastexception knows data has. exception unpredictable in case. bottom line - don't this.

sitecore - Using the/?sc_item={guid} URL and error 404's -

a quick question on sc7.5 - have large legacy system directing users sitecore content. know guid , want redirect user seamlessly via url www.mysite.com/?sc_item={guid} we want able check if content still there , if not produce error 404 allow (and others) clean our links via 404 reports. is there solution @ ? one approach might consider using reverse proxy. can install application request routing module on iis. allow inspect , rewrite incoming requests arr site , forward them on 1 or more backend servers. can rewrite responses backend servers (adjust relative links on page, fix response location in header, etc.) i've implemented solution client has large legacy website , incrementally transitioning content sitecore. reverse proxy allows me mask end-users. urls remain same always. what makes technique powerful can write own rewrite provider arr. means during runtime of arr can execute arbitrary code rather rely on rules achieve desired effect. rewrite provider c...

sbt - Converting to a multi-project build -

i trying convert sbt single project sbt multiproject. i copied src folder new directory website use subproject. changed old (working) lazy val website = (project in file(".")) .enableplugins(sbttwirl) .enableplugins(sbtweb) to lazy val website = (project in file("website")) .enableplugins(sbttwirl) .enableplugins(sbtweb) the part revolver.restart <<= revolver.restart.dependson(webkeys.assets in assets) (managedclasspath in runtime) += (packagebin in assets).value stops working though. first 1 gives me [error] reference undefined setting: [error] [error] fg2/web-assets:assets fg2/*:restart and second one [error] reference undefined setting: [error] [error] fg2/web-assets:packagebin fg2/runtime:managedclasspath

android - Unable to capture text from prompt by using UIAUTOMATER,Appium and python -

i new mobile automation.i trying automate login functionality 1 android app.when ever clicking on login button without providing username getting 1 prompt message field cannot empty. alert box unable capture through uiautomater.i want string prompt. can suggest how proceed .i providing image getting clear idea. https://lh3.googleusercontent.com/-q0xeth2ihns/vvmtk_bjvpi/aaaaaaaaaak/yzipnoptwtm/w506-h281/uiautomater.jpg i had similar problem uiautomatorviewer not capturing toast messages. solved it. ocr solution. i made full anser here: appium toast message first install tesseract this: sudo apt-get install tesseract then can use below in terminal: tesseract example.jpg out install pytesseract using pip: pip install pytesseract install pillow if not done yet: pip install pillow install tesseract-ocr: sudo apt-get install tesseract-ocr then use in python code this: from pil import image import pytesseract # path file im = image.open('test.p...

Is there any way to implement all the formulas that are supported by Excel , into Java? -

i want program support formulas 1 can use in excel file java code. the requirement functions supported excel both mathematical , logical (add, multiply, substract or 'or', 'if') , others vlookup etc java same format? is there way achieve that? the apache npoi project seems support excel formulas. examples available here .

Delete a record in MYSQL using playframework and Form<T> -

hi new play framework.i implement crud operation using mysql database in play framework. i have able delete, update entire table, not able delete single record. want pass values html. index.scala.html @(message: string) @main("welcome play") { <ul id="bars"> </ul> <form action="@routes.application.addbar()" method="post"> <label for="name"> enter name</label> <input name="name"/> <br> <label for="place"> enter place</label> <input name="place"/> <br> <input type="submit"/> </form> <form action="@routes.application.getbars()" method="get"> <label for="retrieve"> retrieve details table </label> <input type="submit"/> </form> <form action="@routes.application.deletebar()" method="get"...

swift - DatePicker Control in IOS with large Daterange -

i looking date picker control choose date between 10'000 b.c. till today (2015). can use uidatepicker ( didn't find information uidatepicker ? i mean allow date range of 12015 years ? or there way achieve standard controls ? or have create own control ? you can use uipickerview , set ( uipickerviewdelegate delegate methods) - (nsinteger)numberofcomponentsinpickerview:(uipickerview*)pickerview to whatever number want - ie. 2 if want able choose month , year. can set how many values should in each component setting up - (nsinteger)pickerview:(uipickerview*)pickerview numberofrowsincomponent:(nsinteger)component and populate arrays - (nsstring *)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component or (if want customize bit more) - (uiview*)pickerview:(uipickerview*)pickerview viewforrow:(nsinteger)row forcomponent:(nsinteger)component reusingview:(uiview*)view

jquery - Is there any way to make morris.js area chart gradient -

i using morris.js area chart show weather report of year. fiddle poc: http://jsfiddle.net/xtyr7/337/ script: morris.area({ element: 'chart', data: [ { m: 'jan', value: 3 }, { m: 'feb', value: 10 }, { m: 'mar', value: 5 }, { m: 'apr', value: 17 }, { m: 'may', value: 6 } // till december ], xkey: 'm', ykeys: ['value'], labels: ['orders'], parsetime: false, linecolors:['#1e9cb5'] }); i want fill area gradient. can suggest me workaround ? using below method can achieve gradient fill morris.area.prototype.fillforseries = function(i) { var color; return "10-#3b7078-#b6b120:40-#bc951c-#3b7078:90-#3b7078"; } usage: gradients linear gradient format: “‹angle›-‹colour›[-‹colour›[:‹offset›]]*-‹colour›”, example: “90-#fff-#000” – 90° gradient white black or “0-#fff-#f00:20-#000” – 0° gradient white via red (at 20%) black. radial gradient: “r[(‹fx›, ‹fy›)]‹colour›[-‹...

Querying the Google Domain Shared Contacts API via service account -

i'm writing application in c# aims query google domain shared contacts api retrieve (and update/add/delete) domain shared contact records. not supported via .net client libraries, have written procedure retrieve oauth 2.0 token include in request https://www.google.com/m8/feeds/contacts/example.com/full . believe have oauth 2.0 token request procedure correct, getting 403 forbidden error when calling above mentioned url token. however, if go oauth 2.0 playground , create token through there , use token instead in c# app, call succeeds , contact records returned. my question - domain shared contacts api support being called credentials of service account? the solution issue include email address of "overarching" domain administrator account user being managed ('sub' property of claimset when creating jason web token or 'user' property of serviceaccountcredential initialization). domain administrator has access domain data, call retrieve domai...

ruby on rails - Why is Unicorn looking for rackup file (config.ru) even though I am specifying a config? -

i ssh'd ubuntu 14.04 server instance, trying bootstrap unicorn server rails 4.2 app. cd /home/sh0/app/current/api bundle exec unicorn -e production -c /home/sh0/app/current/api/config/unicorn.rb but fails! /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/lib/unicorn/configurator.rb:657:in `parse_rackup_file': rackup file (config.ru) not readable (argumenterror) /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/lib/unicorn/configurator.rb:77:in `reload' /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/lib/unicorn/configurator.rb:68:in `initialize' /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:100:in `new' /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:100:in `initialize' /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/bin/unicorn:126:in `new' /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/bin/unicorn:126:in `<top (required)>'...

How to set multiple matrix elements at a time in R? -

i have sparse representation of matrix m below: 1 3 6 2 5 7 5 4 10 which means m[1,3]=6 , m[2,5]=7 , , m[5,4]=10 . if want generate regular 2d matrix representation, there way set existing elements of 2d matrix m @ once? don't want go on index pairs in loop, because there thousands of such pairs (although there 3 of them in example above). i tried m[c(1,2,5),c(3,5,4)]=c(6,7,10) , sets m[1,5]=6 , m[1,4]=6 besides m[1,3]=6 . you "sparse" matrix: library(matrix) m <- sparsematrix(i = c(1, 2, 5), j = c(3, 5, 4), x = c(6, 7, 10), dims = c(5, 5)) #5 x 5 sparse matrix of class "dgcmatrix" # #[1,] . . 6 . . #[2,] . . . . 7 #[3,] . . . . . #[4,] . . . . . #[5,] . . . 10 . if need base r matrix: as.matrix(m) # [,1] [,2] [,3] [,4] [,5] #[1,] 0 0 6 0 0 #[2,] 0 0 0 0 7 #[3,] 0 0 0 0 0 #[4,] 0 0 0 0 0 #[5,] 0 0 0 ...

ios - Downloading from iCloud -

i have icloud support in application. , save database in icloud successfully. when try download database file using bellow code nsfilemanager *fm = [nsfilemanager defaultmanager]; nsurl *ubiq = [[nsfilemanager defaultmanager] urlforubiquitycontaineridentifier:nil]; if (ubiq == nil) { return; } nserror *theerror = nil; nsurl *url = [[ubiq urlbyappendingpathcomponent:@"documents" isdirectory:true] urlbyappendingpathcomponent:filename]; bool started = [fm startdownloadingubiquitousitematurl:url error:&theerror]; nslog(@"started download %@ %d", filename, started); if (theerror != nil) { nslog(@"icloud error: %@", [theerror localizeddescription]); } else { } downloading start don't know download or destination path. how can save file local directory of app. please help

osx - Hide password in python using getpass.getpass() -

when type >>> passwd = getpass.getpass() into python 2.7 shell, in idle, result: warning (from warnings module): file "/library/frameworks/python.framework/versions/2.7/lib/python2.7/getpass.py", line 55 passwd = fallback_getpass(prompt, stream) getpasswarning: can not control echo on terminal. warning: password input may echoed. password: then when type password, isn't hidden. need send variable, can sha using sha module , compare 'shaed' original. pass python keyword . please change password = getpass.getpass() then run shell/console

java - Tomcat SSL is very slow -

i have implemented ssl apache tomcat8. slow. followed below article implementing ssl. https://tomcat.apache.org/tomcat-8.0-doc/ssl-howto.html it takes lot of time load intial jsp, have css & javascript file includes.

mongodb - How to limit connection pool size in monk Node.js -

i using monk module data mongodb. connect db creates 5 connections. this command line mongodb server console... 2015-05-14t10:32:35.618+0530 network [initandlisten] connection accepted 127.0.0.1:61015 #3 (2 connections open) 2015-05-14t10:32:35.619+0530 network [initandlisten] connection accepted 127.0.0.1:61016 #4 (3 connections open) 2015-05-14t10:32:35.621+0530 network [initandlisten] connection accepted 127.0.0.1:61017 #5 (4 connections open) 2015-05-14t10:32:35.621+0530 network [initandlisten] connection accepted 127.0.0.1:61018 #6 (5 connections open) 2015-05-14t10:32:35.622+0530 network [initandlisten] connection accepted 127.0.0.1:61019 #7 (6 connections open) 2015-05-14t10:32:35.629+0530 network [conn3] end connection 127.0.0.1:61015 ( 5 connections open) 2015-05-14t10:32:35.629+0530 network [conn4] end connection 127.0.0.1:61016 ( 5 connections open) 2015-05-14t10:32:35.629+0530 network [conn5] end connection 127.0.0.1:61017 ( 5 connections open) 2015...

c++ - What Does This Loop Optimization Profile Mean? -

i getting started using vtune. educational example, i'm trying hand @ micro-optimization in debug mode. here's toy example codebase. code appears in c++ non- const method, , ".data_length" int field of object (offset 32 bytes), typically large number: for (int i=0;i<data_length;++i) { /*...*/ } vtune helpfully showed me assembly (from msvc 2013) for loop. note performance numbers, in seconds (i removed timings don't register). added annotation: 0x140433084 mov dword ptr [rsp+0x588], 0x0 | | ;"i=0" 0x14043308f jmp 0x1404330a1 <block 77> | | ;jump compare , loop body | | 0x140433091 block 76: | | ;"++i" 0x140433091 mov eax, dword ptr [rsp+0x588] | 0.451 | 0x140433098 inc eax | 0.002 | 0x14043309a mov dword ptr [rsp+0x588], eax | | | | 0x1404330a1 block 7...

bash - Using Scons to run other build scripts "underneath" -

i'm working on contract enhance huge gnarly build system that's based on scons bunch of shell scripts , makefiles intertwined it. the system runs bunch of individual scons commands , request client put in "top level" sconscript control underlying scons runs. i got work using command function: tgt = env.command('bogus.out', 'bogus.in', "./stc.sh") where shell script 'stc.sh' removes next target's controlling fake file 'pkgbogus.out': tgt2 = env.command('pkgbogus.out', 'pkgbogus.in', "./stcpkg.sh") this works fine, , understand out of scope normal scons use ... there slicker way without these 'bogus' files?

matlab - Print all elements of a struct -

i approaching matlab, have function struct: function [out] = struct1() account(1).name = 'john'; account(1).number = 321; account(1).type = 'current'; %.......2 9 account(10).name = 'denis'; account(10).number = 123; account(10).type = 'something'; ii= 1:10 out=fprintf('%s\n','%d\n','%s\n',account{ii}.name, account{ii}.number,account{ii}.type); end end the above code gives me error: "cell contents reference non-cell array object." how output elements of such struct output using "fprintf"? name: 'john' number: 321 type: 'current' ...... 2 9 name: 'denis' number: 123 type: 'something' you indexing elements of struct array { , } used cell arrays. simple ( , ) work fine. also, since have line breaks in formatspec , should combine 3 strings together. example: formatspec = 'name: %s\nnumber: %d\ntype...

math - replace NA with data from another column in R -

i know how make na 's blanks following code: imileft imiright imiavg na na na na 71.15127 na 72.18310 72.86607 72.52458 70.61460 68.00766 69.31113 69.39032 69.91261 69.65146 72.58609 72.75168 72.66888 70.85714 na na na 69.88203 na 74.47109 73.07963 73.77536 70.44855 71.28647 70.86751 na 72.33503 na 69.82818 70.45144 70.13981 68.66929 69.79866 69.23397 72.46879 71.50685 71.98782 71.11888 71.98336 71.55112 na 67.86667 na imileft <- ((aslcomptest$lhml + aslcomptest$lrml)/(aslcomptest$lfml + aslcomptest$ltml)*100) imileft <- sapply(imileft, as.character) imileft[is.na(imileft)] <- "" but when code, won't allow me average of "imileft" , "imiright" or make "imiavg" same other column has numerical value. imiavg<-((imileft + imiright)/2) error in imileft + ...

json - How do I use the data returned by an ajax call? -

i trying return array of data inside json object return url, can see data being returned using console.log. however when trying catch return array in variable example: var arr = list(); console.log(arr.length); the length being output code "0" despite fact data returned has content (so length greater zero). how can use data? list: function() { var grades = []; $.getjson( "https://api.mongolab.com/api/1/databases", function(data) { console.log(data); grades [0] = data[0].name; console.log(grades.length); }); return grades; }, the issue facing easy snagged on if aren't used concept of asynchronous calls! never fear, you'll there. what's happening when call ajax, code continues process though request has not completed. because ajax requests take long time (usually few seconds) , if browser had sit , wait, user staring in angsuish @ frozen scr...

parse.com - Parse and Xamarin -

i using xamarin , wondering if there way run parse in shared project, don't have duplicate code in ios project , android project in solution? am missing something, or have duplicate parse code? what did create shared project type host parse specific code. in xamarin.android app, reference parse.android.dll. in xamarin.ios code, referenced parse.ios.dll. remember, "shared project" type not create dll. underneath hood it's file linking actual project, use references of project. shared project should not contain ios or android specific code.

Save app data on Android/iOS using Haxe/OpenFL -

so, i've created haxe function (using openfl library) saves text , image data game's folder on desktop targets. little while ago, however, notified in thread function not work on mobile targets. same user, thiagojabur , gave me solution (scroll down in same thread). main problem don't have mobile device myself can test on (i have galaxy tab4, haven't gotten working haxe projects). rather send 100 versions can test it, i've decided ask questions here. the goal save data folder game's app id. instance, if app id com.potato.potatogame , data saved (on android) in application storage directory, in folder /android/data/com.potato.potatogame/ . believe can first part of path using openfl.utils.systempath.applicationstoragedirectory() , i'm stuck on how app id. know of function can so? alternatively, may misunderstanding part of code. way thiagojabur used code, seem systempath.userdirectory() returns "/android/data/com.potato.potatogame" on a...

XAML ListView on wrong positon in the grid -

Image
i trying make listview in picture third row on grid, below slider controls. unfortunately not taking position per definition. please advise here definition: <grid> <grid.rowdefinitions> <rowdefinition height="auto"/> <!--top date--> <rowdefinition height="10"/> <!--just space between top date & slider controls--> <rowdefinition height="auto"/> <!--slider row--> <rowdefinition height="*"/> <!--favorite shifts list view--> </grid.rowdefinitions> <textblock x:name="tbdate" grid.row="0" text="mon 28 april" foreground="white" horizontalalignment="center" fontsize="23" margin="6,0,0,0" style="{staticresource messagedialogtitlestyle}"/> <grid grid.row="2" horizontalalignment="center"> <grid.columndefinitions...

javascript - How to access value of variable in Mongo? -

var = "act"; db.s.findone( { brandid: doc.brandid, : {$exists:false} } ).a; i try pass value of variable "a" mongoscript. looks can not used. can help? build query step step , not use . use [] instead var = 'act'; var query = {brandid: doc.brandid}; query[a] = {$exists:false}; db.s.findone(query)[a]; note: query.act == query['act']. just javascript tricks.

Integrate Spring 4 with EJB in legacy system -

tl;dr : how autowire ejb spring @controller ?? i'm trying add new spring 4 webapp legacy system uses ejbs, , runs in resin 4. ejbs stateless , , local , , contain: @resource sessioncontext ejbcontext ejbs looked via singleton contains line: return new initialcontext().lookup("production/entapp/default/myapplication/" + classname + "/local"); i've got no experience of using ejbs other via method, i'm not familiar how lookup performed, ejbs found in manner. my question: how autowire ejb spring @controller ?? i suspect need create interceptor of kind, perform lookup when finds need autowire ejb, having looked through pages , pages of google , so, i'm none wiser. it's worth mentioning i'm trying of without xml, using java @configuration class.

sonarqube 4.5 has misidentified a cpp module as c - how can I fix it -

i created multi-module project single sonar-project.properties. of project in c 1 module c++. left sonar.language property blank , ran sonar-runner analysis. the project , modules created in database , looked ok when did preview on same code had large number of new issues on c++ project. on closer inspection found module in sonarqube wrong - consisted of header files (.h) , of issues use of c style comments. seems module identified c module .cpp files ignored. however, in preview language identified correctly , issues found in .cpp files not know sonarqube. i cannot find place in ui change language of module nor can figure out way force after fact in sonar-project.profiles. first, sonar.language apparently deprecated, , second, using module.sonar.language=cpp caused error: caused by: sonar.profile set 'default_c' didn't match profile language. please check configuration. default_c use projects not 1 i'm working on. have different profiles set different lan...

ios - Falling objects in SpriteKit? -

i have 20 different sprites. want "flow" of them falling top , disappearing when reach bottom. essentially, imagine rain each drop random sprite. want each sprite fall random rotation , each "drop" random sprite selection of 20. can please point me in right direction? i've never made game before , first time working spritekit. i'm using swift way. thanks! make use of arc4random random sprite selection of 20 sprites adding sprites group. arc4random able random rotation you. for them fall down top bottom, can apply -gravity them or apply -impulse. to check whether have reached bottom, y value when disappear off bottom of screen , use comparision value , use removefromparent(). alternatively third method use movement of skaction , adjust y coordinate. @ end of completion block use removefromparent().

semantic web - SPARQL query not inferencing properties after class specified -

i running test query on sparql test inferencing. query follows: prefix eem: <http://purl.org/eem#> prefix ns: <http://purl.org/net/ns/> prefix sc_data: <http://purl.org/net/ns/sc_data/> prefix dbp: <http://dbpedia.org/resource/> prefix dbpprop: <http://dbpedia.org/property/> prefix ex: <http://www.example.org/rdf#> select ?roa { service <http://dbpedia.org/sparql>{ ex:vaccine dbp:polio_vaccine. ex:vaccine dbpprop:routesofadministration ?roa. } } i no results query when trying @ snorql page. when specify polio vaccine, shouldn't automatically inherit properties specified vaccine? need change? in original query, ex:vaccine uri node, short <http://www.example.org/rdf#vaccine> . it's very unlikely dbpedia contains information it. while dbpedia endpoint may (or may not) include information inferrable dbpedia data, doesn't treat sparql query part assertion , part q...

Trouble going to different rooms in my basic Python text adventure -

i in intro programming class , have been trying create simple text adventure every time (try) go different room name error saying particular room isn't defined. thought because called room after else statement @ end , again right underneath didn't change anything. #this random text adventure game. enjoy! def main(): print("you wake in cave without clue of how got there. head throbbing. \ninsistent on figuring out happened you, decide explore cave in search of answers. \n") print("you can following things: \n" "'go left' - explore tunnel on left. \n" "'go right' - explore tunnel on right. \n") #evaluates player's choice. choice = input("what do?: ") if choice == 'go left': print("you stumble way down left tunnel.\n") left_cave() if choice == 'go right': print("you stumble way down right tunnel.\n") ri...

ibm bluemix - Does IBM DataWorks support integration between Object Storage and dashDB? -

does ibm dataworks data load api support integration between object storage , dashdb? this not supported. if have actual softlayer account can connect connectivity bluemix object storage not supported @ time , considered future releases. note: question answered on dw answers user glen walters. here link post .

c# - Best way to compare Periods in using NodaTime (or alternative) -

i have requirement have relative min/max date validation able stored in database customize application per customer. decided nodatime.period due it's capability specify years best choice. however, nodatime.period not offer way compare against period. example data provided validation: minimum age of 18 years old. maximum age o 100 years old. minimum sale duration of 1 month maximum sale duration of 3 months minimum advertising campaign 7 days (note: current requirements year / month / day not combined in validations) the validations are: public period relativeminimum { get; set; } public period relativemaximum { get; set; } given user entered date (and now): var = new localdate(datetime.now.year, datetime.now.month, datetime.now.day); var uservalue = new localdate(date.year, date.month, date.day); var difference = period.between(uservalue, now); i have comparison of: if(relativeminimum != null && difference.islessthan(relativeminimum)))) { ...

python - order by average - Django -

i trying calculate score average of "pelicula". puntuacion table formed "pelis(foreign key of pelicula) " , "user(foreign key of pelicula)" , valor(this score) models.py class usuario(models.model): nombre = models.charfield(max_length=50) apellidos = models.charfield(max_length=50) usuario = models.charfield(max_length=50) password = models.charfield(max_length=50) email = models.emailfield() fechanacimiento = models.datefield() categorias = models.charfield(max_length=50) def __unicode__(self): return self.usuario class pelicula(models.model): titulo = models.charfield(max_length=50) anyo = models.charfield(max_length=50) actores = models.manytomanyfield('actor') resumen = models.charfield(max_length=300) categoria = models.charfield(max_length=50) puntuacionmed = models.charfield(max_length=50) director = models.foreignkey('director'); def __unicode__(self): ...

javascript - Is there a way to prevent a 3rd party JS code located in the <head> from taking down a site if not available? -

i'm building feature require web publishers put js code snippet in section of page in order work. code includes call external (and dynamically generated) js file remote server. file cannot cached putting on cdn isn't option. what i'm worried if there ever problem remote server make remote file unreachable, can take down page in code included (potentially entire site code suppose included site-wide). is there way make sure no matter what, availability of remote file never affect availability of page in code included? -edit- resources in remote file need available before html of page starts render. loading code asynchronously isn't option. you specify async=true not "block" page resuming loading other resources. otherwise it'll halt @ script, though may vary depending on how each browser handles stalling script elements. note: support of async attribute varies - modern browsers circa 2014 understand if need support legacy browsers may ...

c# - Fill ViewBox completely with part of image area determined by Image.Clip -

i have large image want use within windows phone 8.1 app. purpose of application want show part of image , want fill complete viewbox specific part. i can specific part of image using image.clip. until have been unable viewbox filled part determined image.clip. use following xaml. <pivot> <pivotitem margin="10"> <viewbox stretch="uniform" stretchdirection="both"> <image source="http://image.png" stretch="none"> <image.clip> <rectanglegeometry rect="500,100,600,700"/> </image.clip> </image> </viewbox> </pivotitem> </pivot> i've tried various combinations of stretch settings on both image , viewbox. i'also experimented scaletransforms until no luck. so question is want possible...

c# - Linq count vs IList count -

if have following ienumerable list comes repository. ienumerable<someobject> items = _somerepo.getall(); what faster: items.count(); // using linq on ienumerable interface. or list<someobject> temp = items.tolist<someobject>(); // cast list temp.count(); // count on list is linq count() faster or slower casting ienumerable list , performing count() ? update: improved question little bit bit more realistic scenario. calling count directly better choice. enumerable.count has performance improvements built in let return without enumerating entire collection: public static int count<tsource>(this ienumerable<tsource> source) { if (source == null) throw error.argumentnull("source"); icollection<tsource> collectionoft = source icollection<tsource>; if (collectionoft != null) return collectionoft.count; icollection collection = source icollection; if (collection != null) return collec...

embedding - Youtube video embeded link (their own host) looks horrible, almost like 3d, but on their website it looks fine -

for example link https://www.youtube.com/embed/7pryfy4wqdy?autoplay=1&showinfo=0&showsearch=0&modestbranding=1&controls=0&rel=0&wmode=transparent makes video green , purple, , misaligned. but directly on site, plays fine. causing this? https://www.youtube.com/watch?v=7pryfy4wqdy

C/C++ How to convert back int to string (a word)? -

in c i'm reading string txt file, example string "hello", have my: f=fopen("text.txt","r"); fscanf(f,"%s\n",string); now, if want convert string hex , decimal, can this: for (i=0; i<strlen(string); i++) { sprintf(st, "%02x", string[i]); //convert hex strcat(hexstring, st); sprintf(st, "%03d", string[i]); //convert dec strcat(decstring, st); } now, question is: want inverse operation, how? output if convert "hello" hex-> 68656c6c6f dec-> 104101108108111 from "68656c6c6f" or "104101108108111" want go "hello", how can this? (basically want website: http://string-functions.com/ ; string hex converter, hex string converter, decimal hex, converter, hex decimal converter) the challenge realize have string of hex , string of decimal, meaning have character string representation of values, not values themselves. need convert stri...

activerecord - Rails 4 - switch/change table name during request dynamically? -

based on request, query either test_users or users . doing using user.table_name = "test_users" or user.table_name = "users" this works in development, not in production (i.e table name in query not change), due - config.cache_classes = true config.eager_load = true i guessing table names being cached somewhere , model.table_name= not update cache. how can switch table name dynamically? running 4.2.0 , if helps postgres (pg gem).

selenium webdriver - Sporadic test failures due to unknown error while taking screenshot in Chromedriver -

we starting sporadic test failures when running in chrome . happens 3 out of every 10 tests runs. have no idea why occurring or how fix it. appreciated. below stack trace error see. org.openqa.selenium.webdriverexception: unknown error: cannot take screenshot unknown error: failed capture tab: unknown error javascript stack: error: failed capture tab: unknown error @ checkforextensionerror (chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/background.js:14:17) @ object.callback (chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/background.js:37:5) @ safecallbackapply (extensions::sendrequest:21:15) @ handleresponse (extensions::sendrequest:73:7) (session info: chrome=42.0.2311.135) (driver info: chromedriver=2.9.248315,platform=windows nt 6.1 sp1 x86_64) (warning: server did not provide stacktrace information) command duration or timeout: 13 milliseconds build info: version: '2.44.0', revision: '76d78cf323ce037c5f92db6c...

php - Model file not returning values in codeigniter -

my model file working on localhost when upload, returns null values. please explain me how database.php wrong. my database.php : $active_group = 'default'; $active_record = true; $db['default']['hostname'] = 'http://niation.com'; $db['default']['username'] = 'nire'; $db['default']['password'] = 'xxxxu23'; $db['default']['database'] = 'trrtuu'; $db['default']['dbdriver'] = 'mysql' $db['default']['dbprefix'] = ''; $db['default']['pconnect'] = true; $db['default']['db_debug'] = false; $db['default']['cache_on'] = false; my model file: <?php class play extends ci_model { function getdata() { $data = $this->db->select('info')->get('home'); return $data->result(); } my controller file class nirmal exten...

Not casting pointers in C can cause problems? -

yesterday in class, , @ point instructor talking c code. said: what purpose of making pointer cast in c? purpose make compiler interpret correctly pointer operations (for example, adding int pointer result in different offset adding char pointer). apart that, there no difference: pointers represented same way in memory, regardless if pointer pointing int value, char value, short value, or whatever. so, casting pointer not modify in memory, programmer operations more related pointer-type dealing with. however, have read, specially here in stack overflow, not 100% true. have read in weird machines, pointers different types can stored in different ways in memory. in case, not changing pointer correct type cause problems if code compiled kind of machine. basically, kind of code i'm talking about. consider code below: int* int_pointer; char* char_pointer; int_pointer = malloc(sizeof(int)); *int_pointer = 4; and 2 options: 1. char_pointer = (char *)int_pointer...

unit testing a static Main() method in c# -

i trying write unit tests using visual studio unit testing framework static main method, entry point application. have method follows. public static void main() { structuremapbootstrapper.register(); setupfilter<applicant>(); } and calls generic setupfilter method private static void setupfilter<t>() t : idatafilterbase, new() { var filtername = typeof(t).name; if ("startreceiver".trygettrueorfalseconfigvalue(filtername)) { objectfactory.configure(x => x.for<idatafilterbase>().use<t>()); var filter = new t(); filter.startreceiver(); loghelper.loginfo(string.format("started {0} filter service", filtername)); } else { loghelper.loginfo(string.format("{0} filter service not started. startreceiver flag set false", filtername));...

android - How can i insert a .bin created on desktop file into apk -

i have code creating internal file, there random algorithem create data stored in , want app have same file same binary data in it. so need make file on desktop , add internal files how. my question think best way it. thought locate in project, read it, , write internal files. the problem is, dont know locate file in android studio included in external files , read from. thanks. =] hope made myself clear. put in src/main/assets/ . you can access file assetmanager , whatever want it. from android developers website : main/assets/ this empty. can use store raw asset files. files save here compiled .apk file as-is, , original filename preserved. can navigate directory in same way typical file system using uris , read files stream of bytes using assetmanager . example, location textures , game data.