Posts

Showing posts from March, 2013

performance - Meteor - android much slower than website -

hi i'm developing app on meteor has got browser version , mobile versions. in brief, browser version works well, transition between views/routes short, fast. when launch app on android (connected same db) there long breaks between routes. can 1s on few views higher 5 seconds. in database there 3 collections has got ~2k documents. not problem browser version, there problem on android. i tested kadira. can't see going on while routing example there enormous difference in login method. in browser takes maybe 15ms, on android 400ms. and weird (and important): in browser in end there observechanges on user collection. in android there observechanges on every collection , takes lot of time. of course try optimize current algorithm not problem because browser version runs well.

javascript - Optimum Location for Code Schools -

this taken code wars, not looking cheat or anything. have pretty solved problem i'm unsure if method of determining constitutes best location correct. var optimumlocation = function(students, locations){ //your solution var listoflocations = []; (var key in locations) { var obj = locations[key]; var totaldistance = 0; (var = 0; <= students.length-1; i+=1) { console.log(students[i]); var location = calculatedistance(students[i],[obj.x, obj.y]); totaldistance += location; } listoflocations.push({id:parseint(key), dist:totaldistance}); } listoflocations.sort(function(a,b){ return a.dist - b.dist; }); console.log(listoflocations); var id = listoflocations[0].id; return "the best location number " + (id +1) + " coordinates x = " + locations[id].x + " , y = " + locations[id].y; } function calculatedistance (loc1, loc2) { var distx = math.abs(loc1[0] - loc2[0]); var disty = mat

google maps - Meteor Geocoder on iOS device, only return lat and lng, but not physical address -

i developing ios app using meteor. when applied "browser side api", can physical address on browser perfectly. however, doesn't work on ios simulator or ios devices. so, applied apikey ios application. still doesn't work. please advice. sometimes worked, of time, physical address result didn't come back. //router.js router.route('/',{ path:"/", onbeforeaction: function() { session.set('geolocation',geolocation.latlng()); console.log(geolocation.latlng()); this.next(); } }); //index.html <head> <title>todo list</title> </head> <body> <div class="container"> <header> <h1>todo list</h1> <div class="item"> hi </div> </header> <input class="address" type="search" autocomplete="off" autocorrect="off" autocapitalize="off

dojo/mobile orientation change on ios don't resize as expected -

i have been experiencing issues on ios version of mobile app, each time rotate device, screen doesn't resize expected, stuck on previous orientation or size. have made research , found bug existed on previous versions of dojo. , exist solutions , patches. using newer version , still happening previous cases. here links of cases: bugs.dojotoolkit.org/ticket/16658 bugs.dojotoolkit.../17539 bugs.dojotoolkit.../16490 i using dojo 1.9.3 , of solutions patched. can me on this, and/or if know if exists way force resize()? thank in advance. we listen , run resize window.addeventlistener("orientationchange", function() { dojox.mobile.resizeall(); }, false);

ios - multiple thread in assembly language -

override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. //*********************************************************************************************************** // requesting access , autherzation , availability let healthstore = hkhealthstore() if hkhealthstore.ishealthdataavailable() { calciumtracker.setprogress(0.1, animated: true) let sharetypes : set = [hksampletype.quantitytypeforidentifier(hkquantitytypeidentifierstepcount)!] let readtypes : set = [hkcharacteristictype.characteristictypeforidentifier(hkcharacteristictypeidentifierbiologicalsex)!] healthstore.requestauthorizationtosharetypes(sharetypes, readtypes: readtypes , completion:{ (success,error) in if !success { if let x = error { print(x.description) } } }) } else { print("health data not ava

ios - Not able to use UIView in NSObject Xcode -

Image
#import <foundation/foundation.h> typedef enum _nsbubbletype { bubbletypemine = 0, bubbletypesomeoneelse = 1 } nsbubbletype; @interface nsbubbledata : nsobject @property (readonly, nonatomic, strong) nsdate *date; @property (readonly, nonatomic) nsbubbletype type; @property (readonly, nonatomic, strong) uiview *view; @property (readonly, nonatomic) uiedgeinsets insets; @property (nonatomic, strong) uiimage *avatar; - (id)initwithtext:(nsstring *)text date:(nsdate *)date type: (nsbubbletype)type; + (id)datawithtext:(nsstring *)text date:(nsdate *)date type:(nsbubbletype)type; - (id)initwithimage:(uiimage *)image date:(nsdate *)date type:(nsbubbletype)type; + (id)datawithimage:(uiimage *)image date:(nsdate *)date type: (nsbubbletype)type; - (id)initwithview:(uiview *)view date:(nsdate *)date type:(nsbubbletype)type insets:(uiedgeinsets)insets; + (id)datawithview:(uiview *)view date:(nsdate *)date type:(nsbubbletype)type insets:(uiedgeinsets)insets; below object , .m

