Posts

Showing posts from May, 2013

php - Not Able To Run Consolecommand From Cron Tab -

i have written consolecommand runs awesome windows command prompt , linux terminal. problem , when add command in cron tab following error when been executed. this script must run command line. what problem ? here go: class reportgeneratorcommand extends cconsolecommand { public function gethelp(){ echo 'this command genearates periodic reports'."\n\n"; return; } public function run($args){ echo "\n hello world! \n"; } } i used run command cron as php /home/pathtomyapp/console.php mycommand now modified to /usr/local/bin/php /home/pathtomyapp/console.php mycommand and did !

python - 'Flask' object has no attribute 'post' error for login unit test -

i trying test log in functionality flask-testing. i'm following flask docs on testing well. test_login() function raises attributeerror: 'flask' object has no attribute 'post' . why getting error? traceback (most recent call last): file "/home/lucas/pycharmprojects/fyp/shares/tutorial/steps/test.py", line 57, in test_login_logout rv = self.login('lucas', 'test') <br> <br> file "/home/lucas/pycharmprojects/fyp/shares/tutorial/steps/test.py", line 47, in login return self.app.post('/login', data=dict( attributeerror: 'flask' object has no attribute 'post' from flask.ext.testing import testcase flask import flask shares import db import manage class test(testcase): def create_app(self): app = flask(__name__) app.config['testing'] = true return app sqlalchemy_database_uri = "sqlite://" testing = true def setup(self): manage.initdb() def teard

objective c - Programmatically change focus after input text in UITextfield -

i have simple view has 2 textviews button. controls positioned vertically. can navigate 1 control using remote. however, i'm trying following scenario working: the user launches app (focus on first textfield) the user enters textfield , uses fullscreen keyboard, hits "next" button the app shows second textfield (fullscreen keyboard), types in text , hits "done" button the app leaves fullscreen keyboard , focuses button while step 1-3 working out of box, changing focus programatically (4) doesn't work. here's code: - (bool)textfieldshouldreturn:(uitextfield *)textfield { if(textfield == self.textfieldb) { self.activeview = self.textfieldb; [self setneedsfocusupdate]; [self updatefocusifneeded]; return yes; } return no; } and in - (uiview *)preferredfocusedview i'm returning whatever stored in self.activeview (yes, return button instance). methods called expected, focus doesn't change.

Perl pattern extraction from file -

i have text file : name : first file name : first_1 year : 12 etc etc etc t1 : t1 t2 : t2 t3 : t3 conclusion : success name : first file name : first_2 year : 13 etc etc etc t1 : t1 t2 : t2 t3 : t3 conclusion : success name : second file name : second_1 year : 12 etc etc etc t1 : t1 t2 : t2 t3 : t3 conclusion : failure name : first file name : first_3 year : 12 etc etc etc t1 : t1 t2 : t2 t3 : t3 conclusion : success and on..... i need perl script gives me following output: naming file_name year conclusion reason first first_1 12 success t1, t2, t3 first first_2 13 success t1, t2, t3 second second_1 12 failure t1, t2, t3 first first_3 12 success t1, t2, t3 the following need. reads file parse stdin. other array of lines. #!/usr/bin/perl use strict; $naming = ""; $file_name = ""; $year = "";

javascript - Adding an uploaded file as an <image> element in an SVG -

if uploads image <input type="file"/> , there million different ways add image somewhere <img> element or onto <canvas> . want instead add <image> element in svg , i'm totally stymied. if add uploaded file canvas , use canvas.getdataurl(), valid data url can use background image or whatever. setting xlink:href of <image> element url nothing. i've tried adding file directly without canvas step, e.g.: $("#file").on("change",function(){ $("image").attr("xlink:href",this.files[0]); }); that seems still image won't display. have width , height set on it. i've tried various blob url methods , don't anything. how can take image file file input , display <image> element in svg? any assistance appreciated. the this.files[0] returns file object. xlink:href attribute assigment takes string. automatic conversion of file object string results in attribute bein

java - Signal between threads -

this interview question in pseudo code. told there problems in following approach. not find else other holding main thread while event waiting. can guys see real issues? here question: there main thread , child thread. child thread monitoring on 30k message, sent in 1k chunks external source. once child thread sees 1k chunk ready, signals main thread function retrieve data. pseudo code is: // method called in main thread void mainthreadfunction(out message) { var buffer; loop { event.wait; read data buffer; event.release; if (all data of message complete) { exit loop; } } copy buffer message; } // method in child thread void childthreadfunction() { // once 1k chunk of data ready event.set; } the child thread not wait main thread read data, can start overwriting new data before old data read. typically in kind of situation, maintain 2 or more buffers child thr

angularjs - failed to load resource (traceur) Angular 2 -

Image
i have error in project. when load project, doesn't show template , gives error.

clojure - Right-shifting 32-bit ints -

