Posts

Showing posts from January, 2015

node.js - How to check if user is already logged into instagram -

i using node.js, express, , mongodb instagram app. have found many times know whether or not user logged instagram (be through app via instagram-node authentication or through instagram's actual website). is there easy way this? i ended using passport solve problem. passport conveniently takes care of handling instagram authorization , include example app see how works. https://github.com/jaredhanson/passport-instagram/blob/master/examples/login/app.js function ensureauthenticated(req, res, next) { if (req.isauthenticated()) { return next(); } res.redirect('/login') } is useful since can placed @ top of routing file , routes underneath first check see if user authenticated.

java - XPath check for attribute and show the value -

i need check bunch of .xml files specific permission, attribute. if there such permission attribute have find out value attribute has. this code produces nullpointerexceptions : public static void checkxmlpermissions(string path) { fileinputstream file; try { file = new fileinputstream(new file(path)); documentbuilderfactory builderfactory = documentbuilderfactory.newinstance(); //xpath initialisieren; documentbuilder builder = builderfactory.newdocumentbuilder(); document xmldocument = builder.parse(file); xpath xpath = xpathfactory.newinstance().newxpath(); string expression ="//*[@permission]";

Can not explore database created by an embedded neo4j -

Image
i encounter strange problem. i created database using embedded neo4j path "/users/bondwong/documents/workspace/pamela/target/data/pamela.db". here spring configuration: <bean id="graphdbbuilder" factory-bean="graphdbfactory" factory-method="newembeddeddatabasebuilder"> <constructor-arg value="target/data/pamela.db" /> </bean> then changed line of neo4j-server.properties: org.neo4j.server.database.location=/users/bondwong/documents/workspace/pamela/target/data/pamela.db after that, used curl test system, showed good. here result of getting node id 9: however, when fired server, , use browser see data, nothing shows up: here location, same 1 in spring xml configuration file: here :sysinfo result: here junit test , result, showing insert data: package repositorytest; import static org.junit.assert.*; import java.util.hashmap; import org.junit.test; import org.junit.runner.runwith; imp

javascript - Make part of the text as readonly -

i want make part of strings read only. ex: name: ss,ks,mm,ll,pp in name text want make ks , ll read using javascript or jquery. can suggest how can implement functionality? you cannot make part of textbox readonly. however, can try add pattern textbox. correct pattern logic may able want. you can find many jquery plugin textbox pattern. instance: http://www.jqueryrain.com/demo/jquery-mask-input-plugin/

java - servlet route with GET, POST, PUT and DELETE -

i'm new java server-side programming, question starting point using servlets (low level without using spring mvc etc.) , build way there, coming node.js background route definition start function ( app.get(request, response) {} , app.post(request, response) {} etc.), , function receive request , response in parameters 1 of http methods (get, post, put, delete). if can please on starting point of how define methods against route (let's /users ) inside servlet class that'd map http methods while providing request , response in it's parameters. my attempt public class firstservlet extends httpservlet { public void doget(httpservletrequest request, httpservletresponse response) throws servletexception , ioexception { } i believe want servlet mappings . can find a bit more info here but way tell webserver (e.g. tomcat) servlet use answer requests sent given url pattern. map pattern servlet want use serve it. you can find more info on inner w

jquery - How to make real time count up with Javascript? -

<!doctype html> <html> <head lang="en"> <meta charset="utf-8"> <title>count up</title> </head> <body> <h1>number 1</h1> <div id="counter"></div> <br> <h1>number 2</h1> <div id="counter_2"></div> <script> var start_date = new date("july 2, 2015 11:00:00"); // put in starting date here var interval = 0.366; // in seconds var increment = 1; // increase per tick var start_value = 7325698160; // initial value when it's start date var count = 0; window.onload = function () { var msinterval = interval * 1000; var = new date(); count = parseint((now - start_date)/msinterval) * increment + start_value; document.getelementbyid('counter').innerhtml = count; setinterval("count += increment; documen

php - pulling mysql data for timelinejs? -

i'm trying pull data mysql database create json file use timelinejs timeline. problem json file must formatted way. i've created following code formats json correctly, pulling 1 entry database (specifically last entry). guys offer appreciated! <?php $link = mysql_pconnect("localhost", "root", "********") or die("could not connect"); mysql_select_db("php_test") or die("could not select database"); $rs = mysql_query("select * timelinetest"); while($row = mysql_fetch_array($rs, mysql_assoc)) $object = array ('timeline'=> array( 'headline'=>'georgia history title page', 'type'=>'default', 'text'=> 'testing overview', 'startdate'=>'1700', 'asset'=>array('media'=>'titlepagemedia', 'credit'=>'titlepagecredit', &

vmware - unable to install .vmdk file in windows 7 -

i need install .vmdk file in order setup base environment specific application software. below steps performed still struggling. installed vmware player (non commercial version) in system , while trying open .vmdk file through vmware player, started complaining "no operating system found". as next steps, tried install vmware-mount-5.5.0-18463.exe belive free software.but everytime in middle of installation,it showing "the wizard interrupted before vmware diskmount utility installed. system has not been modified. click finish exit installation". below system configuration: os: windows 7 ram: 4gb processor: i5-4200m cpu @ 2.50ghz dis space: 235 gb free. this first time trying install vmimage. please let me know 1. there wrong in approach? 2. there alternative way can install vmdk software? 3. there specific reason due getting above errors? in vmware world, vmdk image of virtual machine's hard drive. use vmdk, have create virtual machine,

linux - How can i check if some dir exist and then execute in makefile -

i have in makefile venv: virtualenv /var/www/env && source /var/www/env/bin/activate but want if /var/www/env not exist how can that unfortunately, make rules not support negative conditions. a common workaround use dummy files mark condition; in case have like var-www-env-does-not-exist: if [ -d /var/www/env ]; touch $@; else rm -f $@; exit 1; fi venv: var-www-env-does-not-exist /var/www/env/bin/activate virtualenv /var/www/env && source /var/www/env/bin/activate another idea write , call script calls virtualenv correctly deals case of existing /var/www/env .

Excel VBA Object Defined Error -

i getting object defined error below code. any idea doing wrong? thanks sub loop_test2() dim integer dim j integer dim countall integer dim countxl integer activesheet.range("a1").activate countall = activesheet.range("a35") msgbox countall j = 1 countall = 1 this error occurs: countxl = cells(i, j).value continued: msgbox countxl = 1 countxl + 2 cells(i + 2, j) = "row " & & " col " & j next next j end sub i think incorrect assignment. i'm not familiar correct syntax. error details: "run time error 1004. application defined or object defined error before edit question, forget initial i .so set value i . in future, may use option explicit @ top of sub make sure declare variable before using it. so case, need set i=1 , , please declare variables long instead of integer. may refer here find out reason why use lon

php - Gmail mails fetching with oauth -

http://appdeal.com/appdeal/getmail2.php i trying fetch email. i have when register in website email. link email website using gmail oath. have use these oath token read mails after interval , parse these mails important text email in form of html, parse using xpath. can on this? for fetching e-mails , have 2 options: either use gmail api or using service context.io . if use context.io, can access other inboxes , not gmail. if work gmail api, make sure ask offline access when getting oauth token, otherwise won't able pull e-mails @ later point in time. fetching e-mails directly via imap in php seems quite complex. when comes parsing e-mails , please keep in mind html of e-mails not accurate , xpath method fail when there slight changes in layout. out of experience (i'm founder of mailparser.io ) suggest rely on text patterns parsing. search things can identify "order id:" regular expressions example.

php - How to replace some characters in tsv file like HTML Math and Engineering symbol entities -

actually want replace these html math , engineering symbol entities numbers. there equivalent code ¼ &#188; , ½ &#189; . examples given in link below . i have used str_replace , preg_match non of them worked. please tell me way this. highly appreciated. you can use mb_encode_numericentity function this, http://php.net/manual/en/function.mb-encode-numericentity.php $string = '¼ ½ ⅖ ⅘ ⅚ '; $convmap= array(0x0080, 0xffff, 0, 0xffff); $string = mb_encode_numericentity($string, $convmap, 'utf-8'); echo $string; output: &#188; &#189; &#8534; &#8536; &#8538; demo: http://sandbox.onlinephpfunctions.com/code/c554aae1696c8ded4cdd97329269828c4cbf836b note: convert other characters outside ascii character set. if want convert 5 characters str_replace might better route. $string = ' figure ¼,½,⅖,⅘,⅚ not'; $find = array('¼', '½', '⅖', '⅘', '⅚'); $replace = array('&#

How to improve the performance of c# program -

i trying to extract sdf file geodatabase.as new sdf file created ,the memory usage program increases.to overcome issue have tried reaseing connection sdf file , tried release resources using gc.collect() method still problem persist. /// <summary> /// feature data geodatabase file /// </summary> /// <param name="dictionaryproperty"> schema of table </param> /// <param name="table">table connection of gdb file</param> /// <param name="sdffilepath">sdf file path</param> static void getfeaturedata(dictionary<string, property> dictionaryproperty, table table, string sdffilepath) { int filecount = 1; ; list<property> propertylist = new list<property>(); ienumerable<string> propertycoll = dictionaryproperty.select(i => i.value).where(i => i.datatype == "oid").tolist().select(i => i.propertyname); string propertyname = null; foreach (string item in

how to set Pig Storage location to some another hadoop cluster -

i running pigscript through rest api , want store pig output hadoop cluster .is there way set pigstorage other hdfs . you can use distcp copy 1 hdfs another. distcp used copy large amounts of data , hadoop file systems in parallel. $ hadoop distcp hdfs://namenode1/foo hdfs://namenode2/bar

javascript - Error when running external php mysql query through JQuery -

hey using jquery call file ' login.php '. when click log in on pop modal error access denied user 'urbanas8'@'localhost' (using password: no) when know connection database correct , works other pages not call external php files. don't understand why error occurring maybe 1 of guys can tell me whats going on here? login modal <!--login modal --> <?php require_once( "./inc/connect.inc.php" ); ?> <div class="modal fade col-sm-4 col-sm-offset-4" id="login" role="dialogue"> <div class="modal-dialogue"> <div class="modal-content"> <form action="" method="post"> <div class="modal-header"> <h4>login</h4> </div> <div class="modal-body row"> <div class="form-group"> &

I have an embedded Google Map which includes a marker. This marker is lost when I click through to detailed map -

i have embedded google map includes marker. marker displays fine in embedded map. however when click "google" logo in bottom left corner of embedded map, takes me through map in full google maps site, marker seen. how can ensure marker carried through detailed google map? map generated follows: <div class="googlemap"><div id="mapdiv" class="googlemaps" style="width: 380px; height: 300px"><script> function tpinitmap() { var tpcoords = new google.maps.latlng('13.704312','100.492296'); var tpmap = new google.maps.map(document.getelementbyid("mapdiv"), {scrollwheel:false, zoom: 14, center: tpcoords, maptypeid: google.maps.maptypeid.roadmap}); var tpmarker = new google.maps.marker({position: tpcoords, map: tpmap, title: 'anantara bangkok riverside resort & spa'}); } </script><script src="http://maps.google.com/maps/api/js?sensor=

HTML: I'm trying to use then integrate a form template, but when I hit submit it just goes to the PHP file. Help fixing this? -

form template origin : http://www.html-form-guide.com/contact-form/php-email-contact-form.html html form page : <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <title>contact us</title> <!-- define style elements--> <style> h1 { font-family : arial, helvetica, sans-serif; font-size : 16px; font-weight : bold; } label,a { font-family : arial, helvetica, sans-serif; font-size : 12px; } </style> <!-- helper script vaidating form--> <script language="javascript" src="scripts/gen_validatorv31.js" type="text/javascript"></script> </head> </head> <body> <h1>contact us</h1> <form method="post" name="contactform" action="contact-form-handler.php"> <p> <label for='name'>your name:</la

Android Maps Get Longitude and Latitude -

i trying location longitude , latitude appear in toast on updates. however, nothing appears ! map loading fine, cannot coordinates in toast. hints? package com.parse.starter; import android.app.activity; import android.location.location; import android.location.locationlistener; import android.os.bundle; import android.util.log; import android.widget.textview; import android.widget.toast; import com.google.android.gms.common.connectionresult; import com.google.android.gms.common.api.googleapiclient; import com.google.android.gms.location.locationrequest; import com.google.android.gms.location.locationservices; import com.google.android.gms.maps.cameraupdatefactory; import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.mapfragment; import com.google.android.gms.maps.onmapreadycallback; import com.google.android.gms.maps.model.latlng; import com.google.android.gms.maps.model.markeroptions; import com.parse.parse

Playing with animation in android -

i learning android animation , thought of playing it. have created animation want there should delay/wait between animation. here code. new animationutils(); animation anim = animationutils.loadanimation(this, r.anim.abc_slide_in_bottom); findviewbyid(r.id.app_logo).startanimation(anim); findviewbyid(r.id.addtopic).startanimation(anim); findviewbyid(r.id.adddescription).startanimation(anim); findviewbyid(r.id.addbtn).startanimation(anim); now want after findviewbyid(r.id.app_logo).startanimation(anim); should wait animation finish. once finished findviewbyid(r.id.addtopic).startanimation(anim); should start , on. if can guide me on how achieve happy thankful thanks. this simple solution needs: final animation anim0 = animationutils.loadanimation(this, r.anim.abc_slide_in_bottom); final animation anim1 = animationutils.loadanimation(this, r.anim.abc_slide_in_bottom); final animation anim2 = animationutils.loadanimation(this, r.anim.abc_slide_in_bot

haskell - How to know what made a behavior change? -

i'm writing network description a listbox logic. it's simple: have behavior ( maybe ) current selected item, , want whenever user adds new item list, current selected item select just-created value. it's possible user remove items list, , cause various of other changes, have know when new item created; can't select last item on every change. i don't have code show because speculations on can't written api*, have context of frameworks t , (simplified): bdb :: behavior t [entry] -- created accumb. bselected :: behavior t (maybe entry) -- created accumb. eaddentry :: event t () -- user clicked add button. created fromaddhandler. * well, did think using eaddentry select last entry, that's bad , if work it's race between adding of new item , selecting of it. how can go it? i gave cactus's suggestion in comments try, , turns out couldn't been done (i'd have bind changes in middle of let block selection behavior, , list b

reflection - How do I get the values of arguments passed inside a func() argument in GO? -

i trying create middleware inside routes , wondering how 1 can values of arguments passed inside func() argument. for example: func (c appcontainer) get(path string, fn func(rw http.responsewriter, req *http.request)) { // how values of rw , req passed in fn func()? c.providers[router].(routable).get(path, fn) } i looked through reflection docs it's not clear me or perhaps there simpler way? edited (solution) it turns out reflection not needed, suggested adam in response post, jason on his golang-nuts reply question. the idea create new anonymous function intercepts parameters passed modification/enhancement before calling original function. this ended doing , worked charm, posting in case helps else: type handlerfn func(rw http.responsewriter, req *http.request) func (c appcontainer) get(path string, fn handlerfn) { nfn := func(rw http.responsewriter, req *http.request) { c.providers[logger].(loggable).info("[%s] %s", req.metho

elasticsearch"java.nio.channels.UnresolvedAddressException: null" by use transportClient -

using elasticsearch transportclient find exceptions: java.nio.channels.unresolvedaddressexception: null @ sun.nio.ch.net.checkaddress(net.java:127) ~[na:1.7.0_71] @ sun.nio.ch.socketchannelimpl.connect(socketchannelimpl.java:644) ~[na:1.7.0_71] @ org.elasticsearch.common.netty.channel.socket.nio.nioclientsocketpipelinesink.connect(nioclientsocketpipelinesink.java:108) [stormjar.jar:na] @ org.elasticsearch.common.netty.channel.socket.nio.nioclientsocketpipelinesink.eventsunk(nioclientsocketpipelinesink.java:70) [stormjar.jar:na] @ org.elasticsearch.common.netty.channel.defaultchannelpipeline.senddownstream(defaultchannelpipeline.java:574) [stormjar.jar:na] @ org.elasticsearch.common.netty.channel.channels.connect(channels.java:634) [stormjar.jar:na] @ org.elasticsearch.common.netty.channel.abstractchannel.connect(abstractchannel.java:207) [stormjar.jar:na] @ org.elasticsearch.common.netty.bootstrap.clientbootstrap.connect(clientbootstrap.java:229) [stormjar.jar:na] @ org.elasticse

android - my androidstudio app doesnt display the adapter in the listview -

i parse json string website , save arraylist , when run app, elements don't show in fragment, debug , info save in arraylist doesn't show it. checked similar topics no 1 has solved problem. here code: adapter: package com.example.luiggi.myapplication; import android.app.activity; import android.content.context; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.arrayadapter; import android.widget.textview; import java.util.arraylist; /** * created andre_000 on 6/28/2015. */ public class facturasadapter extends arrayadapter<invoices> { context context; int layoutresourceid; arraylist<invoices> data; public facturasadapter(context context, int layoutresourceid, arraylist<invoices> data) { super(context, layoutresourceid, data); this.layoutresourceid = layoutresourceid; this.context = context; this.data = data; } @override

controls - how to run a Simulink model in a Matlab M file in this way? -

i have simulink model "mod_sim" in simulink input port "inp" , output port "out". want send inputs model, simulate , take corresponding outputs @ every sampling time "ts". want simulate model in way "n" time steps (in terms of ts). more specifically, want following implementation: at given time step "k", have input u(k) (from other source). then, want apply input mod_sim , corresponding output y(k) model. want repeat n time steps. how can such implementation? i happy helps. you need have inputs defined function of time time span of interest in matlab workspace before start simulation. assuming have t , u defined in matlab workspace, , input port inp @ root level of model, need configure model use u , t inp , described in import data root-level input ports . once have done that, can run simulation using sim command , making sure 'saveoutput' on in simulation options. you can repeat ex

jquery - visualsearch (faceted query search) using Sencha ExtJS 5 -

i've been trying implemented faceted search autocomplete using sencha extjs 5. similar "visualsearch" plugin developed using jquery. this i'd do: http://jsfiddle.net/tuping/7wyhx/1/ so far, have: ext.define('app.custom.searcherwidget', { extend: 'ext.form.field.combobox', alias: 'widget.searcher', emptytext: 'select entity', iskeyselected: false, currselectedkey: null, facetedquery: null, initcomponent: function() { var me = this; me.store = me.retrievekeys();//todo: changed me.querymode = 'local'; me.displayfield = 'description'; me.valuefield = 'code'; me.typeahead = true; me.minchars = 1; me.enablekeyevents = true; me.triggeraction = 'query'; me.hidetrigger = true; me.on({ change: me.fixchange, beforeselect: me.fixbeforeselect, beforequery: me.fixbeforequery, keypress: me.checkkeypressed, scope: me

Does Source Insight provide "EOL conversion" function? -

in notepad++, there "eol conversion" option can change eol of file windows unix format. source insight provide similar feature can convert file or bunch of files in batch? the following answer source insight support: to save file specific end-of-line type in source insight, select file > save as... , says " save type ", select desired end-of-line type. to set end-of-line type new files create in source insight, select options > preferences , click files tab. says " default file format " select desired end-of-line type.

Non blocking TCP connect in Spring Integration -

i attempting use spring integration connect large number of devices (500-1000) on volatile network , i'm having issues default pool of 10 task schedulers blocking trying connect devices not available. my implementation based on dynamic ftp example, new child application context created each of remote devices client tcp connection factory , tcp inbound adapter messages routed flow of root context. the problem having is important these devices connected quickly, large number of them may offline @ time. all connections seem sent out single 10 member task scheduler pool , end blocking on connect call, causing large delays connecting devices online further down list. so question is, there way implement non blocking connect call using spring integration? non-blocking connect won't because connections established on demand , sending thread needs block until connection enabled, if it's request/reply scenario. if using channel adapters one-way or arbitrary two-w

android - Facebook review for hybrid apps -

i implemented hybrid app using ionic framework (cordova , angular). app uses facebook login (that has been implemented in javascript). i want submit app facebook review need submit platform. tried use "android app" platform since not use facebook android sdk login facebook cannot use platform. website asks url (that not have since app runs on mobile devices). what right thing in case? you have use firebase based social login apps. it's simple. creating ionic app so, first step creating blank ionic app. in terminal go directory store ionic apps. run following command: ionic start social-auth blank this create empty ionic app you. type cd social-auth , run following command: ionic serve start dev server @ http://localhost:8100 . note: ionic serve starts server @ http://your_ip_here:8100 . keep things simple let's use address http://localhost:8100 view app in browser (which same accessing http://your_ip_here:8100 ). now if load address

regex - I think my regular expression pattern in C# is incorrect -

i'm checking see if regular expression matches string. have filename looks somename_somthing.txt , want match somename_*.txt , code failing when try pass should match. here code. string pattern = "somename_*.txt"; regex r = new regex(pattern, regexoptions.ignorecase); using (zipfile zipfile = zipfile.read(fullpath)) { foreach (zipentry e in zipfile) { match m = r.match("somename_something.txt"); if (!m.success) { throw new filenotfoundexception("a filename format: " + pattern + " not found."); } } } the asterisk matching underscore , throwing off. try: somename_(\w+).txt the (\w+) here match group @ location. you can see match here: https://regex101.com/r/qs8wa5/1

itunesconnect - Archive submission to App Store failed in Xcode 7.0 for Test Flight -

Image
i submitting prerelease app app store internal testing test flight in xcode 7.0 beta 2 (7a121l). able submit archive 0 problems multiple times today seeing following error message. xcode version or project settings did not change. error itms-90035: "invalid signature. code object not signed @ all. make sure have signed application distribution certificate, not ad hoc certificate or development certificate. i using "ios developer" code signing identity release. code signing settings @ target level following: according this blog post 1 needs use 'ios developer' code signing identity test flight release builds. correct? signing release ios distribution i have tried changing release settings ios distribution still getting same error. update i managed fix problem , uploads app store. had external framework built carthage. needed open framework project , remove framework search path setting it. rebuilt framework carthage , uploaded app ap