angularjs - Ionic go to new view with same state -

i creating view of files in ionic app. explorer in computer, displays directories , files , can click on directories view other directories , files inside itself. to achieve this, have state 'menu.files' (cause have menu navigation) takes path in parameter. so, part of code: in view: <div ng-repeat="file in files" style="..." ng-click="openpath(file)"> in controller: $scope.openpath = function(path) { console.log(path); $state.transitionto("menu.files", { path: $scope.path + "/" + newpath }); } the problem: the view reloading stays on same view... i mean, in top-left there no back-arrow, previous view 'replaced'. want have same behavior of when make $stage.go() view, stack in navigation , user can go back. thanks in advance !

java - Integrate a finished web service in a Android application -

i don't know if correct term "integrate" or "connect" finished web service in android application. mean, is there possibility "integrate" finished restful web service in android application, have not developed, yet.? otherwise, are there steps develop restful web service need use android application? the last question asked because don't know if first step finish restful web service , integrate in android application or or developing restful web service , android application @ same time. in case, how can well ? need organise mind you need 3 things: client(your app) server database lets have create login service app. steps should given below: create login form android ui. get username , password edit texts in strings. send these credentials server(via http reqest). at client side read response url via input stream. at server side, use server side technology in familiar with.(if not familiar server side tech.

gis - Plot specific point data on each layer in stack with rasterVis in R -

i have 2 rasters stacked together: library(rastervis) r1 <- raster(system.file("external/test.grd", package="raster")) r2 <- r1 / 2 r.stack <- stack(r1, r2) since highlight areas later each specific layer in stack, create 2 point datasets based on raster values: pts1 <- rastertopoints(r1, spatial=t) idx <- which(as.data.frame(pts1)[, 1] >= 400) pts1 <- pts1[idx, 1] pts2 <- rastertopoints(r2, spatial=t) idx <- which(as.data.frame(pts2)[, 1] >= 400) pts2 <- pts2[idx, 1] now, plot raster stack levelplot rastervis in r. overlay r1 pts1 , r2 pts2. however, add 1 point dataset, used both layers: levelplot(r.stack) + layer(sp.points(pts1, pch=20, cex=0.1, col="black")) how can use specific point datasets specific layers while still using raster stacks? i avoid making own subplot plotting each layer its' specific point dataset alone followed using print.trellis. tried it, result inferior compared levelplo

php - Convert string array to array -

unfortunately array saved in database string 'array ( [merid] => 00000 [acqid] => 2121 [orderid] => 94 [responsecode] => 1 [reasoncode] => 1 )' i want string converted array original.please as others have warned horrible idea store data need use in format (is var_dump?). if you're stuck data in format, work given string: $string = ('array ( [merid] => 00000 [acqid] => 2121 [orderid] => 94 [responsecode] => 1 [reasoncode] => 1 )'); $arrayonly = preg_match('!\(([^\)]+)\)!', $string, $match); $prepared = '$array = array(' . str_replace(['[', ']', "\n"], ['"','"', ","], trim($match[1])) . ');'; eval($prepared); //$array set array keep in mind mileage may vary, works specific instance may fail on multidimensional array strings. if have control of how data stored , want flexible array storage

ios - MPMediaQuery not showing name in cell text label -

i have playlist query shows playlists, , supposed print them text label in cell. however, don't see text displayed on cell. i have nslog shows playlist name. help? code follows. - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath]; mpmediaquery *myplaylistsquery = [mpmediaquery playlistsquery]; nsarray *playlists = [myplaylistsquery collections]; mpmediaitem *rowitem = [[playlists objectatindex:indexpath.row] representativeitem]; cell.textlabel.text = [rowitem valueforproperty:mpmediaplaylistpropertyname]; (mpmediaplaylist *playlist in playlists) { nslog (@"%@", [playlist valueforproperty: mpmediaplaylistpropertyname]); } return cell; } any guesses why cells aren't showing n