clojure's bit-shift operations seem return 64-bit long results, 32-bit int arguments. not substantial problem bit-shift-left : user=> (format "%08x" (unchecked-int (bit-shift-left (unchecked-int 0x12345678) 4))) "23456780" user=> (format "%08x" (unchecked-int (bit-shift-left (unchecked-int 0xf2345678) 4))) "23456780" however, becomes problem unsigned right-shifting of negative numbers: user=> (format "%08x" (unchecked-int (unsigned-bit-shift-right (unchecked-int 0xf2345678) 4))) "ff234567" the correct answer, of course, 0f234567 . what efficient way implement 32-bit unsigned right-shifting in clojure? this can accomplished calling int clojure.lang.numbers.unsignedshiftrightint(int, int) method uses >>> on int arguments, returning int . it's not exposed function anywhere, have intrinsic implementation (equivalent >>> in java) , can either call directly or wrap in

python - How can I get number of rows and columns selected by excel COM interface? -

i can area selected application's .selection property. (i'm using python access excel com interface) i want know how many rows , columns user have selected, instance input: user has selected a1:g8 output: selected range starts column 1 (by selection.column) selected range starts row 1 (by selection.column) selected range spanning 7 rows (by ?) selected range spanning 8 columns (by ?) i'm looking @ msdn's range interface , property's doesn't seems helpful problem. from vba, this: debug.print selection.rows.count debug.print selection.columns.count debug.print selection.row debug.print selection.column with a1:g8 selected, returns 8 7 1 1 is translated python>

java - graph algorithm for (economic) share graph -

hi graph theory experts :) i'm facing algorithmic problem cannot solve myself. i have find indirect shares each company each other in directed graph containing direct shares (see image simple example). i have start directed graph nodes companies , edges direct shares between these companies. algorithm has append indirect shares between nodes edges (this includes adding new edges graph during algorithm). an indirect share defined product of intermediate direct shares. if there nodes a, b , c in graph, there 1 indirect share, 1 c. indirect(a, c) = 100% * 80% = 1 * 0.8 = 0.8 = 80% now need algorithm computes shares whole graph. there no specific starting point in graph, , may contain variety of circles of each size (in example there 1 "direct" circle between c , d) , multiple paths between pair of nodes (like paths c e). it helpful if me out pseudo code or description of possible algorithm. searched algorithms in graph theory books , on internet, can find s

knockout.js api search form -

