Posts

Showing posts from June, 2014

ember.js - Ember get current url in RESTadapter -

using ember 1.13.2 ember data 1.13.4 in conjunction rails backend. trying implement hmac authentication ember , ember data (restadapter) class authhelper authheader: (adapter)-> ... frontend.applicationadapter = ds.restadapter.extend( headers: (-> 'authorization': new authhelper().authheader(@) ).property().volatile()) for need url request going send to. how can url? or need construct manually collecting host , pluralized models name? get params ? update i able accomplish following code: ember.$.ajaxprefilter (options, oriopt, jqxhr) -> authheader = authhelper.authheader(options.url) jqxhr.setrequestheader("authorization", authheader) return the complete solution can found here: https://github.com/psunix/js-frameworks-api-auth maybe knows more ember way doing this.

javascript - would minimongo cache across subscriptions? -

if have subscription inside tracker.autorun() , publish takes variable selector, means every time, return may vary, minimongo cache docs returned publications? or each time, clears documents , preserve returned docs previous publication? meteor clever enough keep track of current document set each client has each publisher. when publisher reruns, knows send difference between sets. let's use following sequence example: subscribe posts: a,b,c rerun subscription posts b,c,d server sends removed message a , added message d . note not happen if stopped subscription prior rerunning it.

java - How can we put value on text field on output screen? -