javascript - setInterval doesn't work on .css method (no looping) -

i'm using setinterval try rotate image every 3 seconds , using below code: jquery: $(document).ready(function(){ setinterval(function(){ $bird_wing_left.css({ transform: "rotate(30deg)" }, 1000) }, 3000); }); css: .bird_wing_left { background: rgba(0, 0, 0, 0) url("../images/bird_wing_left.png") repeat scroll 0 0; height: 59px; left: 17px; position: absolute; top: 66px; width: 78px; transition: 2s; } ...but animation happens once , not every 3 seconds. if try method (not .css), it's ok. issue? it's rotating to 30 degrees, not by 30 degrees. need keep track of how far it's rotated: $(document).ready(function(){ var rotate = 0; setinterval(function(){ rotate += 30; $bird_wing_left.css({ transform: "rotate(" + rotate + "deg)" }, 1000) }, 3000); });

c - Libftdi usb_open() failed -

i’m working on project using iridium ptt. iridium hardware hooks satellite, , pc via usb. the iridium hardware came software runs on ubuntu linux, runs in virtual box on pc. software written in c , runs in ubuntu. develop on windows, using visual studios. the ubuntu version uses libftdi , libusb (from intra2net) talk hardware. we got libftdi, libusb , created project in visual studios 2013 desktop express edition. (i downloaded zadig windows check make sure had right usb drivers. verified arrow driver green usb connections hardware.) when iridium hardware connected computer 4 serial ports appear in device manager. i’m attempting open 1 of serial ports windows when run program. error when try open 1 (even though can open ubuntu, running in virtual box, on same pc). i'm using sample code (from intra2net) called "simple.c" i’m running in visual studios. i’ve posted below: /* simple.c simple libftdi usage example program distributed under gpl, ve

javascript - How To get Facebook Follower using Graph Api and Graph Secret? -

i used graph api , graph secret , full friends list facebook. how followers facebook using graph api , secret ? idea it? previous have using friend list using php sdk? please 1 guide me? how facebook using graph api , secret ? please refer facebook docs before posting such broad question. you're not able subscribers anymore, because deprecated graph api v2.0. furthermore, starting v2.0 you'll not able friends of user anymore, using app. additionally, never possible app access token write, user access token. see https://developers.facebook.com/docs/apps/changelog#v2_0 /me/subscribers , /me/subscribedto have been removed. the /me/friends endpoint no longer includes full list of person's friends. instead, returns list of person's friends using app.

Qt, set individual matrix elements of QTransform -

is there way set the m_ij elements individualy in qtransform without redefining whole matrix ? (e.g. reseting translation part) you'd use rotate , scale , shear , translate operations indirectly change relevant elements. if want change translation, can kinds of transforms. void settranslation(qtransform & t, qreal x, qreal y) { q_assert(t.type() != qtransform::txrotate && t.type() != qtransform::txshear && t.type() != qtransform::txproject); x -= t.m31() / m11(); y -= t.m32() / m22(); t.translate(x, y); } you have understand, though, elements interact , "translation" set may not act way think will.

javascript - ajax POST handler looping -

i'm trying setup basic ajax submit handler modify form (i'm writing lesson on csrf vulnerabilities), page keeps looping. here's example code i've been tinkering with, based off http://api.jquery.com/jquery.post/ : <!doctype html> <html> <body> <form id="hidden_form" target="blahblah.com"> </form> <script> //attach submit handler form $( '#hidden_form' ).submit(function( event ) { //stop form submitting event.preventdefault(); //set new target form var $form = $( ), url = "http://192.168.101.250/mutillidae/index.php?page=add-to-your-blog.php&csrf-token=securityisdisabled&blog_entry=example+text&add-to-your-blog-php-submit-button=save+blog+entry" //capture response nothing var posting = $.post( url ); }); </script> <script> $( '#hidden_form' ).submit(); </script> </body> </html&

javascript - uv_queue_work does not run callback_method in node addon (c++) -

i making node addon in c++, , want able make callbacks other threads. try it, i'm making following test using uv_queue_work , nan. if call function hello, should start new thread method firstmethod, , when finishes, call next method "callbackmethod" in thread, make callback javascript. reason, runs first method , not run second. this code. void hello(const v8::functioncallbackinfo<v8::value>& args) { v8::isolate* isolate = v8::isolate::getcurrent(); v8::handlescope scope(isolate); v8::local<v8::function> callback; callback = args[0].as<v8::function>(); listbaton* baton = new listbaton(); baton->callback = new nan::callback(callback); uv_work_t* req = new uv_work_t(); req->data = baton; uv_queue_work(uv_default_loop(), req, firstmethod, callbackmethod); } void firstmethod(uv_work_t* req) { std::cout << "entering pre thread" << std::endl; sleep(1); std::cout <&l

