Posts

Showing posts from March, 2012

javascript - Component get duplicated content instead of refreshing -

i'm reviewing reactjs, following tutorial @ https://facebook.github.io/react/docs/tutorial.html , when playing example run weird behavior. problem content of 1 element (the comment) doesn't refreshed . instead duplicates new data. see working fiddle @ http://jsfiddle.net/l0xy4jqa/2/ what's wrong? code: /* html */ <script src="http://fb.me/react-js-fiddle-integration.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.2/marked.min.js"></script> <div id="content"></div> /* js */ var data = [ {author:"mr. raspa pan", color:"darkblue", text: "- content"}, {author:"mrs. pasa sa", color:"darkgreen", text: "- *other* content"}, {author:"mrs. rata tan", color:"brown", text: "- __more__ content"}, {author:"mr. aspa spa", color:"deeppink", t

How do you split an array into array pairs in JavaScript? -

i want split array pairs of arrays so var arr=[2,3,4,5,6,4,3,5,5] would newarr =[[2,3],[4,5],[6,4],[3,5],[5]] there's no pre-baked function that, here's simple solution: var splitpairs = function(arr) { var pairs = []; (var i=0 ; i<arr.length ; i+=2) { if (arr[i+1] !== undefined) { pairs.push ([arr[i], arr[i+1]]); } else { pairs.push ([arr[i]]); } } return pairs; };

Connecting to Redis Cluster via Sentinel -

i have redis cluster of 3 master nodes , 3 slaves. have 3 sentinel servers (each on separate machine) monitoring redis cluster. using predis, able connect cluster via single master node's ip/port. want know if can connect predis cluster via sentinel ip/port? redis cluster handles failover without sentinel, don't need use sentinel via redis cluster. only thing need choosing library can support redis cluster.

how to change website background using php and mysql? -

i have issue changeing background , show or change background if image id =1 , how can dysplay other values ? here php code : <?php include "config.php"; //database connection file //check database background color $check_page_color = mysql_query("select * `page_color` `id` = '".mysql_real_escape_string('1')."'"); // `id` = '".mysql_real_escape_string('1')."' if(mysql_num_rows($check_page_color) > 1) //if no color found, use default color below > 1 { $page_color = "#f9f9f9"; //default color } else { $get_page_color = mysql_fetch_array($check_page_color); $page_color = strip_tags($get_page_color["background_color"]); //color database } ?> css : <style type="text/css"> body { background-image: url(<?php echo $page_color; ?>); </style> and here html code displays photos : new background:<select name="img" class="vp

c# - Return actual patched property value from patchcommand in RavenDb -

a have "billing" class that's describe finance account model in multithreading application. if want transfer money 1 billing make patchcommand increment 1 property , decrement another. right way return actual property value after patching without redundant load-query? billing class public class billing { public string id { get; set; } public decimal balance { get; set; } } my patch method public void transfermoney(string billingsrc, string billingdst, decimal money) { _ctx.databasecommands.batch(new icommanddata[] { new scriptedpatchcommanddata { key = billingsrc, patch = new scriptedpatchrequest { script = @"this.balance -= money;", values = {{"money", money}} } }, new scriptedpatchcommanddata { key = billingdst,

dart - Icon is not changing -

