Posts

Showing posts from February, 2015

How to open an Android device's default camera without showing the chooser. -

i have button that, when pressed, user gets asked choose camera app , allows him/her take picture. firstly, want rid of choice when button pressed user in camera interface. code i'm using right (after having tried many solutions online), prompt user choose camera: intent = new intent(android.provider.mediastore.action_image_capture); try { packagemanager pm = this.getpackagemanager(); final resolveinfo minfo = pm.resolveactivity(i, 0); intent intent = new intent(); intent.setcomponent(new componentname(minfo.activityinfo.packagename, minfo.activityinfo.name)); intent.setaction(mediastore.action_image_capture); intent.addcategory(intent.category_launcher); startactivity(intent); } catch (exception e) { log.i("tag", "unable launch camera: " + e); } i have skimmed through few articles not possible launch android native/default camera without chooser - however, see apps faceboo...

angularjs - How to use a angular value into ng-repeat -

i have added code here. want use {{gname}} in ng-repeat . what's proper syntax this? <div class="groupvalues" ng-repeat="gname in groupname"> {{gname}} <div class="subvalues" ng-repeat="gvalues in groupvalues['{{gname}}']"> {{gvalues}} </div> you can try : <div class="groupvalues" ng-repeat="gname in groupname"> {{gname}} <div class="subvalues" ng-repeat="gvalues in groupvalues[gname]"> {{gvalues}} </div> </div>

php - Does rehashing a randomly salted password at login increase security? -

i working on project in php, , wondering how make system secure possible. using password_hash hash passwords , store them in database. wondering: rehashing , re-saving new salted hash database increase security, or illusion? i don't think increase security, no. have 2 risk scenarios: the cracker breaks server , stays there time undetected. in case, passwords can captured programmatically, users log in. requires less effort brute-forcing strong hash algorithms. the cracker breaks in, steals copy of database, , in response sysadmin plugs security hole , restores server backup quickly. in second case, cracker has set of usernames, email addresses , hashed passwords, may wish try brute-forcing. there no advantage had if these hashes created once or thousand times. it's worth remembering we're trying guard against here. if security of website has been breached, there knock-on effect users have used same username/password combination @ other popular service...

ios - Apple Pay in the South African market -

i want implement apple pay in 1 of applications. while reading, found post saying supported uk , , not south africa. if upload build having apple pay functionality, work south africa? also, app rejected. from own question: it supported uk , us will work south africa? no if application going available in south africa, user's won't able use apple pay (yet. apple pay may rolled out in future) , should implement solution if application available worldwide, users in , uk able use apple pay, however, no others , should either implement solution replace apple pay, or include option users can't access apple pay. i think it's unlikely app rejected including apple pay if app available worldwide. however, part of question off topic, , can't provide definite answer.

python - Create variables in Django views.py and access them at later point -

let's have following 2 functions in views.py: def foo(request): class_instance = someclass() return httpresponse('whatever') def bar(request): # here want access class_instance initially, foo() called, , @ later point bar() called, in want access variable class_instance . is there way of accomplishing while neither using request.session nor django models (e.g. django.db.models )? (nb: had luck global variables in views.py, bad idea anyway , somehow didn't work) you can put variable module constant, if it's not prone changing much. class_instance = someclass() def foo(request): return httpresponse('whatever') def bar(request): # here want access class_instance then both methods have access that, but keep in mind, functions can't change constant's value way . ps: can change value of global: class_instance = someclass() def foo(request): global class_instance class_instance = someclass() #...

jquery - print javascript array in html -

not sure how print results onto html. can through alerts. how print on browser? <!doctype html> <html> <body> <script> var parsed = ""; var myobject = [{ firstname: "jane", lastname: "doe", email: "jdoe@email.com" }, { firstname: "ja", lastname: "joe", email: "je@email.com" }, { firstname: "janet", lastname: "joes", email: "jsse@email.com" }]; (i = 0; < myobject.length; i++) { var myobj = myobject[i]; (var property in myobj) { parsed += property + ": " + myobj[property] + "\n"; alert(property); alert(myobj[property]); } } alert(parsed); </script> </body...

asynchronous - starting a function in asynch mode in R, as a separate process -