c# - Change main class attributes from Thread -

i'm looking answer long, haven't find answer how should communication between threads/main thread , run-time created threads like. had problem in java , comes in c#. let's write c# application, has form simple text label , want run thread(s) increments numeric value written in label. i'm creating main class form, , thread's class. i'm creating new object of thread's class in main class , starting thread on it. how can change text of label defined in main? so if understand correctly, you're asking how change gui thread. this done through construct called synchronizationcontext , provides way run code on thread. in case, if wanted change text of label defined in gui thread, take synchronizationcontext corresponding gui thread , post code through other thread. another concept have familiar tasks. task abstraction that's functionally same thing thread. 2 tasks can run @ same time. task.run starts new task workload represented fun

java - How to store Flyway H2 migrations' history in another schema than PUBLIC? -

using flyway h2 database, out of box sql schema migrations history stored in public.schema_version . i store table in dedicated sql schema flyway , this: flyway.history . reasons doing not pollute h2 console visually when opening public tables, , avoid namespace collision. by modifying property flyway.table , name history table can changed. but using flyway.table=flyway.history not work. schema flyway not created , table public.'flyway.history' gets created instead. how should 1 tweak flyway configuration in order achieve expected result? providing property solves problem partially: flyway.schemas=flyway,public . by doing so, history table stored in schema flyway migrations run default on schema. please refer http://flywaydb.org/documentation/commandline/migrate.html , schemas more details. i found 2 issues approach, can fixed minor tweaks. 1st issue: the schema flyway must existing before flyway migration attempt. can done in java using stm

angularjs - Update the model and selected option of a select that is generated using ng-options -

unfortunately i'm going round in circle trying work out - appreciated. i update model , selected option of select generated using ng-options. here values options: var blahoptionvalues = [ {valueformodel: '1', optiontext: 'a'}, {valueformodel: '2', optiontext: 'b'}, {valueformodel: '3', optiontext: 'c'}, ] here view: <select ng-model="blahmodel" ng-options="item.valueformodel item.optiontext item in blahoptionvalues"></select> as result of event, how update "blahmodel" relevant value? update selected value in view well? yes, update view well. please check demo in plunker: link: http://plnkr.co/edit/7xvrn7gmfkrjs7e4fvuh?p=preview ` var app = angular.module('myapp', []); app.controller('myctrl', function($scope) { $scope.blahoptionvalues = [ {valueformodel: '1', optiontext: 'a'}, {valueformodel: '2', op

How to import animations into Blender? -

i'm trying import js file blending animations blender (v2.65) using three.js (r66) importer, seems importer plug-in not working properly, because nothing shown in scene. tried convert js obj file , import blender, mesh imported, blending animations not imported. can me please? neither blender three.js json importer nor obj file format support animations.

java - How do I construct a JFrame child class? -