i trying change icon when specific radio-button selected. however, switch statement in .dart code never changes icon though switch triggered. thanks help. .dart class gender extends object observable { @observable string sex = ''; } @observable string ikon = 'alarm'; void onchangeradiogrouphandler(dom.customevent e) { gender.sex = (e.target paperradiobutton).label; switch(gender.sex) { case 'male': ikon = 'done'; break; case 'female': ikon = 'cached'; break; } .html <div layout vertical center> <div layout horizontal self-center> <paper-icon-button icon='{{ikon}}' on-click='{{toggle}}'></paper-icon-button> </div> </div> <core-collapse id='core--collapse'> <div layout vertical'> <label id='genderlbl'></label> <paper

symfony - Authentication request could not be processed -

i implementing login module i'm trying use database user entity authentication. i have configured security.yml file follows integrate user entity: providers: our_db_provider: entity: class: userbundle:user property: username but facing error: authentication request not processed due system problem. can let me know why issue coming? if use class authentication inherit userbundle\entity\user, have specify latter superclass instead of entity. here example user.orm.yaml : userbundle\entity\user: type: mappedsuperclass [...] more info on doctrine documentation : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/inheritance-mapping.html

How to update SQL server table based on modified values? -

i developing as3 module loads content sql server table in data grid. whenever data grid changed, changed values should stored in database. question is, there anyway can accomplish 1 sql query? currently firing queries based on changes in each cell inefficient. thank you. maybe add change event listener in data grid helps. mark rows updated , construct sql queries in batch may improve efficiency.

jquery - deselect tag with 'select2' -

hi new java script. i try save in array selected tags, work ok, when press 'x' on tag want delete array, how can this? $( "#select2-2" ).change(function() { $( "#select2-2 option:selected" ).each(function() { strarr[i] = $( ).text(); i++; }); }).trigger("change"); my html code: <select id="select2-2" class="form-control" multiple> <option>tag1</option> <option>tag2</option> <option>tag3</option> <option>tag4</option> <option>tag5</option> </select> more explain select-2: https://select2.github.io/ select-2 create tags when select option select list, this: [tag3 x][tag2 x][tag4 x] when select option select list, visual tag.. save tags in array. when press 'x' want remove tag array. any idea how can this? add remove button, link bit of code: $('#select2-2').find(&

javascript - Ionic animation for splash screen -

is possible add gif or svg animation splash screen ionic mobile app? couldn't find solution looks typical task. maybe missed solution. <gap:plugin name="org.apache.cordova.splashscreen" /> <feature name="splashscreen"> <param name="android-package" value="org.apache.cordova.splashscreen.splashscreen" /> <param name="ios-package" value="cdvsplashscreen" /> </feature> <gap:splash src="img/splash.gif" /> <gap:splash src="img/splash.gif" gap:platform="ios" width="640" height="1136" /> if put .png works, .png doesn't support animations. it mentioned in document supported files are: png, psd, , ai. ionic icon splashscreen if want customize, try 1 might you: using views events create javascript pure ionic splash screen

Errors using distance metric in MATLAB -

my test feature vector 'testpg' , trained feature vector 'trainpg' , both of dimension 2000*1 .i aiming find distance between 2 histogram feature vectors , hence do distance = norm(trainpg-testpg) next compare scalar threshold value check whether satisfies condition , above code works scalar value of distance ie : eg distance = 5.4 scalar but when change code use other histogram based distance metric doesn't work i used pdist2 function http://www.mathworks.com/matlabcentral/fileexchange/29004-feature-points-in-image--keypoint-extraction/content/fps_in_image/fps%20in%20image/help%20functions/searchingmatches/pdist2.m the new code used is distance = pdist2(trainpg,testpg, 'chisq') d = size(distance) here getting subscripted assignment dimension mismatch error dimensions of distance 2000*2000 instead of 1*1 how scalar value distances? if dimensions 2000 x 1 both of feature vectors, should do: distance = pdist2(trainpg.',te

caching - Auto update data in google spreadsheet when data in Json url changed by Apps Script -

i using " importjson trevor lohrbeer (@fastfedora) for ref. " library importing json feeds google spreadsheets. simply input function =importjson(url, query, options) cell , cell returns data there. and fine data in google spreadsheet not updated automatically when json data in url changed. have re-enter function again cell or refresh script manually done. so can suggest solution me? udfs in sheets recalculated if cells references change. there suggestions on 1 , suggest setting triggers recalculate sheet every time you: re-open it change cell - depending on how use data recalculate periodically time-driven scripts

kibana 4 - Pivoting in Elasticsearch -

can tell me there way in elasticsearch/kibana provide pivoting feature in oracle? i want create report pivoting field sum aggregation. for example : have schema indexed in test-index/test-type doc id being id . id | name | code | amt ----------------------- 1 | abc | | 10 2 | def | c | 20 3 | xyz | | 30 4 | abc | | 10 5 | abc | c | 20 6 | xyz | b | 30 7 | def | c | 10 8 | def | | 20 i want generate report pivoting done : sum(amt) code in (a,b,c) name | | b | c --------------------- abc | 20 | 0 | 20 def | 20 | 0 | 30 xyz | 30 | 30 | 0 can using elasticsearch , reports generated in kibana? ps. new elasticsearch query dsl, helpful if having grasp on query dsl can me out whether possible in es , or suggest me way this??

c# - Datagridview header location -

Image
i want move header locations top(columns) , left(rows) right(rows) , bottom(columns). can find information aliments content within headers, not alignment of headers themselves. see photo below example of this... i know might tricky add items accordingly datagridview, data needs organized way opposed headers on top , left. (if using datagridview hard, there object can use?) as always, thanks! afaik, not possible in winforms. don't know how in wpf , don't know other out-of-the-box solutions. my proposal: cheat adding dgv on right , 1 on bottom. contain headers. need 'connect' scrolling events of dgvs. got idea i'm meaning? not nicest solution , sure bit tricky, one.

Gradle build failing in Android Studio -

error: error:execution failed task ':app:createdebugmaindexclasslist'. com.android.ide.common.process.processexception: org.gradle.process.internal.execexception: process 'command 'c:\program files\java\jdk1.8.0_25\bin\java.exe'' finished non-zero exit value 1 my build.gradle is, android { compilesdkversion 21 buildtoolsversion '19.1.0' defaultconfig { applicationid "com.example.izabuy" minsdkversion 14 multidexenabled true targetsdkversion 21 compileoptions { sourcecompatibility javaversion.version_1_7 targetcompatibility javaversion.version_1_7 } } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.txt' } } compileoptions { sourcecompatibility javaversion.version_1_7 targetcompatibility

Unable to hide command prompt in C# windows form application visual studio 2010 -

Image
this question has answer here: hide console window process.start c# 3 answers i have made application in c# visual studio 2010. in application sending ping command cmd , receiving output of cmd in richtextbox . here code:- void proc_outputdatareceived(object sender, datareceivedeventargs e) { if (e.data != null) { string newline = e.data.trim() + environment.newline; methodinvoker append = () => txtoutput.text += newline; txtoutput.begininvoke(append); } } private void btnping_click(object sender, eventargs e) { string command = "/c ping " + txtping.text; processstartinfo procstartinfo = new processstartinfo("cmd", command); process proc = new process(); proc.startinfo = procstartinfo; proc.start(); procstartinfo.redirectstandardoutput = true; procstartinfo.useshellexecute

ios - How to use reloadRowsAtIndexPaths? -

i have seen code around lots not sure how implement it. [self.tableview beginupdates]; [self.tableview reloadrowsatindexpaths:@[indexpathofyourcell] withrowanimation:uitableviewrowanimationnone]; [self.tableview endupdates]; is possible use change font size of individual cell in table populated dynamically? i have row number of cell want change , want change font size on timer after x seconds of 1 cell in table. possible? yes: [self.tableview reloadrowsatindexpaths:@[[nsindexpath indexpathforrow:rownumber section:0]] withrowanimation:uitableviewrowanimationnone]; this assuming have code in cellforrowatindexpath method conditionally change font size.

recursion - Error Handling in a Recursive setTimeout Function in Node.js -

i'm building first node.js application on raspberry pi using control air conditioner via lirc. following code called when want increase temperature of ac unit. sends lirc command every 250 milliseconds depending on how many degrees want increase by. code works expected. var idegrees = 5; var = 0; var delay = 250 // delay in milliseconds function increasetemperatureloop(){ i++; //lirc_node.irsend.send_once("ac", "increase", function() {}); console.log(i); // call fucntion/loop again after delay if still need increase temperature if (i <= idegrees){ timer = settimeout(increasetemperatureloop, delay); } else { res.json({"message": "success"}); } } // start timer call recursive function first time var timer = settimeout(increasetemperatureloop, delay); i'm having hard time working asynchronous nature of node.js. once recursive function done, return json browser shown in

Cannot create new AzureVM using image captured using PowerShell -

i not able create new azure vms using images have captured through powershell. here situation in. i create 2 windows vms "mydevbox1" , "mydevbox2" using latest image of windows server 2012 r2 in azure gallery i install necessary software , configure both same 3a. capture the image of mydevbox1 called mydevbox1-image-ps using powershell script below. 3b. capture image of mydevbox2 called mydevbox2-image-manual using manual/portal process (sysprep -> capture image) (ofcourse separate vm). 4a. when try create new vm using mydevbox1-image-ps created through powershell, vm creation process fails (provisioning times out) 4b. when try create new vm using mydevbox2-image-manual created through manual process, vm creation successful. please help. powershell script using capture image save-azurevmimage –servicename $servicename_tocapture –name $vmname_tocapture –imagename $imagename_captured_generalized –osstate "generalized" -imagelabel $ima

Extracting HTML element with Java and XPath -

i trying extract latitude , longitude of address. here coding. public static void main(string[] args) throws exception { int responsecode = 0; string api = "http://maps.googleapis.com/maps/api/geocode/xml?address=9%20edinburgh%20place,%20centrall&sensor=false&components=country:hk&language=en"; url url = new url(api); httpurlconnection httpconnection = (httpurlconnection)url.openconnection(); httpconnection.connect(); responsecode = httpconnection.getresponsecode(); if(responsecode == 200) { documentbuilder builder = documentbuilderfactory.newinstance().newdocumentbuilder();; document document = builder.parse(httpconnection.getinputstream()); xpathfactory xpathfactory = xpathfactory.newinstance(); xpath xpath = xpathfactory.newxpath(); xpathexpression expr = xpath.compile("/geocoderesponse/status"); string status = (string)expr.evaluate(document, xpathconstants.string);

html - How to prevent text to overlap the image? -

Image
text overlapping image. screenshot of overlapped contents: css class of text: ._text { position:relative; float:left; text-align:left; margin-left:30px; font-size:14px; color:#ff0000; z-index:1; } css class of image: ._images { position:absolute; float:right; margin-top:18px; margin-left:165px; width:170px; height:170px; z-index:0; } give me solution move text away image. thank in advance. edition here html (as demanded in comments) dynamically returned ajax: <div id="rno">(12 / 14)</div> <img class="_images" src="buildings_files/school2.png" align="right"> <h4 class="building_heading">school</h4> <span id="m_text_area_body">school .... <br><br></span> <span class="_text">» upgrade governor palace (level-10) construct building. have suffecient golds construct it</span

android - How to make gridview asymmetric? -

Image
in application trying make gridview asymmetric,but able set colums 2 or 3 on..any other option make gridview asymmetric? following code gridview,can me this? <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#f3f3f3" > <android.support.v4.view.viewpager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="150dp" /> <gridview android:numcolumns="2" android:gravity="center" android:stretchmode="columnwidth" android:layout_width="match_parent" android:layout_height="match_parent" android:id="

c++ - QT Build Error ' Expected a platform name ' (Xcode 6.3.2 / OS X 10.10 / Qt 5.4.2) -

os x 10.10, xcode 6.3.2, qt 5.4.2 clang 64bit after moving yosemite , qt 5 can't build c++ project on mac anymore. next errors after clean,qmake , rebuild: /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.10.sdk/usr/include/sys/unistd.h:185: error: expected platform name, e.g., 'macosx' int getattrlistbulk(int, void *, void *, size_t, uint64_t) __osx_available_starting(__mac_10_10, __iphone_8_0); ^ /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.10.sdk/usr/include/sys/unistd.h:203: error: expected platform name, e.g., 'macosx' int faccessat(int, const char *, int, int) __osx_available_starting(__mac_10_10, __iphone_8_0); ^ /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.10.sdk/usr/include/gethostuuid.h:39: error: expe

algorithm - Complexity when generating all combinations -

interview questions start "this might solved generating possible combinations array elements" meant let me find better. anyway add "i prefer solution since o(x)".. question is: o(x) complexity of generating combinations given set? i know there n! / (n-k)!k! combinations (binomial coefficients), how big-o notation that? first, there nothing wrong using o(n! / (n-k)!k!) - or other function f(n) o(f(n)) , believe looking simpler solution still holds same set. if willing @ size of subset k constant, for k<=n-k: n! / ((n-k)!k!) = ((n-k+1) (n-k+2) (n-k+3) ... n ) / k! but above (n^k + o(n^(k-1))) / k! , in o(n^k) similarly, if n-k<k , o(n^(n-k)) which gives o(n^min{k,n-k})

c++ - common function in base and derived calling base when called through another base function using a derived object? -

#include <iostream> using namespace std; class dissection { int x; public: void test() { cout<<"test base"; } void caller(){ test(); } }; class dissectionderived: public dissection { int x; public: void test(){ cout<< "test derived"; } }; int main( int argc, char ** argv ) { dissectionderived derived; derived.caller(); return 0; } in code sample above, ouput " test base ". way thought was, since derived doesn’t have function named caller invoke base class function, since actual type of object dissectionderived able call test function of dissectionderived class. because overload resolution stops after finds closest test function in base class scope? if caller function can invoked derived function, why cant part of overload resolution in derived class ? i have used -cg g++ compiler flag , did obj dump of objectfile, output shown below: symbol table: 0000000000000000 l d

angularjs - Protractor test for Angular: how to get exact match for column name -

i have started writing protractor tests, beginner this. i have following angular code trying test: <tr ng-repeat="identifier in contentidentifiers"> <td>{{identifier.contentidentifier}}</td> <td>{{identifier.contentidentifiertypedescription}}</td> <td>{{identifier.licensedwebsiteidentifier}}</td> </tr> where content identifier has following values: contentidentifiers = [ { contentidentifier: '123-123-1-abc', contentidentifiertypedescription: 'doi', licensedwebsiteidentifier: 'test website' }, { contentidentifier: 'abc-def', contentidentifiertypedescription: 'isbn', licensedwebsiteidentifier: 'test website' }, ]; and relevant protractor snippet: var identifier = element.all(by.repeater("identifier in contentidentifiers").column("identifier.contentidentifier")); expect(iden

wpf - Editing Resharper's INotifyPropertyChanged -

when have class declare implements inotifypropertychanged interface, resharper automatically generate implementation: public event propertychangedeventhandler propertychanged; [notifypropertychangedinvocator] protected virtual void onpropertychanged(string propertyname) { var handler = propertychanged; if (handler != null) handler(this, new propertychangedeventargs(propertyname)); } which editing this: public event propertychangedeventhandler propertychanged = delegate { }; [notifypropertychangedinvocator] protected virtual void onpropertychanged(string propertyname) { propertychanged(this, new propertychangedeventargs(propertyname)); } can somehow edit autogenerated code? resharper's documentation less clear me on this. no, can't edit auto-generated code, because needs handle number of possibilities when generating - e.g. c# 6 uses ?. operator, , needs handle when event exists , has been initialised. if want use shorthand version doesn't

How are hardware specific bugs and features tested in the Linux kernel? -

how kernel developers test changes on specific hardware? if don't have particular type of hardware, how figure out issue happening? generally, kernel developers responsible writing drivers specific piece of hardware happens tester , owns piece of hardware. if developer comes across bug (or if people report bug) on piece of hardware, 1 fixes it. it'd silly ask fix or maintain driver hardware not own. as higher level kernel features, here linux development paradigm comes play. linux employs merge window strategy releasing since it's unrealistic ask every developer test changes on every single possible combination of hardware , software combinations. instead, after major release, merge window opened around 2 weeks developers can push in significant changes, new drivers , features. after merge window closes, no more patches new changes accepted. during time merge window closed, developers have chance test newly merged code on own hardware , report bugs , br

r - disable all chunk evaluation but keep inline evaluation -

i want disable chunk evaluation keep inline evaluation via \sexpr . setting eval globally false this \documentclass{article} \begin{document} <<setup, include=false>>= opts_chunk$set(eval= false) @ \sexpr{"is not displayed"} bummer. \end{document} also affects \sexpr . p.s.: searched subsets of [knitr],\sexpr, eval. hope formatting correct p.s.: don't want set eval 1.

PHP fetch into multidimensional array -

i trying use bind_result , while-fetch fetch set of data 2d array, have searched through internet solution, doesn't work expected. not sure goes wrong in code after few hours debugging. appreciate if can helps detect blind spot. scenario: i have table below: tbl_team teamname id name gender team1 1 john male team1 2 kelly female team1 3 chan male team2 1 jordan male ... etc i created function query these base on teamname. <?php function queryteam ($team) { $stmt = $mysqli->prepare("select id, name, gender tbl_team teamname = ?"); if($stmt) { $stmt->bind_param('s',$team); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($team_member['id'],$team_member['name'],$team_member['gender']); $team = array(); while($stmt->fetch()) { //echo implode(" - ", $team_member)."<b

shell - What is the difference ` and ' in the sendmail configuration file? -

i reading article : http://linuxconfig.org/configuring-gmail-as-sendmail-email-relay . in middle of article; put bellow lines sendmail.mc configuration file right above first "mailer" definition line: define(`smart_host',`[smtp.gmail.com]')dnl define(`relay_mailer_args', `tcp $h 587')dnl define(`esmtp_mailer_args', `tcp $h 587')dnl define(`confauth_options', `a p')dnl trust_auth_mech(`external digest-md5 cram-md5 login plain')dnl define(`confauth_mechanisms', `external gssapi digest-md5 cram-md5 login plain')dnl feature(`authinfo',`hash -o /etc/mail/authinfo/gmail-auth.db')dnl i wondering there difference ` , ' here? why don't write define('smart_host','[smtp.gmail.com]')dnl define('relay_mailer_args', 'tcp $h 587')dnl define('esmtp_mailer_args', 'tcp $h 587')dnl define('confauth_options', 'a p')dnl trust_auth_mech('external digest-m

javascript - Wave animation for a character converted to svg -

Image
i have problems animating part of character 'w' converted svg. character styled out bit, has small flag @ left side (the part want animate). right when animation going, flag stretched vertically @ top of page. should stay @ same position was, top , bottom line of flag should in parallel ( in image sample below). code sample: var pathdata = "m253.477,175..."; var path = new paper.path(pathdata); var flags = { collection:[] } var flag = function(){ var model = { startindex:0, // start point in path.segments array middleindex:0,// middle point in path.segments array endindex:0, // end point in path.segments array height:20, // wave animation height segments:[] // flag segments } return model; }; var initializeflag = function(){ var segments = path.segments; //... for(var = flag.startindex; <= flag.endindex; i++ ){ flag.segments.push(segments[i]); } flags.collection.push(flag); //ad

asp.net - Wrong version of JQuery being loaded -

i opened old asp.net application working on , updated nuget packages. when try run app following errors: http://localhost:7055/scripts/jquery-1.8.2.min.js failed load resource: server responded status of 404 (not found) http://localhost:7055/scripts/jquery.signalr-1.0.0.js failed load resource: server responded status of 404 (not found)` the above taken chrome console tab. here page source shows in chrome: <!--script references. --> <!--reference jquery library. --> <script src="/scripts/jquery-1.8.2.min.js" ></script> <!--reference signalr library. --> <script src="/scripts/jquery.signalr-1.0.0.js"></script> <!--reference autogenerated signalr hub script. --> <script src="/signalr/hubs"></script> however, not versions referencing in actual source. here actual source: <!--script references. --> <!--reference jquery library. --> <script src="/scripts/

laravel - Destroy session of user when disabled by admin? -

imagine admin, decide disable or remove user. if user logged in , working system, must return login page in (while send first next request after kick admin). should do? in auth filter, if user not guest - check if disabled; if so, log him out. this not log him out if requests public (non-auth protected) route.. point anyway, since doesnt matter if user logged in or not. http://laravel.com/docs/4.2/routing#route-filters

database - Trouble decomposing to 3rd Normal Form (DB) -

i've started studying data bases i'm struggling specific part. i've read definition of each normal form still can't seem understand. here's example couldn't solve properly: **r(a,b,c,d,e,f)** a->b; b->cd; ad->e solution: r1(*a*,b,e); r2(*b*,c,d); r3(*a*,*f*) i can't understand why r3 that r3 make sure in 2nd normal form , there no update anomaly. f in r1 lead duplicate rows of a,b,e there multiple f values a. b , e values might either ambiguous or redundant.

javascript - How to get instagram id once user has authenticated (instagram-node) -

i'm trying instagram id of user once have authenticated on website. have no problem authenticating since can access_token when log-in own account , can use following code assuming know instaid of user exports.renderuser = function(req, res){ console.log("starting rendering"); var userid = "280430135"; api.user(userid, function(err, result, remaining, limit){ if(err){ console.log("current user " + err); } app.set('imgsource', result.profile_picture); app.use('/', routes); res.redirect('/'); }); }; am supposed instaid of user authentication code? exports.handleauth = function(req, res) { api.authorize_user(req.query.code, redirect_uri, function(err, result) { if (err) { console.log(err.body); res.send("didn't work"); } else { console.log('yay! access token ' + result.access_token); res.redirect('/'); } }); }; any appreciated. i'm

Custom sort Python list with certain strings always at beginning? -

i working in python 2.7. have list of strings this: mylist = ['is_local', 'quantity_123', 'actual_cost_456', 'actual_cost_123', 'quantity_456', 'total_items_123', 'id', 'total_items_456', 'name', 'postcode'] the list have id , name , postcode , is_local fields in it, other fields vary. i sort list starts set fields above, , has other fields in alphabetical order. for example: mylist.sort(custom_sort) print mylist ['id', 'name', 'postcode', 'is_local', 'actual_cost_123', 'actual_cost_456', 'quantity_123', 'quantity_456' ...] my problem how define custom_sort function. i've tried this: def custom_sort(a, b): if == 'id': return 1 elif == 'name': return 1 elif == 'postcode': return 1 elif == 'is_dispensing': return 1 elif > b: return 1

memory management - reference and value types c# -

learning c# memory management , faced weird me thing. dynamically allocate memory student object , change in method — being changed. dynamically allocate memory int object , change in method — isn't being changed. why?? class student { public int id; public string name; } class program { static void main(string[] args) { student s1 = new student(); s1.id = 5; s1.name = "myname"; changestud(s1); console.writeline(s1.id); console.writeline(s1.name); int x = new int(); x = 2; changeint(x); console.writeline(x); } static void changestud(student s) { s.id = 500; s.name = "changedname"; } static void changeint(int x) { x = 500; } } the output is: 500 changedname 2 passing class object value similar passing pointer data structure in non-object-oriented language, because passed memor

python - Flask-SQLAlchemy: Can't reconnect until invalid transaction is rolled back -

so using amazon web services rds run mysql server , using python's flask framework run application server , flask-sqlalchemy interface rds. my app config.py sqlalchemy_database_uri = '<rds host>' sqlalchemy_pool_recycle = 60 my __ init __.py from flask import flask flask.ext.sqlalchemy import sqlalchemy application = flask(__name__) application.config.from_object('config') db = sqlalchemy(application) i have main application.py from flask import flask application import db import flask.ext.restless application.models import person application = flask(__name__) application.debug=true db.init_app(application) @application.route('/') def index(): return "hello, world!" manager = flask.ext.restless.apimanager(application, flask_sqlalchemy_db=db) manager.create_api(person, methods=['get','post', 'delete']) if __name__ == '__main__': application.run(host='0.0.0.0') the models.py

java - How to stay in same activity after clicking button in android? -

i trying develop simple feedback application. when user enters invalid data should show error. after error detected fields should clear , should stay on same activity should do?here's code: package com.example.feedback; import android.os.bundle; import android.app.activity; import android.content.intent; import android.view.menu; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; import android.widget.radiogroup; import android.widget.toast; public class feedback extends activity { string s; boolean fill=true; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_feedback); final button bt1 = (button) findviewbyid(r.id.bt1); final edittext tv2 = (edittext) findviewbyid(r.id.tv2); final edittext tv1 = (edittext) findviewbyid(r.id.tv1); final edittext

javascript - Custom filter in Angular -

i have problem custom filter. can't include it's in project. firstly used filter: text. understand array initialized asynchronously , used custom filter. when include filter, have problem ($injector:unpr). sorry english. <div ng-controller="productlist products"> <form ng-submit="addproduct()"> <input type="text" placeholder="enter product" ng-model="producttitle"> <button>add</button> </form> <ul class="productlist"> <li ng-repeat="product in list track $index | custom:search"> {{product.title}} </li> </ul> <input type="text" placeholder="search" ng-model="search"> </div> app here angular.module('lists', []) .controller('productlist', function($scope) { $scope.list = []; $scope.addproduct = func

ios - Present GameCenter authenticationVC again -

Image
i'm facing little issue here , hope me figure out wrong. *the test project presented below can find here : http://goo.gl/wz84aa (fr) or https://goo.gl/0m8lrz (mega.nz) * i'm trying present user authentification view controller proposed apple gamecenter feature. more precisely, re-present if canceled on first time. i have game storyboard : gamenavigationcontroller : class gamenavigationcontroller: uinavigationcontroller { override func viewdidload() { super.viewdidload() nsnotificationcenter.defaultcenter().addobserver(self, selector: selector("showauthenticationviewcontroller"), name: presentauthenticationviewcontroller, object: nil) gamekithelper.sharedinstance.authenticatelocalplayer() } func showauthenticationviewcontroller() { let gamekithelper = gamekithelper.sharedinstance if let authenticationviewcontroller = gamekithelper.authenticationviewcontroller { self.topviewcontroller.

powershell - R Execution failed with the application has requested the Runtime to terminate it in an unusual way -

i new r, kindly me below error. calling r code using batch file (e.g: c:\batchfile\x.bat) in machine has dynamic memory i.e. based on load memory , cores increase. in above approach executing out error. r code using rodbcext korpus, akmeans, lsa, stringr, topicmodels, rweka, lda, snowfall, tm, opennlp, reshape2, plyr, rodbc packages. but while calling x.bat file using remote server within powershell (e.g.,invoke-command -computername 'servername' {start-process 'c:\batchfile\x.bat' -wait}) resulting below errors: loadlibrary failure: paging file small operation complete. just-in-time debugging errors this application has requested runtime terminate in unusual way. thanks in advance

SublimeREPL on Sublime Text 3 not importing Python 2.7 modules -

i have been trying configure sublimetext 3 run sublimerepl, setting runs idle, or pycharm ide, but, after trying different options checked in so, keeps returning: >>> import pandas traceback (most recent call last): file "<console>", line 1, in <module> importerror: no module named pandas >>> import os >>> os.environ['pythonpath'] traceback (most recent call last): file "<console>", line 1, in <module> file "/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/userdict.py", line 23, in __getitem__ raise keyerror(key) keyerror: 'pythonpath' i have tried editing sublimerepl.sublime-settings file default extend path file can see @ faq site of sublimerepl, still not work. does know how solved? i don't know if problem you, getting exact same error , learned opening sublime text command line (e.g. 'subl .' open directory, once have shor

php - Get current page and url in prestashop -

i trying url of current page in prestashop test multiple pages of website if website pages not have consistent pattern. noticed of prestashop pages of form /index.php?id_category=<categoryid>&controller=<controllername>, /index.php?id_product=<productid>&controller=<controllername> etc. able controller name using context::getcontext()->controller->php_self so, want know how product id or category id form current url of page? there's no need manually reconstruct link, can use link class. // context $context = context::getcontext(); // category id (on category , product page) $cid = $context->controller->getcategory()->id; // product id (on product page) $pid = $context->controller->getproduct()->id; // category link $cat_link = $context->link->getcategorylink($cid); // product link $prod_link = $context->link->getproductlink($pid);

sql server - Can data be transformed in the way below using SQL? I'm not sure a pivot would even work -

the users want data shown this: tax description ml total link link link link link link code rate code rate rate code rate sc001 abbeville county, sc y 0.0700 sc 0.0600 sclo1 0.0100 sc002 aiken county, sc y 0.0800 sc 0.0600 sccp1 0.0100 scec1 0.0100 but data stored in database this: tax description ml link link code rate link description sc001 abbeville county, sc y 0.0600 sc south carolina state sc001 abbeville county, sc y 0.0100 sclo1 local option 1% sc002 aiken county, sc y 0.0600 sc south carolina state sc002 aiken county, sc y 0.0100 sccp1 capital projects 1% sc002 aiken county, sc y 0.0100 scec1 education capital improvement i ho

java - Reflection of setter, getter method -

i trying implement reflection code in java. new using reflections , have existing method this: scheduleparams incomeresetfxschedule = performanceswapleg.getincomefxresetschedule(); if (performanceswapleg.getincomefxresetschedule().getdateroll() != null) { incomeresetfxschedule.setdateroll(dateroll.valueof(performanceswapleg.getincomefxresetschedule().getdateroll().tostring())); } else { incomeresetfxschedule.setdateroll(dateroll.valueof(dateroll.s_preceding)); } i trying write reflection code above code , stuck @ point: try { class<scheduleparams> incomefxresetschedule = scheduleparams.class; class<dateroll> dateroll = dateroll.class; try { method m = performanceswapleg.class.getmethod("getincomefxresetschedule"); m.invoke(performanceswapleg); method m1 = scheduleparams.class.getmethod("setdateroll", dateroll); m1.invoke(performanceswapleg);

Reset CSS settings from Javascript -

is there way reset settings of css element? have input want validate , not possible because set border of text input red can't come settings of css automatically. there way it? in advance. edit 1 <input id="tm" type="text" onchange="validatestarttime()" name="orario_start" placeholder="orario inizio"> and validatestarttime() is function validatestarttime(){ var t_st=document.getelementsbyname("orario_start"); t_st[0].style.bordercolor="gray";//here want set css settings automatically if(t_st[0].value.length==0){ t_st[0].style.bordercolor="red"; flag=false; } //validation time var t1=t_st[0].value.split(" "); if(t1.length!=2){ t_st[0].style.bordercolor="red"; flag=false; }else{ var t1_1=t1[0].split(":"); if(t1_1.length!=2){

java - Getting values from a collection with a complex JPA query -

Image
i trying materials purchase order (po) id. there few collections in path , join tables. po.java @entity @table(name = "t_po") @cache(usage = cacheconcurrencystrategy.nonstrict_read_write) public class po implements serializable { @manytoone @joincolumn(name = "customer_id", referencedcolumnname = "id") private customer customer; @onetomany(mappedby = "po", targetentity = po_part.class) private list<po_part> partlist; part.java @entity @table(name = "t_part") @cache(usage = cacheconcurrencystrategy.nonstrict_read_write) public class part implements serializable { @manytomany @cache(usage = cacheconcurrencystrategy.nonstrict_read_write) @jointable(name = "t_part_material", joincolumns = @joincolumn(name="parts_id", referencedcolumnname="id"), inversejoincolumns = @joincolumn(name="materials_id", referencedcolumnname="id")