i looking ability start r processes asynchronously within r. below function startfunctioninasynchmode<-function(workingdir,filestosource, functionname, ...){ #workingdir - dir should set wd #filestosource - vector of filenames sourced #functionname - actual function run asynchrously #... - other parameters passed function #return value - should system process id started } would have quick ideas? checked packages parallel etc. doesn't seem fit. in advance here implementation using r cmd. basic version tested. , open items. startfunctioninasynchmode<-function(workingdir,filestosource, functionname, ...){ wd<-getwd() setwd(workingdir) fs<-makefiles() scriptfile<-fs$scriptfile cat(file=scriptfile,paste0("source(\"",filestosource,"\")", collapse = "\n")) cat(file=scriptfile,"\n",append = t) functioncall<-getfunctioncall(functionname,as.list(match.call()), startinde...

line split in C# without any reason -

i m reading text file file.readallline use foreach function read use line worked fine @ 1 point break 1 line unnecessarily 2 lines string[] lines = file.readalllines("yilc2.csv"); foreach (string line in lines) { console.writeline(line); } line in csv file breaks two 12345.67890,foobar,barbaz,spamham,female,17,town,12345678901,example@example.com,"block 42 flat no 05 fourth floor jubilee garden apartment dha phase 2",university,,,barbaz,,,,mba,,no, individual values in csv files allowed have embedded line breaks, long these values surrounded double-quotes ( reference ). a field contains embedded line-breaks must surounded double-quotes here example: point of view of csv reader file has single line 3 values: "one","two three","four" in c# notation values "one" , "two\r\nthree" , , "four" readalllines method pays no attention double-quotes, point...

vba - Compare and count consecutive data in Excel -

i trying make excel macro compare , count data same column. specifically, want count if cell , cell below cell both have absolute value less 100. end goal: column below data have, 241.197 96.747 88.325 156 53.666 55.372 -45.667 -207.152 i want macro return value of 2. need count [96.747 88.325] & [53.666 55.372 -45.667] say have column data starting @ a1 sub counttotal dim integer dim sum double dim count integer = 1 cells(rows.count, "a").end(xlup).row sum = abs(range("a" & i).value) + abs(range("a" & + 1).value) if sum < 100 count = count + 1 next msgbox count end sub not tested. should see if counts last value in column + empty 1 after, if does, shorten loop 1.

c++ - Reducing time complexity of string comparison -

i have dictionary .txt file on thousand words , definitions. i've written program take first word of each line file , check against string input user: void checkword(string input) { std::ifstream infile; infile.open("oxford.txt"); if (infile.is_open()) { string line; //there "using std::string" in file while (getline(infile, line)) { //read first word each line std::istringstream iss(line); string word; iss >> word; //make sure strings being compared same case std::transform(word.begin(), word.end(), word.begin(), ::tolower); std::transform(input.begin(), input.end(), input.begin(), ::tolower); if (word == input) { //do thing word } } infile.close(); return "end of file"; } else { return "unable open file"; }...

drag and drop - protractor clickanddrug on canvas -

i need automate signature on canvas. when used cucumber used canvas.click_and_drop_by , when try perform using protractor read have use action sequence. how do if i'm using page-objects? this canvas: <canvas class="pad float-left" height="100" width="290" title=""></canvas> this page-object: function mypage() { this.firstsignature = element(by.css('.pad')[0]); this.sign = function() { var offset = {x:30, y:30}; browser.actions(). mousemove(this.firstsignature, offset). mousedown(). mousemove(45,45). mouseup(). performaction(); }; } module.exports = mypage; how can make drag work? there special draganddrop() method: browser.actions().draganddrop(this.firstsignature, {x: 45, y: 45}).perform();

javascript - store $http GET promise object locally -

i've been scratching head trying figure out how implement simple data update on graph due lack of angular service knowledge. trying make 1 request , store json object locally on controller can have (1) original json render original chart , (2) modified json based on user input (always modifies original json) render updated chart. here controller: ` angular.module('scattchartapp') .controller('chartctrl', function($scope, $http, $cachefactory) { $http.get('chartconfig.json').success(function(response) { $scope.options = response.options; $scope.data = response.data; $scope.initdata = angular.copy($scope.data); }); $scope.update = function(user){ var a, b, c, d, e; = user.a; b = user.b; c = user.c; d = user.d; e = user.e; var data = $scope.data; if(a !== "" && b !== "" && c !== "" && d !== "" && e !== ""){ for(var = 0; i<$sco...

Creating a new Dataframe from loop on old dataframe in R -

i have dataframe time series of prices(pt) looks follows: head(mydata) b c 2005-07-29 66.82 41.80 372.0 2005-08-01 68.94 42.70 373.0 2005-08-02 70.22 43.75 379.2 2005-08-03 70.79 43.75 385.6 2005-08-04 70.42 44.10 390.0 2005-08-05 69.84 43.60 386.0 consideri ng lookback window of 3 days (w=3), trying create new dataframe time series of following: x(ti) = 1/w (pt/pt + pt-1/pt + pt-2/pt) i have used following code: nr<-nrow(mydata) nc<-ncol(mydata) x<-data.frame() (j in 1:nc){ for(i in 1:nr-w+1){ x[i,j]<-rowsums(mydata[i:(w+i-1),j]) } } however, following error message: error in rval[i, j, drop = drop., ...] : 0's may mixed negative subscripts this seems suggest wrong loop? or syntax? appreciated.

SSL: make Java check the whole trust chain -

say i'm communicating client via https certificate chain: acme root | +--- acme intermediate | +--- server cert i've created trust store i've imported acme intermediate certificate using keytool -import -alias intermediate-ca -file acme_intermediate.der -keystore /path/to/intermediate-cacerts and started vm ... java -djavax.net.ssl.truststorepassword=changeit -djavax.net.ssl.truststore=/path/to/intermediate-cacerts ... when connecting server, connection made. i've expected javax.net.ssl.sslhandshakeexception unable find valid certification path requested target or similar because acme root certificate not stored in intermediate-ca . to sure, i've checked if jvm examined default system truststore strace ing jvm did not: $ strace -tt -f -etrace=open java -djavax.net.ssl.truststorepassword=changeit -djavax.net.ssl.truststore=/path/to/intermediate-cacerts program 2>&1 | grep -ve 'open\((.*\.(so|jar)|"/(proc|d...

twitter bootstrap - AngularJS: External Modal Templates -

i read agularjs - include external html file modals , didn't include code or explanation , pointed docs i've read. so, go more detail. i have main html file spa (single page application). want use modals more detailed views. <html> <head> <meta charset='utf-8'> <script src="js/angular.js"></script> <script src="js/angular-ui-bootstrap-modal.js"></script> <script src="js/app.js"></script> <link rel="stylesheet" href="css/bootstrap.css"> </head> <body ng-app="myapp" ng-controller="myctrl"> <button class="btn" ng-click="open()">open modal</button> <!-- want in separate html file --> <div modal="showmodal" close="cancel()"> <div class="modal-header"> <h4>modal dialog</h4> </div> <div...

Using SQL Server CTE to duplicate results of temporary table query -

i've solved problem given work - solved using temporary tables - , i'd prefer solve using ctes if @ possible. appreciate. the problem determine convention attendance. but, twist is, determine how many attendees have gone convention 3 out of previous 5 years. this works, code (a little long - sorry ... ): declare @cnt int = 2006; create table #meetingmatrix (meeting varchar(10), year int); create table #attendees (year int, id varchar(10)); create table #rollup (year int, matches int); -- create table of meetings insert #meetingmatrix (meeting, [year]) select meeting, cast(year(end_date) int) meet_master meeting_type='conv' , (year(end_date) > 2000 , year(end_date) < 2016); -- create table of has gone on years insert #attendees ([year], id) select distinct mm.year, orders.st_id orders inner join order_lines on ( orders.order_number = order_lines.order_number ) inner join product on ( order_lines.product_code = product.product_code ) in...

java - Hibernate @Filter collection of enums -

i need figure out how apply annotation-based filtering parameter list of enums defined as: @column(name = "target_status") @enumerated(enumtype.string) @type(type="pgenumconverter", parameters = { @parameter(name = "enumclassname", value = "com.company.model.campaign.campaigntarget$status") }) private status targetstatus; so @filterdef looks this: @filterdef(name="filtercampaigntargetbystatuses", defaultcondition="target_status in (:statuses)", parameters = @paramdef(name = "statuses", type = "string")) and when enable filter looks this: session.enablefilter("filtercampaigntargetbystatuses"). setparameterlist("statuses", statuses); and error hibernate is: org.hibernate.hibernateexception: incorrect type parameter [statuses] the data in postgresql , definition of type: create type statuscmp enum ('act...

android - Cordova Camera plugin error when large image is re-size using targetWidth & targetHeight -

i having problem camera plugin in android using phonegap. app stop working when upload large images(2mb above) not when upload small size images. here sample code: function browse_image(){ navigator.camera.getpicture(onphotodatasuccess, onfail, { quality: 50, destinationtype: destinationtype.file_uri,sourcetype: picturesource.photolibrary, targetwidth: 600, targetheight: 600 }); } the image trying used 2.27mb 2448x3264 pixels. i aware when remove "targetwidth: 600 , targetheight: 600" plugin work will. i know if there away make plugin work without removing targetwidth & targetheight option in plugin any or suggestion appreciated!

javascript - Isotope filter with jquery css overlays not working as expected -

i have strange problem, using isotope's filterable function sort through elements in portfolio. when user hovers on portfolio element overlay triggered using following code: /*************************************************** portfolio item image hover ***************************************************/ $(window).load(function(){ $(".portfolio-grid ul li .item-info-overlay").hide(); if( is_touch_device() ){ $(".portfolio-grid ul li").click(function(){ var count_before = $(this).closest("li").prevall("li").length; var this_opacity = $(this).find(".item-info-overlay").css("opacity"); var this_display = $(this).find(".item-info-overlay").css("display"); if ((this_opacity == 0) || (this_display == "none")) { $(this).find(".item-info-overlay").fadeto(250, 1); } else { ...

php - How to only select 2 column from the database with laravel 5.1? -

i trying use laravel 5.1 select records mysql database , break results pages. here method use return database results listall view. (this code display white screen "no errors, no results") public function getindex(){ $accounts = db::table('accounts') ->lists('account_id','account_name') ->where('client_id', '=', 7) ->paginate(100); $name = 'mike a'; return view('accounts.listall', compact('accounts', 'name')); } when using code below, works returns column. want display 2 columns. public function getindex(){ $accounts = db::table('accounts') ->where('client_id', '=', 7) ->paginate(100); $name = 'mike a'; return view('accounts.listall', compact('accounts', 'name')); } edited this code after k...

While loop doesn't stop (Bash) -

i want delete of blank lines , lines spaces (if exist (only bottom of file)) , remove 1 more line (also bottom of file). i have code: while [[ "$last_line" =~ ^$ ]] || [[ "$last_line" =~ ^[[:space:]]+$ ]] sed -i -e '${/$/d}' "./file.txt" done sed -i -e '${/$/d}' "./file.txt" for reason loop doesn't stop , deletes in file. matter? you can use tac , awk combination this: tac file | awk 'begin{p=0} p<=1 && /^[[:blank:]]*$/{p=1; next} p==1{p++; next} 1' | tac tac file # prints files in reverse /^[[:blank:]]*$/ # find blank/empty lines using search pattern tac # reverse file content

wpf - Trying to write to the Keywords windows metadata item using C# -

we have couple folks, right now, going through directory of thousands of jpgs , hand-setting tags metadata item on them in windows explorer. want whip read spreadsheet they're getting tags , applying them files. in research i've done, seems "tags" metadata in windows "keywords" xmp metadata. i've managed read metadata using following code: filestream fs = new filestream(@"c:\test.jpg", filemode.open, fileaccess.readwrite, fileshare.readwrite); bitmapsource img = bitmapframe.create(fs); bitmapmetadata md = (bitmapmetadata)img.metadata; stringbuilder tags = new stringbuilder(); foreach (string s in md.keywords) { tags.append(s); tags.append(";"); } string fin = tags.tostring(); the problem keywords property read-only collection. i've found several "leads" on writing metadata, none of them seem work. sucks because if open file in note...

c# - Adding Datatable to List<Datatable>, data being persisted through add(). Why? -

i have need add 1-* datatables list<datatable> . on first iteration through, confirm appropriate data has been loaded datatable gets added list. however upon second iteration, i"m noticing first item added has been overwritten data of second item , , on. i tried here, in hopes creating new datatable , adding list help, i'm still running same issue. datatable dt = new datatable(); dt = _dtdetails; // _dtdetails datatable _dtdetailslist.add(dt); // _dtdetailslist list<datatable> this should straight forward add. i'm doing similar things elsewhere in code , it's not having same end result this. there nothing special list or datatable. normal stuff. thoughts?

javascript - Select2: Emptying and loading changed array data, loads old data -

first loaded array data by: $("#foo").select2({ data: example }); then changed array "example" , wanted change select by: $("#foo").empty(); $("#foo").select2({ data: example }); but old select showed up. idea why? edit: array wasnt updated caused error.

Java, change boolean from another class -

this question different because it's creating 3d world editor.. @ moment want updated positions of models work.. so i've worked way rather simple problem. in order update scene want have boolean if specific input given , change false true once input given.. problem though input method has in class , don't know how can affect boolean there.. here's code: public class enginesetup extends game { public boolean dostuff = true; public void init() { creationtool updatecoords = new creationtool(this); while(dostuff == true) { updatecoords.environment(); dostuff = false; } } } this happens when engine starts. it's going run environment method in creationtool class once, because after first execution dostuff changes false. public class creationtool extends gamecomponent { public void input(float delta) { if(input.getkeyup(getcoords)) // change boolean value in enginesetup true } } in creationtoo...

java - how to extract image from rtf file using RTFEditorKit -

using coding html extracted. need extract image rtf. think problem in rtfeditorkit. please suggest ideas solve this. private static string rtftohtml(reader rtf) throws ioexception { jeditorpane p = new jeditorpane(); p.setcontenttype("text/rtf"); rtfeditorkit kitrtf = (rtfeditorkit) p.geteditorkitforcontenttype("text/rtf"); try { kitrtf.read(rtf, p.getdocument(), 0); kitrtf = null; editorkit kithtml = p.geteditorkitforcontenttype("text/html"); writer writer = new stringwriter(); kithtml.write(writer, p.getdocument(), 0, p.getdocument().getlength()); return writer.tostring(); } catch (badlocationexception e) { e.printstacktrace(); } return null; } standard rtfeditorkit not support images. can use alternative advancedrtfeditorkit . read document , go through character elements checking attributes imag...

textview - Auto Scroll Text View when Talkback is enabled in Android -

in android, when "talk back" enabled , reads text overflow scrollable textview, keeps on reading entire text without scrolling. reads text not visible on screen. there way can make textview auto scroll along text "talk back" reading. no. body of answer must 30 characters. seriously though, there no way this. platform limitation. consider chunking text multiple views. more accessible large blocks of text take long time talkback read , can frustrating users.

python - httplib.HTTPConnection timeout: connect vs other blocking calls -

i'm trying use python's httpconnection make long running remote procedure calls (~30 seconds) httplib.httpconnection(..., timeout=45) solves this. however, means failed connection attempts cause painfully long wait. can independently control read , connect timeouts socket -- can when using httpconnection? i understand not waiting send request, if deal connection failure first, wont have wait, i.e. don't include timeout parameter first request, following: httplib.httpsconnection ('url' ) headers ={'connection' : 'keep-alive'} conn.request("request blank", headers) #dummy request open conn , keep alive dummy_response = conn.getresponse() if dummmy_response == 200 or dummy_response == 201: #if ok, work conn conn.request("request real", timeout = 25) else: reconnect. #restart dummy request just suggestion, can bump question or have answered again.

angularjs - Where is the appropriate place to instantiate a javascript widget/chart/utility when using angular.js? -

i'm using chart.js make, unsurprisingly, chart, , i'm trying figure out how cleanly , correctly rewrite code in angular.js. vanilla implementation if using vanilla javascript , html, i'd boils down this: <canvas id='chart'></canvas> <script> data = {...} // dictionary of chart data, omitted brevity options = {...} // dictionary of chart options, same^ var ctx = document.getelementbyid("chart").getcontext("2d"); var chart = new chart(ctx).line(data, options); </script> and first canvas load, script run , draw chart. angular but angular, can have, instead, <ng-chart></ng-chart> <script> angular.module('app') .directive('ngchart', function(){ return { restrict: 'e', template: '<canvas></canvas>' ... } ) </script> and put same javascript first example inside dir...

c# - error: "select command that does not return any key", but Im sure that Im giving a key -

im trying update table, works fine tables 1 have error: http://i.stack.imgur.com/yq75b.jpg (i cant post images sorry) and have primary key http://i.stack.imgur.com/u9qjl.jpg the problem must in table because works other table, tried deleting , creating again primary key column error persist,change column name neither solves it. if use query sql server can find primary key exist: select information_schema.key_column_usage objectproperty(object_id(constraint_name), 'isprimarykey') = 1 but in update still receive same error: sqlconnection con = new sqlconnection(conn1.connectionstring); sqldataadapter dacust = new sqldataadapter("select * item", con); sqlcommandbuilder cbcust = new sqlcommandbuilder(dacust); dacust.update(ds.tables[0]); (i'm sending "ds" webserver datagridview item columns match) as said table "item" cant updated tried tens of other tables witho...

javascript - Efficient CSV Row Reduction JS -

i have huge csv i'm trying filter based on user input. looks this: from,phone_number,from_date seattle,123,6/15/15 omaha,321,6/14/15 i have function supposed take user input , match rows meet criteria. var lst = [] var lst2 = [] var lst3 = [] function mapper() { var dateu = document.getelementbyid("userinputdate").value; var cityu = document.getelementbyid("userinputcity").value; var numberu = document.getelementbyid("userinputnumber").value; d3.csv("some.csv", function(d) { return { city: d.from, number: d.phone_number, date: d.from_date }; }, function(error, rows) { (var = 0; < rows.length; i++) { lst.push(rows); if (dateu.length > 0) { (var = 0; < lst.length; i++) { if (lst[i].date === dateu) { lst.push(rows[i]); console.log(rows[i]); } } if (cityu.length > 0) { (var = 0; < lst.length; i++) { if (lst[i].city === cityu) { ...

c++ - How to do un-normalized 2D Cross Correlation in IPP -

i'm doing c++ optimization work , have need of plain vanilla version of cross correlation without mean offset or normalization scaling operations. know under normal circumstances image data influence of brightness removed using above means structural similarity can discerned in our application brightness needed. i'm using ipp 7.1, know if there's means this? next best thing i'll have write loops manually , exploit simd autovectorization openmp parallelization. yes, of course, there available crosscorr functions without normalization - take @ ippi.h : ippapi( ippstatus, ippicrosscorrvalid_32f_c1r, ( const ipp32f* psrc, int srcstep, ippisize srcroisize, const ipp32f* ptpl, int tplstep, ippisize tplroisize, ipp32f* pdst, int dststep )) ippapi( ippstatus, ippicrosscorrvalid_8u32f_c1r, ( const ipp8u* psrc, int srcstep, ippisize srcroisize, const ipp8u* ptpl, int tplstep, ippisize tplroisize, ipp32f* pdst, int dststep )) ippapi( ippstatus, ip...

c# - Akka.net dynamically add child -

there configured actorsystem actors organized hierarchically following: /user /processes /process1 /process2 /process3 to generate scheme use next c# code: // in entry point iactorref processescoordinatoractorref = actorsystem.actorof(props.create<processescoordinatoractor>(), "processes"); // in processescoordinatoractor.cs: iactorref processoneactorref = context.actorof(props.create<proccessactor>(), "process1"); iactorref processtwoactorref = context.actorof(props.create<proccessactor>(), "process2"); iactorref processthreeactorref = context.actorof(props.create<proccessactor>(), "process3"); my problem want add child actor process1 , process2 or process3 entry point code (outside of processactor). hands tied, because iactorref hides actor instance me. how solve it? the child actor has created in context of parent actor. if want trigger happening outside, send parent message ,...

c# - Auto implemented interfaces in Arrays -

i read book "clr via c# fourth edition". , cannot understand 1 statement: so, example, if have following line of code: filestream[] fsarray; then when clr creates filestream[] type, cause type automatically implement ienumerable<filestream> , icollection<filestream> , , ilist<filestream> interfaces. furthermore, filestream[] type implement interfaces base types: ienumerable<stream> , ienumerable<object> , icollection<stream> , icollection<object> , ilist<stream> , , ilist<object> . i tested statement code: filestream[] fsarray = new filestream[0]; string s = null; foreach (var m in fsarray.gettype().getinterfaces()) s += m.tostring() + environment.newline; and result, have this: system.icloneable system.collections.ilist system.collections.icollection system.collections.ienumerable system.collections.istructuralcomparable system.collections.istructuralequatable system.collect...

javascript - Nesting a parent child relationship in lodash, given the parent id and children -

how able nest json object if parent , children given property. the data looks like: "1": { "id": 1, "name": "foo", "parent": null, "root": 1, "children": [2, 4, 6], "posts":[ { "id": "1", "name": "item1" }, { "id": "2", "name": "item2" }, { "id": "3", "name": "item3" } ] }, "2": { "id": 2, "name": "bar", "parent": 1, "root": 1, "children": null, "posts":[ { "id": "4", "name": "item4" } ] }, "3": { "id": 3, "name": "bazz", ...

c++ - What is the upper bound of BigInteger with character array implementation? -

if impement biginteger character array (in c++), in terms of power of 10, upper bound in 32bit system? in other words, - 10^x < n <= 10^x (first character reserved sign). what x in 32 bit system? please ignore have reserved memory os , consider 4gb memory addressable us. an 8-bit byte can hold 2 8 , or 256 unique values. 4gb of memory 2 32 , or 4294967296 bytes . or 4294967295, if subtract 1 byte want reserve sign that's 34359738360 bits . this many bits can hold 2 34359738360 unique values. - 10^x < n <= 10^x (first character reserved sign). what x in 32 bit system? wolfram alpha suggests - 10^1292913986 < n <= 10^1292913986 largest representable powers of 10. so x 1,292,913,986.

python - Locust.io Load Testing getting "Connection aborted BadStatusLine" Errors -

i'm using locust.io load test application. random error unable pinpoint problem: 1) connectionerror(protocolerror(\'connection aborted.\', badstatusline("\'\'",)),) 2) connectionerror(protocolerror('connection aborted.', error(104, 'connection reset peer')),) the first 1 one happens few times every 1,000,000 request or , seems happen in groups there 5-20 @ once , fine. second happens every couple days or so. the cpu , memory below servers max load database server, app server , machine running locust.io. the servers medium sized linode servers running ubuntu 14.04. app django , database in postgresql. have increased maximum open file limit wondering if else needs increased on server leading occasional errors. from have been able gather searching error might have python requests library. -any appreciated.

maven - Setup AEM Adobe CQ5 6.1 project to build/install offline -

i'm new cq5 , looking steps/settings may need setup aem adobe cq5 6.1 project build/install offline (not connected internet). i've use our internal network nexus (which has lot of general dependencies available except aem related). i've use maven & java7. looking possible issues/resolutions, steps & helpful info. a typical aem project have lots of dependencies. there dependencies aem platform(including granite, sling, osgi etc). these dependencies downloaded adobe public repositories, unless have nexus repository in company these dependencies available.

javascript - HTML5 audio: trying to make a queue -

i working on text-to-speech generator using javascript , html5 audio elements. idea transform string of ipa (international phonetic alphabet) sound. in function talk() , take string , split it. put corresponding sounds queue , try play playq(q) function. but function doesn't seem work. can make play first sound. q[0].play; working, rest of playq(q) function not. i'm thinking either because of q.shift() method, have tried q[1:] , or because of recursivity. function talk(){ var queue = [] var str = document.ipatts.phonetic.value var letters = str.split("") (x in letters) { queue.push(document.getelementbyid(letters[x])) } playq(queue); } function playq(q){ q[0].play(); var z = q.shift(); q[0].onended = function() {playq(z)}; } nevermind! got work using var z = [] (x in q) { if (x > 0) { z.push(q[x]) } } in stead of var z = q.shift();

python 2.7 - twitter search api not returning exact phrase results everytime -

the twitter search api not returning tweets have exact phrase. i'm using quotes documentation specifies https://dev.twitter.com/rest/public/search here search looks like search_phrase = 'puppies' tweet_results = [status status in tweepy.cursor(api.search, q='"{}"'.format(search_phrase), lang = 'en', count = 100).items(1000)] of 1000 tweets 46 of them not contain "puppies" here example output below. perhaps "puppies" located somewhere else in tweet object? maybe in users section of profile. below bad responses. rt @3_beards: oh yeah! @silicondrinkabt growing! welcoming @drinkabouttlv family more on way! that moment when forget you're not important person them rt @3_beards: oh yeah! @silicondrinkabt growing! welcoming @drinkabouttlv family more on way! those few of bad results.

database - Smartface IS Secure Data-Fields don't work -

i have created local table , inserted data. long don't use is secure fields works fine. when use is secure fields encrypted text these fields. seems decrypt function missing. how solve this? for accessing fields use: var field_value = data.execute("select f3 testtable rowid = 3;"); alert("row 3:" + field_value); actually, should encrypted values if try kind of sql execute statement, regardless how many rows selected issecure. mean, if there issecure field, should seen encrypted. selecting rows insecure or of them insecure, shouldn't change anything. the new release of smartface app studio available right now. ( http://account.smartface.io/account/login?returnurl=%2f ) i tested case, works fine new release. by way, if want reach actual value in table, try below code : data.mydataset.move(2); //lets reach same row wrote above move alert("row 3 : " + data.mydataset.f3); you should write dataset's name instead of my...

c++ cli - Calling c++ generic method from C# -

i created c++ 64-bit library follows // unmanagedcli.h #pragma once using namespace system; using namespace system::runtime::interopservices; namespace unmanagedcli { [dllimport("msvcrt.dll", entrypoint = "memset", callingconvention = callingconvention::cdecl, setlasterror = false)] extern intptr memset(intptr dest, int c, int count); //[system::runtime::compilerservices::extensionattribute] public ref class unmanaged sealed { public: static void free(void* unmanagedpointer) { marshal::freehglobal(intptr(unmanagedpointer)); } generic <typename t> t : value class static intptr new(int elementcount) { return marshal::allochglobal(sizeof(t) * elementcount); } generic <typename t> t : value class static intptr newandinit(int elementcount) { int sizeinbytes = sizeof(t) * elementcount; int...

python - Is there any method in django to use database without creating models.py file? -

i having database data filled in , want use in new django app. way use data of database in django app.actually don't want make changes in old database , want use data. please suggest me better approach this. while serching found command- inspectdb can generate model.py file database, issues it does'nt map foreign key in model.py, need rearrange our classes in model.py file , more. searching other alternative. you access data legacy database using connection.cursor() django.db module. if have 2 dabases databases = { 'default': { 'name': 'new_database', 'engine': 'django.db.backends.postgresql_psycopg2', 'user': '', 'password': '' }, 'old': { 'name': 'old_database', 'engine': 'django.db.backends.mysql', 'user': '', 'password': '' } } ......

postgresql - Play Framework trying to access DB with windows username -

i have db.conf looks in conf folder: db.default.driver=org.postgresql.driver db.default.url="jdbc:postgresql://62.210.145.112/babybets" db.default.username=postgres db.default.password="my_password" it included in application.conf: include "db.conf" infos correct, use same jdbc connection string, user/pass connect intellij db view database. when try access page, error: play.api.configuration$$anon$1: configuration error[cannot connect database [default]] @ play.api.configuration$.play$api$configuration$$configerror(configuration.scala:94) ~[play_2.10-2.3.8.jar:2.3.8] @ play.api.configuration.reporterror(configuration.scala:743) ~[play_2.10-2.3.8.jar:2.3.8] @ play.api.db.bonecpplugin$$anonfun$onstart$1.apply(db.scala:247) ~[play-jdbc_2.10-2.3.2.jar:2.3.2] @ play.api.db.bonecpplugin$$anonfun$onstart$1.apply(db.scala:238) ~[play-jdbc_2.10-2.3.2.jar:2.3.2] @ scala.collection.traversablelike$$anonfun$map$1.apply(traversableli...

jquery - Using json encoded data from ajax post to populate radio buttons -

i need populate radio buttons select shipping method , price data depending on country order shipped to. doing ajax call. $('#shippingcountry').change(function() { // dropdown list of countries var selc = $(this).val(); $.ajax({ type : 'post', url : 'formprocess.php', data: {country: selc}, datatype : 'json', encode : true }).done(function(data) { //console.log(data.msg); // data.msg thing returned // here need construct list of radio boxes... }); }); the thing returned data.msg . populated like: [ {"id":"9","name":"zone 1 standard","charge":"23.00"}, {"id":"11","name":"zone 1 fedex","charge":"37.00"}, {"id":"10","name":"zone 1 express","charge":"44.50"} ] i need take data , make radio buttons each returned item...

linux - How can I run a command on all files in a directory and mv to a different the ones that get an output that contains 'Cannot read TIFF header'? -

i'd remove bad tiffs out of large directory. commandline tool "tiffinfo" makes easy identify them: tiffinfo -d * this have ouput this: 00074000/74986.tif: cannot read tiff header. if tiff file corrupt. if happens i'd take file , move different dirrectory: bad_images. tried using awk on this, hasn't worked far... thanks! assuming "cannot read tiff header" error comes on standard error, , assuming tiffinfo outputs other data on standard out don't want, then: cd /path/to/tiffs file in `tiffinfo -d * 2>&1 >/dev/null | cut -f1 -d:` echo mv $file /path/to/bad_images done remove echo move files, once satisfied script work expected.

Laravel Form select disable first option -

i have code on view {!! form::select('room', $rooms, input::old('room'), array('class' => 'form-control')) !!} and on controller $rooms = array('' => 'select room') + $rooms; i wanted first option selected , disabled "select room". tried put in array , didn't work. if want disable 1 option select list can in html this: <select> <option value="volvo" disabled>volvo</option> <option value="saab">saab</option> <option value="vw">vw</option> <option value="audi">audi</option> </select> this disable first option disabled. for reff. http://www.w3schools.com/tags/att_option_disabled.asp

javascript - Function calling 2 ways with multiple arguments -

as of know can create simple function this. function calc(a,b){ return a+b } calc(1,1); //returns 2 we can make this function calc(a){ return function(b){ return a+b } } calc(1)(1); //returns 2 what if had multiple arguments? function calc() { function r(arg) { var = []; for(var = 0, l = arg.length; < l; i++){ a[i] = arg[i]; } return a.reduce(function(p, c) { return p + c; }); } var res = r(arguments); return function() { res += r(arguments); return res; } } this works calc(1,2)(1) doesn't calc(1,2,1) is there way combine both versions? means when calling calc(1,1) call calc(1)(1) , both still return 2. or calc(1,2,3) calc(1,2)(3) calc(1)(2,3) return 6 it needs know how many arguments calculation after ;-) you can make function turns things sort of function : function curry(f){ var args = []; return addargs; func...

xaml - Windows phone 8.1 app crash report . Nothing is there to identify the reason of crash -

i have published windows phone 8.1 silverlight application market. , among many users, of them getting ( 3 or 4 reported out of 8000 users ) app crash issue . i checked issue on our end , provided possible steps prevent crash. unfortunately users getting same app crash. and users , me equally worried.!! :( when checked dev center crash reports found following exception details never on debugging device unknown!{0dff7a2f-51f8-4de8-8e37-5e97fab540c0}_task_disconnected_while_still_running:_server_task_currentstate_=_active, targetstate =_active. missing_dump_em_watchdog_timeout_deada444_unknown.dll!{0dff7a2f-51f8-4de8-8e37-5e97fab540c0}_task_disconnected_while_still_running:_server_task_currentstate_=_active, targetstate =_active. aghost.exe!{0dff7a2f-51f8-4de8-8e37-5e97fab540c0}_quiesce_hang and noticed users getting crash on navigating in a page phone contacts images displaying . kill app chance? can please explain when these above crashes occurs , how can...