i'm trying make child class jframe . think im doing correctly when run opens blank window without name or background color (my jpanel class background. however, know error not there because commented out add( jpanel ) , window still didn't have name) eclipse doesn't show syntax errors. why doesn't code work?: main class: package ashwin.engine; import javax.swing.*; import java.awt.*; public class execute { public static void main(string[] args) { swingutilities.invokelater(new runnable(){ @override public void run() { int[] bcolor = new int[3]; bcolor[0] = 254; bcolor[1] = 0; bcolor[2] = 0; window wndw = new window("test", 1000, 1000, bcolor, true); } }); } } jframe child class: package ashwin.engine; import javax.swing.*; import java.awt.*; public class window extends jframe { window(string name, int wid

excel - Power Query: transform a column by multiplying by another column -

i want similar power query transform column based on column , i'm getting stuck on how modify syntax particular goal. similar linked question, assume have following table: table 1: column | column b | column c ------------------------------ 1 | 4 | 7 2 | 5 | 8 3 | 6 | 9 instead of changing value of column conditional on column b, want multiply values in multiple columns (column b , column c) in column , replace values in initial columns can following: table 1: column | column b | column c ------------------------------ 1 | 4 | 7 2 | 10 | 16 3 | 18 | 27 is possible without using multiple sequences of table.addcolumn followed table.removecolumns ? i have tried table.transformcolumns based on this , not been able syntax right achieve this. table.transformcolumns won't give column a unless can index table, possible if columns have unique data. table.transformrows let bu

spring - How to autowire a service and a repository together -

i have fix following error. can help severe: standardwrapper.throwable org.springframework.beans.factory.beancreationexception: error creating bean name 'searchcontroller': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire method: public void com.website.dev.controller.searchcontroller.setrecordingservice(com.website.dev.service.recordingservice); nested exception org.springframework.beans.factory.nosuchbeandefinitionexception: no qualifying bean of type [com.website.dev.service.recordingservice] found dependency: expected @ least 1 bean qualifies autowire candidate dependency. dependency annotations: {} @controller public class searchcontroller { private recordingservice recordingservice; @autowired public void setrecordingservice(recordingservice recordingservice) { this.recordingservice = recordingservice; } @requestmapping("/

How to create a QR code for my existing android application? -

i want create qr code existing android application (built in android studio). need id's end & generate qr code view in layout. please me. here of sample codes, can refer, values may different depend on mobile phone model. hope help! use zxing library. private void startscan(context context, string parameter) { intent intent = new intent(); intent.setaction("com.motorolasolutions.emdk.datawedge.api.action_softscantrigger"); intent.putextra("com.motorolasolutions.emdk.datawedge.api.extra_parameter", parameter); context.sendbroadcast(intent); } @override public boolean onkeyup(int keycode, @nonnull keyevent event) { if ((event.getaction() == keyevent.action_up) && keycode == keyevent.keycode_...) { startscan(this, "start_scanning"); registerreceiver(new broadcastreceiver() { @override public void onreceive(context

python - Negative integer division surprising result -

in application encountered following , surprised results: 8/-7=-2 (both integers). what means? for actual values, i.e. 8.0/(-7.0) , result -1.143 . your result using integer division being rounded down toward more negative value of -2 . (this known "floor division") this why perplexing answers of: >>> 8/(-7) -2 >>> 8/7 1 note: "fixed" in python 3, result of 8/(-7) -1.143 . if have no reason using python 2, should upgrade. ;) in python 3, if still want integer division, can use // operator. give same answer 8/(-7) in python 2. here's python enhancement proposal on subject: pep 238 -- changing division operator

ios - How to add Label on Bar Button Item? -

Image
i have uibarbuttonitem taken using interface builder. its outlet taken follow : { iboutlet uibarbuttonitem *itemnext, *itemprevious, *itemsubmit; } so in storyboard looks following image. now, question how can add uilabel before rightbarbuttonitem item ? note : uibarbuttonitem not on navigationcontroller set on bottom of screen shown in image. i unable drag , drop uilabel on uibarbuttonitem can suggest me how can that? uilabel can added subview uitoolbar or uinavigationbar . you can add uibaritem . use settitletextattributes:forstate: on uibaritem attributed string properties similar uilabel .

azure application insights - Uncaught TypeError: n.Telemetry.PageViewPerformance.checkPageLoad is not a function -

all our microsoft datazen servers seeing infine loop of client side javascript exceptions: uncaught typeerror: n.telemetry.pageviewperformance.checkpageload not function since script comes http://az416426.vo.msecnd.net/scripts/a/ai.0.js issue may app insights cloud service. as experienced this? interesting - there refactoring 'checkpageload' split 2 other functions ( https://github.com/microsoft/applicationinsights-js/commit/da50064bfc6537fe7efe78ef1f5b048636f85070#diff-e25ffb54668c8e8794fb7224dbfadafbl112 ) don't see issues - usages of checkpageload corrected accordingly. intermittent issue or still reproducing? have custom code calling appinsights script, or it's snippet injected page?

list - Creating data frame in R using variable -

i have 2 data types price of type list , company of type character price [[1]] [1] "rp 83.000" [[2]] [1] "rp 87.900" [[3]] [1] "rp92,000" [[4]] [1] "regular price 125,000.00 discount price 125,000.00 " and company [1] "tororo" "babyzania" "bilna" "babylonish" i want create data frame using 2 data types , of form : tororo rp 83.00 babyzania rp 87.900 bilna rp 92,00 babylonish regular price 125,000.00 discount price 125,000.00 can me out tried using directly df=data.frame(company,price) but not giving correct dataframe want. if list same length , in same order company name vector can this df = data.frame(company, unlist(price)) your 4th price different top 3 wont printed anyway.

optimization - R programming: how to choose a combination of a factor with varying numbers, with constraints and then optimize? -

i want every combination of team price < x data format looks like: position name salary gameinfo avgpointspergame 1 wr julio jones 9300 phi@atl 07:10pm et 21.293 2 wr odell beckham jr. 9200 nyg@dal 08:30pm et 26.417 3 wr demaryius thomas 9100 bal@den 04:25pm et 22.812 4 wr dez bryant 8700 nyg@dal 08:30pm et 19.033 5 qb aaron rodgers 8600 gb@chi 01:00pm et 23.428 6 wr calvin johnson 8500 det@sd 04:05pm et 18.229 let's team consist of 1 qb, 3 wr, 2rb, , flx. there package me select these combinations data set? or perhaps ideas should into. want direction not solution. i thinking optimization constraints correct way going this, honest have no idea. the constraints this. #constraint 1 #price of team < 50,000 max_price >= 50000 #constraint 2 #1qb #constraint 3 #2rb #rb1!=rb2 #constr

jasmine - Find component using CSS selector in TestUtils -

i'm writing simple tests react components using testutils , i'm finding both testutils.findrendereddomcomponentwithclass , testutils.findrendereddomcomponentwithtag methods pretty limiting . i'd find component using typical css selector (i.e. tag.class [attr] ) doesn't seem option. is there simple way find element specific attribute? if not there useful tools finding components apart testutils ? i find useful use browser's element.queryselector()/queryselectorall() method on dom elements. you can call example this: var domelement = findrendereddomcomponentwithclass('myclass'); var firsttextinput = domelement.queryselector('input[type="text"]');

java - Is it ever justified to have an object which has itself as a field? -

is ever justified have object has field : class thing { thing field; public thing() { this.field = this; } } i'm not talking class field of same type class made every instance of class has field. saw in legacy code (this field never used) i'm curious. legit use of ? yes, though rare. used in jdk situations field this might not be. from class implements collections.synchronizedcollection(c) static class synchronizedcollection<e> implements collection<e>, serializable { private static final long serialversionuid = 3053995032091335093l; final collection<e> c; // backing collection final object mutex; // object on synchronize synchronizedcollection(collection<e> c) { this.c = objects.requirenonnull(c); mutex = this; } synchronizedcollection(collection<e> c, object mutex) { this.c = objects.requirenonnull(c); this.mutex = objects.requirenonnull(mu

tortoisehg - how to rollback a branch merge in mercurial -

Image
i have merged development branch production mistake. haven't made public, please let me know how can revert merge ? using tortoisehg workbench. you can strip commit did merge, assuming it's last one. right-click, modify history -> strip. if it's more complex that, post more detail (e.g. screenshot of graph) , i'll try help.

javascript - Is there any plugin for calendar that can be shown up without any event -

i want show calendar @ top of page. googled , got results of them shown after events such 'click', 'mousemove' , etc. i want find plugin can satisfied following requirements. it can show while document ready , not disppear it has api of listening click event (click day or change month,year) btw: don't need calendar google calendar you can use jquery datepicker https://jqueryui.com/datepicker/

forms - jquery mobile + cordova get photo and post via php mail -

i using jquery mobile 1.4.5 , cordova mobile app. currently want send via php mail service photo taken user or photo photo gallery. so far js cordova api: var picturesource; // picture source var destinationtype; // sets format of returned value // wait device api libraries load // document.addeventlistener("deviceready",ondeviceready,false); // device apis available // function ondeviceready() { picturesource=navigator.camera.picturesourcetype; destinationtype=navigator.camera.destinationtype; } // called when photo retrieved // function onphotodatasuccess(imagedata) { // uncomment view base64-encoded image data // console.log(imagedata); // image handle // var smallimage = document.getelementbyid('smallimage'); // unhide image elements // smallimage.style.display = 'block'; // show captured photo // in-line css rules used resize image // smallimage.src = "data:image/jpeg;base64," + imagedata; }

mercurial graft feature, can it copy? -

there new feature in mercurial 3, called 'graft' (graft local). job of moving change-set different branch. is there way "copy" change-set branch? i interested in in moving stuff qa branch production branch, still need code reside in qa. want copy. found , have tried few things, maybe it'll become clear more tinkering , reading... does have better way of 'cherry picking' change-sets move cross branch (or trunk)??? graft copies changesets, doesn't move them. hg graft (emphasis mine): this command uses mercurial's merge logic copy individual changes other branches without merging branches in history graph. known 'backporting' or 'cherry-picking' . default, graft copy user, date, , description source changesets.

mysql - Using php mt_rand() function -

am trying use php mt_rand() function produce me unique number used unique identifier row in database. can pick number had picked range 1, 1000000. code follows echo mt_rand(1, 1000000);?> continued help yes, produce duplicates. it's random, not unique. easiest solution use auto-increment column. if don't want sequential, have couple options. these 2 @ first: https://github.com/ramsey/uuid http://php.net/manual/en/function.uniqid.php

if statement - Software Engineering: Conditionals evaluate "good" or "bad" order -

this question has answer here: best practice on if/else statement order 10 answers i remember reading in software engineering book once there typical rule follow when writing if else conditional statements order of evaluation. should valid case evaluated first followed invalid / erroneous case or vice versa? there proper order cases should evaluated first? example: if (good) { // exec block of code case. } else { // bad case. } or if (errorcase1) { // errorcase1 block. } else if (errorcase2) { // errorcase2 block. } else { // case. } no fixed rule such heard usage follow this if(usual) { (more often) } else (unusual) { (rarely occurring) } but if both have same function different properties better go unusual first usual can save 1 instruction. if(x == 0) // 1 {x = 1;} // 2 else {x = 2;} // 3

apache - Passenger Rails url prefix causing no route matches -

Image
i have rails application rooted inside folder called convergeops. phusion passenger setup serve passengerbaseuri /convergeops . 80% of time, works fine, every , no route matches error shown below: httpd.conf file documentroot "/var/www/html/convergeops/public" <directory "/var/www/html/convergeops"> railsenv production passengerbaseuri /convergeops passengerapproot /var/www/html/convergeops setenv rails_relative_url_root /convergeops passengerfriendlyerrorpages on allowoverride allow options -multiviews require granted </directory> any idea why might getting routing error?

php - How do I fetch Google Plus share count using cURL multi? -

i found following function i've been able use collect , cache share counts on various social networks. far, can feed twitter, linkedin, facebook, , pinterest url's in array function , kick response can parse , count from. in effort speed process, found process uses curl multi fetch shares @ same time instead of processing 1 request @ time. however, curl had been using google plus has lot more configuration in order make work. possible configuration function it's looping through requests, if sees google plus, adds of information specific request, still runs request simultaneously others? here's curl multi function i'm using: function sw_fetch_shares_via_curl_multi($data, $options = array()) { // array of curl handles $curly = array(); // data returned $result = array(); // multi handle $mh = curl_multi_init(); // loop through $data , create curl handles // add them multi-handle foreach ($data $id => $d) { $curly[$id] = curl_in

Allowing *.html pages to execute PHP script -

i understand there lot of seemingly same questions on here. have tried given solutions in answers find still no succes. i have microsoft 2012 r2 server running iis 8.5. because old website using .htaccess installed helicon ape still make use of .htaccess. seems run good. tested adding .htaccess file: rewriteengine on rewriterule ^test\.html http://www.google.com/? [r=301,l] whenever open test.html file redirect me google guess working fine. now tried add following line .htaccess: addtype application/x-httpd-php .html .htm and after failed tried following line: addtype application/x-httpd-php5 .html .htm still no succes. after tried let fastcgi handler process html files. nothing changed. last not least have tried use server side includes video: youtube video still didn't work. have .htaccess file in root folder. there other options try?

Rails rollback when creating user with nested forms -

i'm getting rollback when trying add user db , i'm not sure why. i have 3 models: company.rb class company < activerecord::base acts_as_paranoid has_many :locations, dependent: :destroy has_many :users, dependent: :destroy has_many :tests, through: :locations has_many :reports, dependent: :destroy accepts_nested_attributes_for :locations, :users validates_presence_of :name end ** user.rb ** class user < activerecord::base acts_as_paranoid devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :registerable belongs_to :company has_and_belongs_to_many :roles end ** location.rb ** class location < activerecord::base acts_as_paranoid belongs_to :company has_many :network_hosts, dependent: :destroy has_many :tests, dependent: :destroy has_many :commands, dependent: :destroy validates_presence_of :company, :identifier, :name validates_uniqueness_of :identifier delegate