the goal of code search on api search string: so if fill out form hits bij name. i used following knockout.js script: var viewmodel= { query : ko.observable("wis"), }; function employeesviewmodel(query) { var self = this; self.employees = ko.observablearray(); self.query = ko.observable(query); self.baseuri = base + "/api/v1/search?resource=employees&field=achternaam&q="; self.apiurl = ko.computed(function() { return self.baseuri + self.query(); }, self); //$.getjson(baseuri, self.employees); //$.getjson(self.baseuri, self.employees); $.getjson(self.apiurl(), self.employees); }; $(document).ready(function () { ko.applybindings(new employeesviewmodel(viewmodel.query())); }); the html binding is: <input type="text" class="search-query" placeholder="search" id="global-search" data-bind="value: query, valueupdate: 'keyup'"/> but

java - Why won't this code deadlock? -

i'm investigating deadlock problem on settext need first learn , understand deadlocks. end have created short program try , replicate may happening on larger scale unsure why smaller program never deadlocks. here learning program: public static void main(string[] a) { jframe frame = new jframe(); final jtextfield p = new jtextfield("start"); jbutton btn = new jbutton("button"); btn.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent e) { swingutilities.invokelater(new runnable(){ @override public void run(){ p.settext(string.valueof(system.nanotime())); } }); } }); frame.getcontentpane().setlayout(new flowlayout()); frame.getcontentpane().add(p); frame.getcontentpane().add(btn); frame.setsize(400, 400); frame.setdefaultcloseoperation(frame.exit_on_c

c - Can I get some advice on the easiest way to parse the provided string -

the string: phillip:22021999;football,tennis,basketball i want line read these variables in following manner: char name[50] = phillip int dob = 22021999 char (*a[10])[14] = 'football', 'tennis','basketball' any advice appreciated. #include <stdio.h> #include <stdlib.h> #include <string.h> enum { max_num_of_field = 10, field_size = 14 }; int main(void) { char *the_string = "phillip:22021999;football,tennis,basketball\n"; char name[50]; int dob; char (*a[max_num_of_field])[field_size] = { null }; char rest[max_num_of_field*(field_size+1)]; sscanf(the_string, "%49[^:]:%d;%149[^\n]", name, &dob, rest); int i;//, num_fields = 0; char *p; for(i = 0, p = strtok(rest, ",\n"); < max_num_of_field && p ; ++i, p = strtok(null, ",\n")){ char (*afield)[field_size] = calloc(1, sizeof(char[field_size])); strncpy(*afield, p, field_

c# - Graphics CopyFromScreen off when font/icon scaling is enabled -

need c# windows forms program. on .net 4.0. i use following (snippet of) code capture composited image window: var location = pointtoscreen(picvisualizer.location); ... g.copyfromscreen(location, new point(0, 0), picvisualizer.size, copypixeloperation.sourcecopy); picvisualizer picturebox control in window. works intended, long user keeps windows font/icon scaling @ 100%. if change, image captured right size offset, capturing part of window, desktop, etc. i've tried variety of solutions give me same location value, end result same. i've tried autoscalemode none, font, dpi , inherit, , 4 gave me same result. is there way tweak code it'll capture correct part of screen when display scaling not @ 100%? thanks. the answer suggested blorgbeard works beautifully. picvisualizer.drawtobitmap(bitmap, picvisualizer.clientrectangle); thanks.

ios - UIAlertViewController flickers/blinks briefly -

i'm using swift code display alert dialog uiviewcontroller import uikit class testviewcontroller: uiviewcontroller { @ibaction func ontestclick(sender: uibutton) { let alertcontroller = uialertcontroller(title: "title", message: "message", preferredstyle: .alert) alertcontroller.addaction(uialertaction(title: "ok", style: .default, handler: nil)) self.presentviewcontroller(alertcontroller, animated: true, completion: nil) } } when alert shown view dark (e.g. black) background, briefly "flickers" (appears white , instantly change color darker white). this doesn't seem happen on other apps , system os. what's problem here? i able reproduce saying , don't think doing wrong. if turn slow animations on simulator (cmd + t) see alert controller being positioned in center of screen in fade animation. when animation in progress alert controller has white background (and apple's co

How to building function for codeigniter such as Wordpress -

i fetch data views, $article['article_title'] article title <?php foreach ($articles $article) { ?> <a href="#"><?php echo $article['article_title']; ?></a> <!-- code here --> <? } ?> how create helper using the_title() (same wordpress function) replace $article['article_title'] ; <?php foreach ($articles $article) { ?> <a href="#"><?php echo the_title(); ?></a> <!-- code here --> <? } ?> i created function working id (segment), homepage don't working because not segment. it's question. you can way: create helper e.g.: function the_title() { $ci =& get_instance(); // if url looks http://localhost/this-is-my-page-name $slug = $ci->uri->segment(1); if($slug) { $query = $ci->db->where('slug', $slug)->get('pages')->row(); $result = $query->title;

java - Method for know unregistered tokens in APNS server (using Spring Server) -

successfully done push notification in android. , deal ios push notification. in case of gcm sever push notification, server notify token unregistered or invalid etc. likewise there method in apns server. please check code send push notification in apns public void pushmessage() { apnsservice service = null; try { // certificate inputstream certstream = this.getclass().getclassloader().getresourceasstream("your_certificate.p12"); service = apns.newservice().withcert(certstream, "your_cert_password").withsandboxdestination().build(); // or // service = apns.newservice().withcert(certstream, // "your_cert_password").withproductiondestination().build(); service.start(); // read user list list<user> userlist = userdao.readusers(); (user user : userlist) { try { // had dai

android - Is there any way from which we can detect images are loading from cache in picasso? -

Image
as title suggest want check whether images loading cache or not. i've done couldn't succeeded. picasso.with(getapplicationcontext()) .load(data.get(position).get("product_image")) .into(viewholder.imgviewicon, new callback() { @override public void onsuccess() { viewholder.imgviewicon.setvisibility(view.visible); if (picasso.loadedfrom.network != null) yoyo.with(techniques.zoomin).duration(1200) .playon(viewholder.imgviewicon); viewholder.placeholder.setvisibility(view.gone); } @override public void onerror() { } }); please have batter option tell me. thanks. use picasso's setindicatorenabled(true) detect image loaded from. picasso picasso =

javascript - Trouble with Dojo Build and Conversion to AMD -

i'm working on dojo application written else. i'm new dojo, have discovered reduce http requests need produce "build" version. have done, afaict (i single compressed script @ least), when using built script, none of functions available work (they're "undefined"). furthermore, in trying figure out, looks though point make code amd compatible (is code amd compatible?). how work examples such 1 below? reading appears might need make each existing function scripts module, produce hundreds of scripts, , doesn't feel right. how best convert code such amd compatible , buildable? i've got 15 or .js scripts containing varying numbers of functions written way... tia! var somethingstatus = false; somethinginit(); function somethinginit() { require(["dojo/ready", "dojo/dom", "dojo/dom-construct", "dojo/cookie", "dojo/json", "dojo/domready!"], function(ready, dom, domconstruct

ios - Parse push notifications when data changes -

this general question design direction. working on weather app right now, have user accounts, weather data web server. able retrieve weather app , post these data in parse. want if temperature out of range, send push notification app. question how can receive notification when app not running or running in background? thoughts, directions, keywords appreciated. thanks! you need use parse cloud code , send push notification when server notified change. 1 way can think of schedule job (look @ console - core -> jobs) run let's every hour , check temperature , send push if meets 1 of conditions. good luck

mule - RAML loading in cloudhub taking prolonged time -

Image
i created mule application , able run/deploy on local machine successfully. when changed port private , deployed cloudhub, raml's console not loading completed. same question post in below link. mule esb server: raml loading prolonged time could please me out. how big raml? there bug found uploads larger size timing out , erroring in backend. if watched network traffic see 504 error being returned request. that particular 1 got fixed on 27th january issue might solved now?

c# - OpenText vs ReadLines -

i came across implementation of reading file line line looks this: using (streamreader reader = file.opentext(path)) while (!reader.endofstream) { string line = reader.readline(); } however this: foreach (string line in file.readlines(path)) { } is there reason pick 1 on other? objectively: the first 1 picking line 1 one , process stream data. the second 1 generates ienumerable<string> @ once , can start processing lines (source msdn - apologize mix readalllines @ first). usefulness?: the first 1 more "fluid" in sense. because can choose take/process , break/continue @ will. everytime need line, take one, process , choose break or continue. can choose not take further line (suppose have yield in while loop) till want come @ will the second 1 ienumerable<string> (that is, specify info of expected data before process) giving overhead @ first. noted, however, overhead relatively small ienumerable defer actual execution, unl

PHP Json array decode in php and inserting mysql -

this question has answer here: how extract data json php? 2 answers "sci-6":{"quantity":11,"id":"sci-6","price":15,"name":"notebooks"}, "sci-7":{"quantity":1,"id":"sci-7","price":10,"name":"posters"}, "sci-8":{"quantity":2,"id":"sci-8","price":15,"name":"pen"}, "sci-9":{"quantity":4,"id":"sci-9","price":100,"name":"charger"}, "sci-10":{"quantity":1,"id":"sci-10","price":10.25,"name":"news paper"} please me decode variables , insert values mysql using php $data = '{"sci-6":{"quantity":11,&q

java - Paypal certificate upgrade to sha256 -

paypal has updated sandbox api endpoint , certificate use sha256 instead of sha1. migrate application (which connects paypal express checkout) use sha256, a) deleted , downloaded new certificate paypal account , converted .p12 format using openssl confirmed certificate using sha256withrsa b) confirmed /etc/ssl/certs/ca-certs.crt having verisign g5 ca certificate given in link https://gist.github.com/robglas/3ef9582c6292470a1743 still unable connect paypal sandbox java code uses httpclient. failing during handshake in java code - using sslcontext.getinstance("ssl") using custom truststore class customtrustmanager implements x509trustmanager { public boolean checkclienttrusted(java.security.cert.x509certificate[] chain) { return true; } public boolean isservertrusted(java.security.cert.x509certificate[] chain) { return true; } public java.security.cert.x509certificate[] getacceptedissuers() { return null; } public void checkclienttrusted(java.s

python - ProgrammingError at / relation "xxx" does not exist / Error during template rendering -

i'm building django on heroku , i'm getting "error during template rendering" error on heroku. when running locally works fine. in addition, i'm printing field i'm trying render before rendering page , see exists , valid. template simple: this urls.py from django.conf.urls import patterns, include, url django.contrib import admin perfil import views urlpatterns = patterns('', url(r'^admin/', include(admin.site.urls)), url(r'^$', views.lista_dato), ) this models.py from django.db import models django.utils import timezone # create models here. class dato(models.model): #author = models.foreignkey('auth.user') nombre = models.charfield(max_length=50) nacimiento = models.datefield(blank=true, null=true) cedula = models.integerfield(max_length=50) tarjeta_profesional = models.charfield(max_length=50) celular = models.charfield(max_length=100) email = models.emailfield(max_length

c# - Dynamically add Children to WPF UserControl and Handle its events from WinForm -

i have simple wpf usercontrol called "xnavpanel" contains panel. added control winform using "elementhost". have wpf usercontrol called "mainmenubutton" contains textblock. from winform; add many "mainmenubutton" in "xnavpanel" dynamically in runtime. have method loop on datatable rows , foreach row adding "mainmenubutton" "xnavpanel" , add event handler each "mainmenubutton". the problem is; controls doesn't invoke handlers! public static void fillmenu(xnavpanel navpanel, datatable items) { navpanel.mainpanel.children.clear(); //mainpanel panel inside usercontrol mainmenubutton menuitem; foreach (datarow dr in items.rows) { menuitem = setmenuitem(dr); navpanel.mainpanel.children.add(menuitem); } } static mainmenubutton setmenuitem(datarow dr) { mainmenubutton menuitem = new mainmenubutton(); menuitem.name = "mi_" + dr["formname"

php - Getting SQL error 1136 -

i getting sql error 1136. config file correct , contains $conn variable connecting database. <?php include './config.php'; $field = [ "test_id", "testcase_id", "circle_name", "performed_date", "assign_to", "assign_by", "status", "comment", "device_used", "testsuite_id", "simcard_no", "time", "review", "redirection_issue", "price_point_mismatch_issue", "subscription_on_first_concent", "landing_page_issue" ]; $testid = '12342004'; $value = 'tc_3ja_1'; $circle = 'gujarat'; $date_created = '16/01/21'; $assigned_to = 'chirag.parekh'; $assign_by = 'brijesh.mashruwala'; $current_status = 'pass'; $current_comment = ''; $action = ''; $device = 'xperia tipo'; $tsuite = '

How to change Visual Studio 2012 Razor colors -

i change yellow background color of razor tags in vs12. optional: install color theme editor: http://visualstudiogallery.msdn.microsoft.com/366ad100-0003-4c9a-81a8-337d4e7ace05 in theme editor or tools > options > environment > fonts , colors search for: 'html server-side script' edit foreground & background of @ , other tags. search for: 'razor code' edit background of razor code.

Include all pages in tampermonkey(userscript) -

i have include sites in tampermonkey..this script have run // ==userscript== // @name phishing blockz // @namespace http://use.i.e.your.homepage/ // @version 0.1 // @description phishing block based on hyperlinks // @match http://*/* // @run-at document-end var req = new xmlhttprequest(); req.open('get', document.location, false); req.send(null); var headers = req.status; var locheader=req.getresponseheader("location"); alert(headers); alert(locheader); have done wrong.please me run userscript in pages in chrome // @match http://*/* will match addresses starting http://... not https://... example. use following include all addresses if that's require (including local pages may have saved on hard-drive!).. // @match *://*/* note: method below works @ time of writing virtue of potential bug or undocumented feature in tm2.12 (so subject change in future versions!!): // @match *

Calling web API and Receive return value in Android -

i've googled topics , don't useful information. i want use web api in android projects, don't know how call them android or java i've got web api this site , want use in android project. example, web api url : /api/uname2uid/{uname}. that convert user name user numeric id i want display user id returned api textview . need return value string or number. please me this. edit want learn how use web api for more simplicity: in program have textview , a edittext , button when press button textview update corresponding user id username given in edittext field thats all. working example great me understanding this. a simple async call thing you.: mainactivity.java new yourasync(){ protected void onpostexecute(object[] result) { string response = result[1].tostring(); try{ jsonobject jsonobject=(new jsonobject(jsonresult)).getjsonobject("data"); //parsing json obje

sqlite - Is it possible to separate multiple values pulled in from a SQLite3 Row using Python? -

i have database row links, example, name mike description blonde, short, glasses. current, if run person.description, prints out this: " ""blonde""", 'short', 'glasses', is possible separate these values , eliminate '"'s? here few things i've tried: in person: j in i['description']: print j this returns each descriptive word character character: " " " b l o n d e " " " , next tried: for in plugins: print i['sets_kb_item'] this returned: " ""blonde""", 'short', 'glasses', i've tried this, trying lucky: in person: j in i: print j['description'] but gave me typeerror: typeerror: 'int' object has no attribute '__getitem__' here example of row in sqlite database querying: name: description: mike 'blond

html - Structuring div 's created by "createElement" in JavaScript -

structuring div's in html goes this: <div id="parentdiv"> <div id="childdiv"></div> </div> my code bellow creates 2 divs, places child div next parent div instead of inside it: var pardiv = document.createelement('pardiv'); pardiv.setattribute('id', "workspace"); pardiv.innerhtml = "hello world"; pardiv.style.background = "red"; pardiv.width = 300; pardiv.height = 300; document.body.appendchild(pardiv); var childdiv = document.createelement('childdiv'); childdiv.setattribute('id', "childdiv"); childdiv.innerhtml = "hello world"; childdiv.style.background = "yellow"; childdiv.width = 100; childdiv.height = 100; document.body.appendchild(childdiv); how can programmer structure div's in html if created through javascript? don't append childdiv body, instead, append parent element so: pardiv.

python - How to check if a string contains any one of the value of a list in a query in Django ORM -

i need create query in want check if field "answer_string" contains 1 of value list. i did in way: q=queryset.filter(reduce(operator.and_, (q(answer_string__contains = item) item in answerlist))) there no. of checkboxes user can select multiple answers , have created list.any value in answer_string field can contain multiple answers in string. want check if string contains 1 of value list should take yes. this query wrote returns me 0 results. please? if want check if field contains "any" value of list use operator.or_ operator.and_ concatenates smaller q objects and . current query searching field value contains list values.

javascript - position() in jquery ui -

i new jquery ui. reading position() docs of jquery ui. includes details 'of', 'at' , 'my' arguments. i clear 'of' argument, still confused ' at ' , ' my ' arguments. as per understanding, believe 1 of them required. can let me know why both of them required? moreover, tells target element , positioned element. can let me know, point to, taking example ? sorry such simple question , bad english. thanks in advance. it tells target element , positioned element. can let me know, point to i clear 'of' argument two of statements in conflict here. if clear of argument, should know target element already. positioned element element want position. let's call a . target element element relative want position a . of used specify target element. my , at used specify how want position these. my specifies positioning of a , , at specify how should positioned relative target. for exampl

ios - How to disable sharing on UITextView without using non-public APIs and Rejected by apple? -

my latest release apple rejected following response. your app uses or references following non-public apis, violation of app store review guidelines: _share: the use of non-public apis not permitted in app store because can lead poor user experience should these apis change. i have thoroughly searched app in xcode _share: method. using disable sharing on 1 of uitextview this. @implementation uitextviewdisableshare : uitextview - (bool)canperformaction:(sel)action withsender:(id)sender { if (action == @selector(_share:)) return no; return [super canperformaction:action withsender:sender]; } @end there lot of questions on stack-overflow suggest use above code disable copy, paste or share options programmatically e.g this . need disable sharing option, can't set userinteractionenabled=no . one of app release accepted app store above code in it. how should disable sharing on uitextview, not conflicts of apple's review guide lines ,

javascript - var NAME = function NAME (){ }; - Function Name used twice -

in javascript, 1 standard way declare function follows: var add = function(a,b){ return a+b; }; however, when repeat function name on right side of syntax, no errors either. var add = function add(a,b){ return a+b; }; what's going on in second case? there 2 uses of function keyword in javascript: function declarations , function expressions . function declarations don't allow left of keyword, e.g. function add(a,b){ return a+b; } and always require name, e.g. add . meanwhile, examples invoke other type, function expressions , don't require name (but can named!) , always require left, e.g. your var add = function(a,b){ return a+b; }; or single parenthesis: (function(a,b){ return a+b; })(1,2); // 3 so we've got vocabulary down, you've got in second example, reprinted— var add = function add(a,b){ return a+b; }; —is function expression (namely, variable assignment add ) function happens named . now,

architecture - Connect Azure Mobile Service with ASP.NET Web API -

is possible connect azure mobile service asp.net web api app? want use features included in ams, business logic belongs web api can reuse in web app (maybe asp.net mvc). possible? in advanced. this possible. you can use azure app service mobile apps service run service. provides same facilities azure mobile services, entirely contained within asp.net web app (or node.js web app). it's sdk on top of asp.net application. for more information on this, see the documentation .

node.js - Where are the sources for phantomjs 1.9.19? -

i trying build phantom version 1.9.19 armv8-a processor. however, when checked out project's github page latest 1.9.x release found 1.9.8 . where can find sources 1.9.19 ? background version 1.9.19 required facebooks osquery . since not come pre-build arm have manually build , dependencies. breaks info phantomjs@1.9.19 failed exec install script . there no phantomjs 1.9.19. phantomjs npm package supposed easy way install phantomjs , version corresponds phantomjs version contains, started go off rails version 1.9.8 onwards (which contains phantomjs 1.9.7). maintainer messed up. phantomjs 1.9.8 last version of 1.x branch. can compile , create own phantomjs package version need.

cmd - How to give relative path? -

i want in folder c:\eclipsemars\workspace\deploy , have give relative path master\gradlew.bat. i gave this cd c:\eclipsemars\workspace\deploy..\master\gradlew.bat showing error system cannot find path specified. how give path correctly?

push - Point existing code to new location of the remote respository in GIT -

i moved remote repository ( git ) on server , path changed. but, mistake had committed few changes forgot push last commit. when pushing still trying @ old location. how can start pointing same local code base new git repository can continue working without having re-clone repository , re-apply un-pushed changes? git.exe push --progress "origin" master:master remote: not found fatal: repository ' http://server.com/username/repo-name.git/ ' not found you use below command change link new remote git remote set-url origin {new url.git} you verify change by git remote -v the above commands assume remote repository named "origin", default nomenclature using git, can make suitable change based on local environment. more details can found @ https://help.github.com/articles/changing-a-remote-s-url/

systemtap : Able to access local variables but cannot access local pointers -

i have dumb question, wanted understand source code flow of system tap, trying access local variable using kernel.statement probe function, displays other variable except pointers. probe module("module_path/proc_rw.ko").statement("my_write@module src path/proc_rw.c+9") { printf("local = %s\n", $$locals) } module code : static ssize_t my_write(struct file *f, const char __user *buf, size_t len, loff_t *off) { pid_t pid; int ret; struct task_struct *task_local; int *i; ret=copy_from_user(c, buf, len); i=&ret; pid=simple_strtol(buf, null, 10); task_local=pid_task(find_vpid(pid), pidtype_pid); return len; } when execute above stap code, returns, local = pid=0xf98 ret=0x0 task_local=? i=? any understand why task_local , values not printed helpful. regards, yash. what you're seeing here artefact of compiler optimization. variables no longer used m

oracle - DBeaver simple query ORA-00911 invalid character -

i switching sqldeveloper dbeaver in work oracle 10g database, have oracle instantclient exact version of database. i not make scripts, bunch of queries, select, update. had collection of them, each on 1 or few lines, semicolon @ end, followed 2 dashes , comment. multiple line statements visual separation separated lines of many dashes. sqldeveloper treated such system well, ctrl+enter executed line (or group last comment or semicolon next semicolon), ignored comment after or before. copied whole collection 1 programs main window other (sql editor). usage results weird. example in new sql editor tab (table names changed, ignore if got reserved words): select * file_movement movement_status != 'moved' , last_update > sysdate -10 order last_update desc;--my comment, explanation select * activity activity_type = 'generator' , status = 'created' , started > sysdate -10 order started desc;--my other comment the first 1 executes expected ctrl+enter,

security - Windows Store Apps: How to implement credit card payments -

i'm developing windows store app includes module app users able pay bills app using credit cards. would please recommend technique implement such feature securely ? i wouldn't bother implementing myself. not because there's no way pull off because of 1 single reason: fraud . it took banks , clearing houses years straight. don't reinvent wheel , go established solution paypal or amazon payments.

Regex replace special comments -

so few months ago 1 of colleagues left. used comment code way: //---------------------------- // comment //---------------------------- private void func()... so each comment, instead of using 1 line @ most, uses 4 lines (including break line), drives me crazy. i'm trying create regex can remove comment safely , replace it. above code should way: // comment private void func()... i thought of removing each 1 of '//----------------------------' leaves me many empty lines break line between comment , actual line described. appreciated. edit note one: our project written in visual studio note two: comments may contain more 1 line of comment, example: //---------------------------- // line 1 comment // line 2 comment //---------------------------- this expression matches case , 3 lines of comments first , last ones have trailing - : ((\s|\t)*\/{2,})(.*[-]+)(\r?\n)((\1(.*)\4?)+)\4\1\3\4? try here and can replace with: \5 (or $5) edit: m

python - xml.sax parser and line numbers etc -

the task parse simple xml document, , analyze contents line number. the right python package seems xml.sax . how use it? after digging in documentation, found: the xmlreader.locator interface has information: getlinenumber() . the handler.contenthandler interface has setdocumenthandler() . the first thought create locator , pass contenthandler , , read information off locator during calls character() methods, etc. but, xmlreader.locator skeleton interface, , can return -1 of methods. poor user, do, short of writing whole parser , locator of own?? i'll answer own question presently. (well have, except arbitrary, annoying rule says can't.) i unable figure out using existing documentation (or web searches), , forced read source code xml.sax (under /usr/lib/python2.7/xml/sax/ on system). the xml.sax function make_parser() default creates real parser , kind of thing that? in source code 1 finds expatparser , defined in expatreader.py. and...it

java - Forcing a JPanel to repaint after calling the show method of CardLayout -

i'm writing holiday recommendation system piece of coursework. gui of uses cardlayout. in main class user object created default name , access levels defined in it's constructor. object passed main usercard panel passes login , logged in. if user logs in cardpanel transitions login logged in , supposed display username of logged in user calling user.getusername(); method. my problem thus. because of way card layout works panel username display has been created in constructor of usercards default values user object first created. need find way force panel repaint after show method called on cardlayout object. following code of 3 classes in question. (i've limited code paste relevant methods). //the usercards panel public usercards(user u) { cardlayout cl = new cardlayout(); this.setlayout(cl); useroptionspanel options_card = new useroptionspanel(cl, this); registerpanel register_card = new registerpanel(cl, this);

iphone - Why isn't Brightcove Player Loading in UIWebview? -

i'm noob iphone development , having trouble loading brightcove player uiwebview . aware ios can't play flash, don't need play video. want player , it's thumbnail visible in webview. when load brightcove player via url link in webview works fine, when try embed player doesn't load. resolving appreciated. my code: //via url link nsstring * storylink = @"http://link.brightcove.com/services/player/bcpid1683318714001?bckey=aq~~,aaaac59qsjk~,vyxcsd3otbphz2uirfx2-wdcltynymnn&bclid=1644543007001&bctid=2228912951001" nsurl *kitcourl = [nsurl urlwithstring:storylink]; nsurlrequest *requesturl = [nsurlrequest requestwithurl:kitcourl]; [videoscreen setuserinteractionenabled:yes]; [videoscreen loadrequest:requesturl]; //embedding player //brightcove player nsstring *htmlstr2 = [nsstring stringwithformat:@"<html><body><object id=\"flashobj\" width=\"320\" height=\"230\" classid=\"clsid:d27cdb6e-ae6

Android library/API for NFC reader/writers -

are there existing libraries allow android tablet (4.0.4) without nfc chip interface external usb nfc reader/writer? yes, acr 122 u can connected via usb otg cable. acr has android test app on driver page . in addition need nfc tools java interact reader (sending commands etc).

ubuntu - Gitlab wont start on reboot -

i installed gitlab 8.4 source using guide - http://doc.gitlab.com/ce/install/installation.html on ubuntu 14.04 , i'm having trouble getting started on boot. i used these commands tutorial make init script , run on boot. sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab sudo cp lib/support/init.d/gitlab.default.example /etc/default/gitlab sudo update-rc.d gitlab defaults 21 sudo service gitlab start works fine when server rebooted, gitlab wont start , nginx shows 502 bad gateway in browser. what problem?

java - How to log with same log4j.properties files for two different Spring-Boot Applications? -

suppose have 2 spring-boot applications called config , eureka . config made of: config /src/main /java /com.example demo.java /resources application.properties eureka made of: eureka /src/main /java /com.example demo.java /resources application.properties i have log4j.properties files log4j.rootlogger=info, stdout, file log4j.appender.stdout=org.apache.log4j.consoleappender log4j.appender.stdout.target=system.out log4j.appender.stdout.layout=org.apache.log4j.patternlayout log4j.appender.stdout.layout.conversionpattern=[%d{yyyy:mm:dd hh:mm:ss.sss}] - %p [%t] --- %c : %m%n log4j.appender.file=org.apache.log4j.fileappender log4j.appender.file.file=log.out log4j.appender.file.layout=org.apache.log4j.patternlayout log4j.appender.file.layout.conversionpattern=[%d{yyyy:mm:dd hh:mm:ss.sss}] - %p [%t] --- %c : %m%n one way log both config , eureka keeping copy of properties file in resources folder of both

Ruby method for convering Windows short path into long path? -

is there built-in method in ruby convert windows short path like c:\progra~2\micros~1.0\vc\bin\amd64 into corresponding long path c:\program files (x86)\microsoft visual studio 12.0\vc\bin\amd64 i've tried file.expand_path(short_path) pathname.new(short_path).cleanpath pathname.new(short_path).realpath dir.chdir(short_path) { dir.pwd } but none of these worked. if possible, i'd avoid calling win32 api directly in this answer , or ugly work-arounds spawning powershell: %x{powershell (get-item -literalpath #{short_path}).fullname} here 1 possible workaround: path=dir.mktmpdir('vendor') => "c:/users/admini~1/appdata/local/temp/1/vendor20160727-12668-ywfjol" dir.glob(path)[0] => "c:/users/administrator/appdata/local/temp/1/vendor20160727-12668-ywfjol"

python - How do I create a variable number of variables? -

how accomplish variable variables in python? here elaborative manual entry, instance: variable variables i have heard bad idea in general though, , security hole in python. true? use dictionaries accomplish this. dictionaries stores of keys , values. >>> dct = {'x': 1, 'y': 2, 'z': 3} >>> dct {'y': 2, 'x': 1, 'z': 3} >>> dct["y"] 2 you can use variable key names achieve effect of variable variables without security risk. >>> x = "spam" >>> z = {x: "eggs"} >>> z["spam"] 'eggs' make sense?

eclipse c++ function defined in header could not be resolved -

i trying compile c++ program however, getting error function 'argument' not resolved ...... semantic error however argument defined in app.h have included in project. i have included header files going project > properties > c/c++ general > paths , symbols > includes . under gnu c++ clicking add , file system , putting in path files. i can't figure out why getting error. the line giving me error is: arguments = { argument ("input", "input image", "the input image.").type_image_in (), argument ("ouput", "output image", "the output image.").type_image_out (), argument::end }; and in 'app.h': #define arguments const mr::argument __command_arguments[] solution: closing project , reopening solved problem...... solution: closing project , reopening solved problem......

c++ - How can I fix YouCompleteMe's wrong error highlighting of "cout" usage? -

i've been trying youcompleteme set on machine, , i'm there, except small problem. when use cout simple cout << "hello world!" << endl; , ycm highlights cout , first << , , string error, telling me: invalid operands binary expression ('ostream' (aka 'int') , 'const char *'). i know program correct. compiles , runs. causing behavior? let me know if left out information. thanks! edit: .ycm_extra_conf.py file this: import os import ycm_core # these compilation flags used in case there's no # compilation database set (by default, 1 not set). # change list of flags. yes, droid have been looking for. flags = [ '-wall', '-stdlib=libc++', '-std=c++11', '-x', 'c++', # path work on os x, paths don't exist not # harmful '-isystem', '/applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../lib/clang/7.0.2/include' '-isystem&

java - How to run SQL TRANSACTION in a PreparedStatement -

i have sql transaction query unable run. can 1 tell me please why? have failed run using preparedstament.executequery(); well. start transaction; select total_installment_remaining payment_loan loan_id = 1 update; update payment_loan set total_installment_remaining =total_installment_remaining-1 loan_id = 1; commit; turn off autocommit, use connection.commit() end transaction. connection.setautocommit(false); statement stmt = con2.createstatement(); // automatically start transaction resultset rs = stmt.executequery("select total_installment_remaining payment_loan loan_id = 1 update"); // process result if needed ... stmt.executeupdate("update payment_loan set total_installment_remaining =total_installment_remaining-1 loan_id = 1"); // end transaction , persist changes connection.commit(); if don't need result of select in code, don't need select ... update in first place, because update lock row anyway.

Android edit text with custom shape -

Image
how can edit text shape this. i mean right rounded corners , exact same shape. understood 9 patch doesn't me that. 9 patch best way in situation, create 9 patch , set background of edittext . here giving sample image, can try it. edittext.setbackground(r.drawable.edt_bg);

android - GCM registration failed -

i working google push notifications. able retrieve reg id failing register mobile in server.can me going wrong main activity: gcmregistrar.checkdevice(this); // make sure manifest set - comment out line // while developing app, uncomment when it's ready. gcmregistrar.checkmanifest(this); //setcontentview(r.layout.activity_main); // mdisplay = (textview) findviewbyid(r.id.display); registerreceiver(mhandlemessagereceiver, new intentfilter(display_message_action)); final string regid = gcmregistrar.getregistrationid(this); mdisplay.append("reg id" + regid + " "); if (regid.equals("")) { // automatically registers application on startup. gcmregistrar.register(this, sender_id); //mdisplay.append("reg id" + regid + " "); } else { // device registered on gcm, check server. if (gcmregistrar.isregisteredonserver(this)) { // skips