i want put value in txtf1 @ output screen , it. how can put value on text field on output screen? import java.awt.color; import java.awt.textfield; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.jframe; import javax.swing.jpanel; import javax.swing.jtextfield; import javax.swing.swingconstants; public class demog extends jpanel implements actionlistener{ private textfield textf, txtf1; public void jhand(){ textf = new textfield(); textf.setsize(40, 40); textf.settext("20"); textf.seteditable(false); textf.setbackground(color.white); textf.setforeground(color.black); //textf.sethorizontalalignment(swingconstants.center); textf.setlocation(15, 15); //textf.addactionlistener(this); txtf1 = new textfield(); txtf1.setsize(40, 40); txtf1.gettext(); txtf1.seteditable(false); txtf1.setbackground(color.white); txtf1.setforeground(color.black); //txtf1.sethorizontalalignm...

C# LINQ GroupBy with NULL values -

i have object dates: class myobj { public datetime? date {get; set;} } as can see date nullable. possible use linq 's groupby method group list<myobj> dates including null s? to like: {elements_with_date_1, elements_with_date_2, ..., elements_with_no_date} ? the groupby -method extension-method, means static method accepts date parameter. written listwithnulls.groupby() treated groupby(listwithnulls) . because of behavior, null -values can handled , don't nullreferenceexception . have @ extension-methods definition. helps understand how can work them: public static ienumerable<igrouping<tkey, tsource>> groupby<tsource, tkey>(this ienumerable<tsource> source, func<tsource, tkey> keyselector); you can see first argument written this ienumerable<tsource> source , enables short-handle source.groupby() .

plugins - Neo4j server won't create data/log dir and files -

working neo4j server win service plugin extension. server not creating log files (which should found under data\log) , can't see why. went through conf files , fine. in app i'm writing logs via java.util.logging.logger instructed in documentation , suggested here: how can log neo4j server plugin? did had similar experience or can direct me solution? p.s plugin extension works fine. thank you.

node.js - Passing/Comparing by reference for javascript objects -

i'm trying compare 2 objects. use socket.io send nodes object client. my server.js goes: var nodes = {'101':{id:'101',x:100,y:200}, '102':{id:'102',x:200,y:200}}; socket.emit('message', nodes); in client, i'd create copy of object nodes first time receives. save variable oldnodes , next time socket receives nodes object, comparison oldnodes , output property has been changed. e.g., if receives var nodes = {'101':{id:'101',x:100,y:200},'102':{id:'102',x:200,y:300}}; , should print(console.log) nodes[102].y changed . client.html : socket.on('message', function(nodes){ if (oldnodes == undefined){ var oldnodes = nodes; } else{ //compare oldnodes & nodes //print result } }); for copying, var oldnodes = nodes; not want since javascript passes objects reference. so, if oldnodes & nodes have same content, (oldnodes == nodes) ...

Sending a File from a Python script to a PHP Script using POST deployed on Xampp Server -

i trying send file (may txt, pdf, xls or docx) python script php script. deployed on xampp server. far have tried several methods, no luck. python script im using send file: url = 'http://192.168.1.8:80/testfile.php' files = {'file': open('expected.txt', 'rb')} r= requests.post(url, files=files) i have tried urllib : f=open(filename, 'rb') filebody = f.read() f.close() data = {'name':'file','file': filebody} u = urllib.urlopen(url,urllib.urlencode(data)) print u.read(). both giving same error undefined index: filetoupload in c:\xampp\htdocs\testfile.php on line 16 this php code posted on other end receive file python script $target_dir = "uploads/"; $target_file = $target_dir . basename($_files["filetoupload"]["name"]); $uploadok = 1; $imagefiletype = pathinfo($target_file,pathinfo_extension); // check if image file actual image or fake image if(isset($_post["subm...

javascript - Flyout hide himself on list view iteminvoked event -

if invoke flyout show function on iteminvoked event. flyout automatically hide himself in fraction of second. here code <div id="listview" class="win-selectionstylefilled" data-win-control="winjs.ui.listview" data-win-options="{ itemdatasource: teoco.listview.data.datasource, itemtemplate: select('.settingstemplate'), selectionmode: 'single', tapbehavior: 'directselect', oniteminvoked : name.listview.selectionchanged, layout: { type: winjs.ui.listlayout } }"> </div> <div id="contactflyout" data-win-control="winjs.ui.flyout"> </div> settings.settingsmodules = (new function(){ function selectioneventhandler(evt){ var settingslist = evt.target; evt.detail.itempromise.then(function (invokeditem) { var flyout = document.getelementbyid("contactflyout"...

How to use multiple Git SSH keys on Eclipse? -

i looked several answers , forums solution not find single 1 works. i have scenario: eclipse luna service release 2 (4.4.2) ubuntu 14.04 x64 two ssh keys on ~/.ssh folder two bitbucket accounts (one personal projects , 1 enterprise) a git repository accessible primary key (~/.ssh/id_rsa) a git repository accessible secondary key (~/.ssh/other) i created ~/.ssh/config file contents: host bitbucket bitbucket.org hostname bitbucket.org identityfile ~/.ssh/id_rsa identityfile ~/.ssh/other user git and sake of sanity added second key using ssh-add well. running ssh-add -l lists both keys. when using command line, git commands work charm, both repositories. when using eclipse, invalid remote: origin error when trying clone or pull repository secondary key: caused by: org.eclipse.jgit.errors.noremoterepositoryexception: git@bitbucket.org:myuser/myrepository.git: conq: repository access denied. i added secondary key @ window > preferences >...

XFS CEN not update printer status of ATM -

i want atm journal printer status using wfsgetinfo() xf api function. returns status not updated. hresult resultexec= wfsgetinfo( hser,wfs_inf_ptr_status,null,wfs_indefinite_wait,&lp); printf("\n printer result deviceasync===> %d \n", ((lpwfsptrstatus)lp->lpbuffer)->fwdevice); switch(((lpwfsptrstatus)lp->lpbuffer)->fwdevice) { case wfs_ptr_devonline : printf("\n printer result wfs_ptr_devonline : device online. \n"); break; case wfs_stat_devhwerror: printf("\n printer result wfs_stat_devhwerror : device inoperable due hardware error.\n"); break; case wfs_ptr_devnodevice: printf("\n printer result wfs_ptr_devnodevice : there no device intended there; e.g. type of self service machine not contain such device or internally not configured.\n"); break; case wfs_ptr_devoffline: ...

android - manage fade in animation of listitems with onScrollStateChanged for a listview -

animate listview items fade-in animation, onscrollstatechanged , i have been trying out below code layoutanimationcontroller controller = animationutils.loadlayoutanimation( this, r.anim.anim2); getlistview().setlayoutanimation(controller); getlistview().setonscrolllistener(new onscrolllistener(){ public void onscroll(abslistview view, int firstvisibleitem, int visibleitemcount, int totalitemcount) { // todo auto-generated method stub } public void onscrollstatechanged(abslistview view, int scrollstate) { // todo auto-generated method stub if(scrollstate == 0) { layoutanimationcontroller controller = animationutils.loadlayoutanimation( mainactivity.this, r.anim.anim2); getlistview().setlayoutanimation(controller); } } }); } how works when load ...

c# - WCF certificate authentication -

while implementiong wcf security using certificate, facing below mentioned error. secure channel cannot opened because security negotiation remote endpoint has failed. may due absent or incorrectly specified endpointidentity in endpointaddress used create channel. i have put certificates in trusted people. it looks identity problem , have tried setting identity both in service , client config still didn't work. below configuration details. service configuration <bindings> <wshttpbinding> <binding name="wshttp"> <security mode="message"> <message clientcredentialtype="certificate" /> </security> </binding> </wshttpbinding> </bindings> <service name="wcfcertificateauth.service1"> <endpoint address="" binding="wshttpbinding" bindingconfiguration="" bindingn...

shiny - Reactive input to ggvis in R-markdown cause quit -

i'm trying use r-markdown shiny interactive visualization. file let user specify bunch of data files , use reactive shiny expression processed dataframe, data() . can use data() renderplot correctly plot out bunch of graphs(like heatmap.2 , plot ). however, when try using ggvis plot reactive data, generation of html quit @ ggvis code chunk. tried answer how data passed reactive shiny expression ggvis plot? . both of 2 methods in answer led "quitting lines". here's code: reactive({ data %>% ggvis(~pcomp, ~variances) %>% layer_points()%>% layer_bars(fill := "gray", opacity := 0.5) %>% layer_lines() }) %>% bind_shiny("plot1") ggvisoutput("plot1") here's code based on other method: data %>% ggvis(~pcomp, ~variances) %>% layer_points()%>% layer_bars(fill := "gray", opacity := 0.5) %>% layer_lines() i'm using r-studio version 0.99.441, r version 3.2.1 (20...

ios - Multiple storyboards in Swift -

i have app has 4 storyboards, each different device (iphone4, 5, 6, 6+). have tried use auto constraints since app complicated, wasn't able figure out. have heard if have multiple storyboards there should way of specifying storyboard use in app delegate. how go specifying proper storyboard proper device in app delegate? have 4 storyboards, named: iphone4s.storyboard iphone5.storyboard iphone6.storyboard iphone6plus.storyboard thank you. implement function retrieves storyboard when it's name specified. func getstoryboard(name : string)-> uistoryboard { var storyboard = uistoryboard(name: name, bundle: nil); return storyboard; } change app delegate method like: func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool { var storyboard = getstoryboard("main") // change storyboard name based on device, may need write condition here var initialviewcontroller...

How to use random () function to shuffle array in PHP -

in 1 interview asked shuffle associative array has value . $card = array ( "car"=>1, "bus"=>2, "truck"=>3, ); etc. using radom function generate random digit between 0,1 ; they asked me not use inbuilt php function . input: associative array; output: randomly sequenced associative array; thanks & regards the built-in shuffle() doesn't handle associative arrays well, you'd need shuffle array keys , reconstitute array again. i'm using fisher-yates-knuth algorithm perform shuffling, crux of solution. function myshuffle($arr) { // extract array keys $keys = []; foreach ($arr $key => $value) { $keys[] = $key; } // shuffle keys ($i = count($keys) - 1; $i >= 1; --$i) { $r = mt_rand(0, $i); if ($r != $i) { $tmp = $keys[$i]; $keys[$i] = $keys[$r]; $keys[$r] = $tmp; ...

How can I allow JSSOR to use ng-repeats in AngularJS? -

i'm pretty new angular game, , have been trying integrate jssor slider webpage utilize angularjs's ng-repeat feature using custom directive. far, have tested in devtools , cannot find errors in console when load page slider on it, , paused loaded make sure of images loading in ng-repeat have hoped, jssor displays first picture in strange position compared should , doesn't have animation. know app, directives, , controllers doing they're supposed to, i'm guessing it's in how jssor finds div img's in it display that's tripping up. suggestions? html within jssor slideshow: <div class="slideshow"> <!-- slides container --> <div class="containpic" u="slides" style="display: block; cursor: move; position: absolute; left: 0px; top: 0px; width: 800px; overflow: hidden;"> <slider-pic></slider-pic> </div> </div> html slider-pic directive: <div ng...

How to Indicate a Nullable Value's Original Data Type in C# -

is there bool.null indicate boolean type's null value in c#? thanks boolean value-type. cannot equal null @ case. however, if nullable boolean , can directly compare null: bool? b = getbooleanfromsomewhere(); if (b == null) // null p.s. there no "boolean type's null value". classes not have "own null values". there null .

Android Service do not working -

my app follow next scenarios... 1.[main activity] thread repeat sleep(5000) if thread sleep(), startservice() 2.[service.class] sendbroadcast() 3.[main activity - broadcastreceiver] toast() thread working clean, service don't called. i register in manifest.xml and create broadcastreceiver dynamic. manifest.xml <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name=".mainactivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <service android:name=".service" android:enabl...

jQuery: How to add the attribute in $(this)? -

example have 10 textbox , each has same attribute different value, example have attribute data-same different value , have in code $('#test').each(function(){ $(this).val(); }); and want filter result using attribute of each textbox. how it? thinking on doing this $('#test').each(function(){ $('[data-same="val1"]',this).val(); }); but i'm not sure it. use attr() $('#test').each(function(){ var attributevalue = $(this).attr('data-same'); //do whatever want value }); also, code indicates have same id multiple elements. avoid , use classes or attributes instead. $('[data-same]').each(function(){ var attributevalue = $(this).attr('data-same'); //do whatever want value }); see why bad thing have multiple html elements same id attribute?

bash - Using Perl to replace a string in only a certain line of file -

i have script using large scale find , replace. when match found in particular file, record file name, , line number. what want each file name, line number pair, change string <foo> <bar> on line of file. in shell script, executing find , replace command on file given line number... run=`perl -pi -e "s/$find/$replace/ if $. = $linenum" $file` this believe has been ignoring $. = $linenum , s/$find/$replace/ on whole file, bad. any ideas how can this? you using assignment = instead of comparison == . use: perl -pi -e "s/$find/$replace/ if $. == $linenum" $file where there caveats content of $find , $replace , $linenum aren't going problem. caveats issues such $find cannot contain slash; $replace can't contain slash either; $linenum needs line number; beware other extraneous characters confuse code. i don't see why you'd want capture standard output of perl process when writes file, not standard ou...

php - How to troubleshoot and get fopen()to work in php5? -

i've searched hard can, , have been stuck on seems such simple issue. i'm trying use fopen() in php create simple txt file. code follows: $myfile = fopen("text.txt", "w") or die("not working"); but no matter i've tried won't work. i use godaddy hosting; plesk on windows. allow_url_open on. , open_basedir set none . i've confirmed phpinfo() . i read somewhere perror can used, i've tried using in context , doesn't output anything: $myfile = fopen("text.txt", "w") or perror("error"); i have display_errors set on . i'm racking brain on else try. godaddy support useless. any advise on troubleshooting or else problem based off information helpful. thanks!

android - NullPointerException when setAdapter ListView in onPostExcute -

i create listview , set action loadmore when scrolling final item. listview works until scroll final item, action loadmore listview running. got error: 07-01 22:48:10.792: e/androidruntime(4691): java.lang.nullpointerexception 07-01 22:48:10.792: e/androidruntime(4691): @ android.widget.listview.clearrecycledstate(listview.java:516) 07-01 22:48:10.792: e/androidruntime(4691): @ android.widget.listview.resetlist(listview.java:503) 07-01 22:48:10.792: e/androidruntime(4691): @ android.widget.listview.setadapter(listview.java:445) 07-01 22:48:10.792: e/androidruntime(4691): @ com.example.mainactivity$1processdatatask.onpostexecute(mainactivity.java:192) 07-01 22:48:10.792: e/androidruntime(4691): @ com.example.mainactivity$1processdatatask.onpostexecute(mainactivity.java:1) 07-01 22:48:10.792: e/androidruntime(4691): @ android.os.asynctask.finish(asynctask.java:631) 07-01 22:48:10.792: e/androidruntime(4691): @ android.os.asynctask.access$600(asynctask...

javascript - Error: Cannot find module 'flux' -

i have js project requires other js files parent directory. here structure of project: web package.json ... core js ... here content of package.json { "name": "propertyfinder", "version": "0.0.1", "main": "js/app.js", "dependencies": { "flux": "^2.0.1", "keymirror": "~0.1.0", "object-assign": "^1.0.0", "react": "^0.12.0" }, "devdependencies": { "browserify": "^6.2.0", "envify": "^3.0.0", "reactify": "^0.15.2", "uglify-js": "~2.4.15", "watchify": "^2.1.1" }, "scripts": { "start": "watchify -o js/bundle.js -v -d app.js", "build": "browserify . -t [envify --node_env prod...

c++ - Undefined reference with Allegro 5 after updating MinGW to 64 (Windows 7, Code::Blocks) -

Image
i'm having "undefined reference" whole schmere, , setup (as seems). all libs linked (i mean, of them, it's impossible i've missed something): the headers included: and here's toolchain executables compiler (after change / update). i'm paranoid paths not have spaces anymore, , not work (it working mingw x86, full of bugs, string conversion not work, , whatever. installed on c:\mingw, it's installed in different path (the new one)). i've changed path environment variable accordingly. so, ideas? in toolchain executables wrong? (i've never set manually before). solved problem, returning buggy mingw x86 (reinstalling whole code::blocks mingw default, , erasing code::blocks .conf file in appdata). so, i'll have use buggy version of gcc because it's 1 "sees" allegro 5 (for reason, there's incompatibility. not find allegro functions).

separating string between commas into an array in c -

i want split string several strings stored in array (of strings). tried use strtok_r , couldn't work. tried doing using code: int r=0; int c=0; (int e=0;buf2[e]!=null;e++) { if (buf2[e]!=",") { monsters[i].types[c][r] = buf2[e]; r++; } else { r=0; c++; } } buf2 string i'm splitting, monsters[i].types[c] array of strings i'm splitting into. when this, gives me: in file included main.c:7:0: resource.h: in function ‘main’: resource.h:97:22: warning: comparison between pointer , integer [enabled default] (int e=0;buf2[e]!=null;e++) { ^ resource.h:98:14: warning: comparison between pointer , integer [enabled default] if (buf2[e]!=",") { ^ i tried putting ascii values instead of null & "," , , didn't give me warnings, didn't work. , there way include 2 variable declarations before for loop, next other int declaration? edit: so tried us...

javascript - Totaljs FrameworkWebSocket Client -

i use websockets send updates server clients. i know can use server sent events internet explorer doesn't have great compatibility prefer use websocket. the totaljs websocket allow me use client? i'm trying this: (totaljs websocket example) exports.install = function(framework) { framework.route('/'); framework.route('/send/', send_message); framework.websocket('/', socket_homepage, ['json']); }; function send_message() { var controller = this; var socket = new websocket('ws://127.0.0.1:8000/'); socket.onopen = function() { socket.send(encodeuricomponent(json.stringify({ message: "send_message" }))); }; socket.close(); socket = null; } function socket_homepage() { var controller = this; controller.on('open', function(client) { console.log('connect / online:', controller.online); client.send({ message: 'hello {0}'.format(c...

Android Filter a listview Attempt to invoke interface method 'int java.util.List.size()' on a null object reference -

my aim filter listview research, "whatsapp" when looking friend name. have error when try write inside search box appears if search icon pressed. this error: process: org.testing.an_app, pid: 15386 java.lang.nullpointerexception: attempt invoke interface method 'int java.util.list.size()' on null object reference @ android.widget.simpleadapter.getcount(simpleadapter.java:93) @ android.widget.adapterview.checkfocus(adapterview.java:717) @ android.widget.adapterview$adapterdatasetobserver.oninvalidated(adapterview.java:840) @ android.widget.abslistview$adapterdatasetobserver.oninvalidated(abslistview.java:6137) @ android.database.datasetobservable.notifyinvalidated(datasetobservable.java:50) @ android.widget.baseadapter.notifydatasetinvalidated(baseadapter.java:59) @ android.widget.simpleadapter$simplefilter.publishresults(simpleadapter.java:383) @ android.widget....

Passing Value from C++ to Javascript -

i have c++ file reads values sensor , want display values on website dynamically. im looking way pass these values(integers) cpp file javascript displays them on site. my first, simple try write values js file variables every second cpp script. js uses file source , displays variables on site: cpp: fprintf(file, "var mx=%d, my=%d, mz=%d, ax=%d, ay=%d, az=%d, gx=%d, gy=%d, gz=%d;\n", imu.raw_m[0], imu.raw_m[1], imu.raw_m[2], // m = magnetometer imu.raw_a[0], imu.raw_a[1], imu.raw_a[2], // = accelerometer imu.raw_g[0], imu.raw_g[1], imu.raw_g[2] // g = gyroscope ); html/js: <script src="./imu.js" type="text/javascript"></script> the problem of course, need refresh page time, because imu.js file cached website. i'd rather have way directly pass integers cpp file js script. read json or googles v8 script. i'd hear suggestions first. by way, im running on raspi, if important. thanks help ...

html - Can I make the browser window start at the bottom of the page? -

normally, when page loads, browser window starts @ top of html , body , this: ______________________________ | browser window browser window | | browser window browser window | | browser window browser window | | browser window browser window | | browser window browser window | | browser window browser window | _______________________________ ----- out-of-view content ----- ----- out-of-view content ----- ----- out-of-view content ----- ----- out-of-view content ----- ----- out-of-view content ----- ----- bottom of content ------- css html { height: 100%; max-height: auto; width: 100%; } body { height: 100%; min-width: 100%; position: relative; } and have scroll down see rest of content. is there way can manipulate css make browser window start @ bottom? this: ----- top of content ---------- ----- out-of-view content ----- ----- out-of-view content ----- ----- out-of-view content ----- ----- out-of-view content ----- ----- out-of-view conte...

php - Can't get to link so image using constants -

why can find image when use ? defined("prod_images") ? null : define("prod_images", realpath(dirname(__dir__) . "/public/images/")); $product_image = prod_images . $image; <img src="<?php echo prod_images; ?>" alt=""> please try: absolute path : <img src="http://www.yourdomain.com/images/<?php echo $image; ?>" alt=""> or relative website root : <img src="/images/<?php echo $image; ?>" alt="">

sql - Identify records with two identical values in two different columns? -

i have table of student id's, major1, major2 , minor. want identify records of students registered twice same major. need function select have same major "fin" in column major1 , major2. have far: create view a5t5 select (firstname || ' ' || lastname)"fullname", studentid "studentid", major1 "doubledipping" a5 group major1, major2 ????? having count ????? order major,lastname,firstname; i think you're making harder is. if understand question correctly following query should give you're looking for: select (firstname || ' ' || lastname) "fullname", studentid "studentid", major1 "doubledipping" a5 major1 = major2 if need function, usual way return result set return opened sys_refcursor caller responsible closing. example: create or replace function double_dipping_students return sys_refcursor csr sys_refcursor; begin open csr select (firstname ...

Why does array size have to be 3^k+1 for cycle leader iteration algorithm to work? -

the cycle leader iteration algorithm algorithm shuffling array moving even-numbered entries front , odd-numbered entries while preserving relative order. example, given input: a 1 b 2 c 3 d 4 e 5 the output be a b c d e 1 2 3 4 5 this algorithm runs in o(n) time , uses o(1) space. one unusual detail of algorithm works splitting array blocks of size 3 k +1. apparently critical algorithm work correctly, have no idea why is. why choice of 3 k + 1 necessary in algorithm? thanks! this going long answer. answer question isn't simple , requires number theory answer. i've spent half day working through algorithm , have answer, i'm not sure can describe succinctly. the short version: breaking input blocks of size 3 k + 1 breaks input apart blocks of size 3 k - 1 surrounded 2 elements not end moving. the remaining 3 k - 1 elements in block move according interesting pattern: each element moves position given dividing index 2 modulo 3 k . this p...

android java.io.File.fixSlashes(File.java:185) -

i got error in console crashes & anrs. error showing , couldn't find problem is. java.lang.nullpointerexception @ java.io.file.fixslashes(file.java:185) @ java.io.file.<init>(file.java:134) the function code save picture is: public static string sharephoto(context context, bitmap bmp) { file folder = new file(environment.getexternalstoragedirectory().getabsolutepath() + "/pictures/folder"); boolean success = true; string file_path = null; if (!folder.exists()) { success = folder.mkdir(); } if (success) { file_path = folder + "/img_" + system.currenttimemillis() / 1000 + ".jpg"; } outputstream os = null; try { os = new fileoutputstream(file_path); bmp.compress(bitmap.compressformat.jpeg, 100, os); } catch (ioexception e) { e.printstacktrace(); } } else { // else on failure } intent mediascanin...

javascript - Cached asynchronous Node.js objects, avoiding callback hell -

i've got express app relies on database stores json object used app's main configuration object. i'd cache object don't have keep going database up. however, i'd way invalidate cached object if new configuration object inserted database, , have app pick new object without restart. on top of that, i'd of without digging deep callbacks at outset, example of code (this contrived, don't worry db design or premise -- it's not real). assume users can assigned list of roles, stored in "config" object: // config.js var config; module.exports = function(cb) { if(config != null) { cb(config); } else { db.query('select data config', function(res) { config = json.parse(res.data); cb(config); }) } } // users.js var config = require('config'); var roles; config(function(data) { roles = data['user roles']; // cache roles lifetime of application, doesn't allow invalidation }); module.exp...

java - Box2D wrong body rotation -

Image
i making map tiled , load box2d bodies box2dmapobjectparser world , work fine except 1 thing. i'm using newer version of tiled implemented body rotation. i'm trying implement in box2dmapobjectparser myself , it: editor: and game: as can see right rectangle has property named rotation can properties, don't know wrong it. i set rotation this fixture.getbody().settransform(fixture.getbody().getposition(), degree); where degree value editor. have clues doing wrong? tried doing fixture.getbody().settransform(fixture.getbody().getposition(), degree*mathutils.degreestoradians); but itsalso sets wrong rotation. tiled rotates rectangle objects top-left corner. box2d rotates around position of body, easiest solution create box fixture such position of body in top-left (if you're using b2polygonshape::setasbox means passing center @ half width , half negative height (since y axis inverted)).

wordpress - Authenticate custom WP API endpoint with social login (OAuth) -

i'm using wordpress + woocommerce in combination wp-api backend mobile ecommerce app. my goal offer social login (via facebook, twitter, google etc.) within app register/login , use woocommerce api receive e.g. orders of authenticated user. currently plan is: use client sdk user e.g. can login using fb account from step 1 e.g. users name, email , fb id sent custom endpoint adding user wordpress db (like https://github.com/royboy789/wp-api-social-login ) create custom endpoint orders wp-api (e.g.: .../orders) inside endpoint function check wether user authenticated if user authenticated, endpoint returns user's orders using woocommerce api wrapper ( https://github.com/kloon/woocommerce-rest-api-client-library ) but i'm struggling @ #3 because don't know how check wether user authenticated. i thought creating endpoint contact oauth authorization server check user’s credentials using e.g. facebook's access token. , if check valid, create custom acce...

dns - Avro tool fails to convert from json due to IPv6 -

i trying convert simple json file avro using avro tools (1.7.7). the command i've been running java -jar ~/downloads/avro-tools-1.7.7.jar fromjson --schema-file src/main/avro/twitter.avsc tweet.json > tweet.avro on schema { "type": "record", "name": "tweet", "namespace": "co.feeb.avro", "fields": [ { "name": "username", "type": "string", "doc": "screen name of user on twitter.com" }, { "name": "text", "type": "string", "doc": "the content of user's message" }, { "name": "timestamp", "type": "long", "doc": "unix epoch time in seconds" } ], "doc": "schema twitter messages" } i see exception after runnin...

c# - First ListView item doesnt displayed Windows Phone 8.1 -

i've got problem described here listview in windows phone 8.1 wobbles while scrolling though long list (xaml) so im solve problem link, when add xaml datatemplate listview grid width="{binding actualwidth, elementname=content}" , after that, 1st item of listview dosent displayed, not rendring @ all... how can solve that? i believe caused because estabish itemsource of "content" in earlier event(like loadstate event). possible actualwidth 0.0 when tries bind first item. so try assign itemsource in event page's loaded event make sure actualwidth has valid value.

linux - How to install zbase62 offline -

i downloaded zbase62 here . copied tarball onto offline linux machine , unzipped tar -xzf resulting in folder called zbase62-1.2.0 . in directory containing folder, did $ pip install --no-index --find-links=/path/to/zbase/zbase62-1.2.0 zbase62 ignoring indexes: https://pypi.python.org/simple collecting zbase62 not find downloads satisfy requirement zbase62 no distributions @ found zbase62 i've tried several minor variations of no success, though i've had success other packages. possible install zbase62 offline? until i'll have modify path variable. running command as: pip install zbase62 worked me. when --no-index used did see same error.

php - Symfony2 - print message on non-console event -

i've started refactor 1 of commands in symfony2 (2.7) application. quick question - is there way write event listener listens custom event , handles printing message on screen? suppose there class emits event, example, on successful save db. need listen event , when it's emitted, want print message on screen: "your entity has been saved successfully" , don't want in command code because in opinion when there many outputs in commands, execute method becomes bit messy. that's why started search way of handling system events proper information user. thanks! maybe should try consolelogger ?