Posts

Showing posts from July, 2014

java - Given a Node, how can I select the equivalent Node in a Document? -

my caller handing me org.w3c.dom.node , org.w3c.dom.document serves owner document . supplied node , in other words, guaranteed parented in supplied document , , represents node in document against work should performed. i in position need clone document (i need perform modifications, , cannot modify source.) obviously, if that, node still have in hand not owned new document resulting clone. have lost selection in cloned document . however, know there node in cloned document equal node have in hand. need find it. what best way accomplish this, short of plowing through whole document , calling isequalnode(node) on each one? i thought perhaps there way document.find(myunparentednode) , no such method exists. you generate xpath describes position of node in old document , apply new document. see this question approaches how that. if it's possible modify node before cloning give unique attribute doesn't collide else (e.g. generated randomly) ...

php - No input file specified when typing homestead.app as the url -

so have installed laravel through composer, virtual box machine , homestead. fine when try access url homestead.app shown in instructions, no input file specified. below content of homestead.yaml... folders, pointed local area have laravel source called installed under xampp/htdocs... doing wrong ? --- ip: "192.168.10.10" memory: 2048 cpus: 1 provider: virtualbox authorize: ~/.ssh/id_rsa.pub keys: - ~/.ssh/id_rsa folders: - map: c:/xampp/htdocs/learning-laravel-5/public to: /home/vagrant/code sites: - map: homestead.app to: /home/vagrant/code/laravel/public databases: - homestead variables: - key: app_env value: local # blackfire: # - id: foo # token: bar your configuration bit off believe. first map project's public directory virtual box's code directory. map site laravel/public directory inside directory mapped. in fact trying access c:/xampp/htdocs/learning-laravel-5/public/laravel/public web...

Missing Visual Studio Project Template for Xamarin Shared Project -

Image
visual studio 2013 update 4 not show shared project template. have xamarin forms project templates. installed fresh update of xamarin morning. based on i've found far, used issue vs update 2. idea on how shared project template show up? from xamarin support: no, there's no optional bits missing. think visual studio update 4 removed shared project template. it's microsoft template, not xamarin one. can still create xamarin.forms app shared project (that's our template), no longer allow create independent shared project. so, 3 ways create 1 if using visual studio 2013: 1) switch xamarin studio , create there , close , reopen solution in vs. vs recognize project, doesn't have template create anymore. easiest approach. 2) install "shared project template" online templates - 3rd party template; i've not tried if want stay in vs , have template, it's worth shot. 3) create either universal wind...

sorting - Access violation in Masm when accessing memory offset -

i'm trying to selection sort in x86 assembly , i'm getting access error violation when try use variable access offset of array. .data array byte "fairy tale" count = ($ - array) minindex byte ? .code _main proc mov eax, 0 mov ebx, 0 mov ecx, count ; move array count counter register dec ecx ; decrease counter lea esi, array mov bl, 0 ; = 0 l1: push ecx mov minindex, bl ; minindex = mov al, minindex[esi] ; gives error ; rest of code... ret _main endp end _main there no build errors, access violation @ run time. not allowed such operation in masm? there workaround? mov al, minindex[esi] if think take value of minindex , use offset esi in read operation, you're incorrect. use the address of minindex . you can change code to: movzx eax,byte ptr minindex ; zero-exten...

java - Loader instantiation throws nullpointer in JavaFX -

i have declared 2 fxml files , controller each one: rootlayoutcontroller controller rootlayout.fxml , overviewcontroller controller overview.fxml rootlayout has menu bar file open item, , overviewcontroller has draw button. i have class called datastructure. want open file , send path overviewcontroller. when click draw constructor of dartastructure shall instantiated, path parameter. click open, on file chooser open dialog, program throws nullpointer in handleopen() method. source not found! in main class wrap overview in rootlayout , show stage. rootlayoutcontroller: public class rootlayoutcontroller { private final model model; public rootlayoutcontroller(model model){ this.model = model; } /** * opens filechooser let user select .z3lgm file load. */ @fxml private void handleopen() { filechooser filechooser = new filechooser(); // set extension filter filechooser.extensionfilter extfilter = new filechooser.extensionfilter( "3lg...

c# - Why doesn't Json.net properly serialize a class derived from TreeNode? -

i have class inherited treenode when try serialize returns string that's not json string (as expected). for example: string json = jsonconvert.serializeobject(new a()); output: "treenode: " where a defined as: public class : treenode { public int x { get; set; } } if remove treenode inheritance, output is: {"x":0} why doesn't serialize property if it's inherited treenode ? note: filter class serialize public properties of a class, using contract: public class shouldserializecontractresolver : defaultcontractresolver { private list<string> propertiesnames; public shouldserializecontractresolver(type type) { this.propertiesnames = type.getproperties(bindingflags.public | bindingflags.instance | bindingflags.declaredonly) .select(p => p.name) .tolist(); } protected override jsonproperty createproperty(memberinfo member, memberserialization memberserializat...

Import .xlsx to oracle sql developer error -

i exporting .xlsx file 1,000,000 rows sql developer using 'import data' function. however, error: error during handleevent on action 'import data... ' (id=998). none of attached controllers handled action. - oracle.ide.controller.ideaction$controllerdelegatingcontroller@6eb6ea5e[oracle.dbt ools.raptor.controls.sqldialog.objectactioncontroller] can please help? thanks! try using .xls file instead of .xlsx file. should work fine.

c# - Web Api OData: A null value was detected in the items of a collection property value -

i want return following records odata: player { numbers: [1, null, 3] } "numbers" being collection of nullable items (say ienumerable). odata has problem if of items in numbers collection null: a null value detected in items of collection property value; non-streaming instances of collection types not support null values items. is there way around it? i'm using web api odata 2.2 (v3) thanks, stevo try defining numbers property this: public ienumerable<int?> numbers { get; set; } i've tested such poco definition in-memory data: numbers = new int?[]{1,null,2} and works fine v4 service written using web api: numbers: [ 1, null, 2 ], i believe should work v3 service.

Android three circles different sizes -

hi have 3 circles in android show progress, custom element (viewprogressbar) inherit relative layout. <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center"> <com.theproject.ui.view.viewprogressbar android:id="@+id/vps_history_progress1" android:layout_width="wrap_content" android:layout_height="wrap_content" app:value= "@string/zero" app:subject = "@string/txt_progress1" /> <com.theproject.ui.view.viewprogressbar android:id="@+id/vps_history_progress2" android:layout_width="wrap_content" android:layout_height="wrap_content" app:value= "@string/zero" app:subject = "@string/txt_progress2" /> <com.theproject.ui.view.viewprogressbar android:id="@+id/vps_history_progress3...

delete part of string (word) in tcl -

in tcl have variable (string) witch come input text file. many... thing going faced on : a1 = lp89slc.at271300.0 a2 = lp89slc.at28742.0 a3 = lp89slc.at2-71300.0 a3 = lp89slc.at2-0.260-0.085 all of them have same part in meddle of string ( {...}+{.at2}+{...} ) ==> ( .at2 ) want delete right part come next of (.at2) example : a1 = lp89slc.at271300.0 ==> lp89slc.at2 a2 = lp89slc.at2-71300.0 ==> lp89slc.at2 also want know there way can delete last part of string come next special character ...at2... example : after set unpredictable variable {somecharecter.at2undesirablepart} change {somecharecter.at2} the difference between question , first 1 that, in first situation, first part finite , assignable. in second question both part come in left , right place of {at2} unpredictable. trim trimright trimleft commands dont job! the easiest way use regular expression substitution: regsub -all -line {^.*\y(\w+\.at2).*$} $thestring {\1} thestring th...

How do I calculate age specific R^2 in R -

i got demography dataset of swedish mortality mortality.org goes year 1751 2011 , age 0 110. i've used {demography} package fit lee-carter model data period 1900 2011 , age 0 100. need asses fit of estimates , intend use coefficient of determination so. problem now, need age-specific r^2's every age 0 100 , overall r^2 given when estimating model. in other words, need find r^2 via formular r^2 (x) = 1 - ∑_x ( m(x,t) - predict{m(x,t)})^2 / ∑_x (m(x,t) - mean{m(x)})^2 for every x = 0,...,100. here m(x,t) mortality rate year t , age x, predict{m(x,t)} lee-carter prediction of m(x,t) , mean{m(x)} mean rate of mortality @ age x. code far: #lee-carter analysis of swedish mortality #packages used in mortality analysis library(demography) library(forecast) library(lifecontingencies) #import of mortality data: sweden <-hmd.mx(country="swe", username="username@email.domin",password="password", label="sweden") #fit of lc model (...

c++ - Forward decleration changes function behaviour? -

i'm learning c++ , found strange understand (see comment on 5th line of code): #include <iostream> using namespace std; // forward decleration output a=1 , b=2 // without forward decleration output a=2 , b=1 // why?? void swap(int a, int b); int main() { int = 1; int b = 2; swap(a, b); cout << "a: " << << endl; cout << "b: " << b << endl; system("pause"); return 0; } void swap(int a, int b) { int tmp = a; = b; b = tmp; } can explain behaviour please? thought default c++ passes value unless use amperstand (&) in front of function parameter this: function swap(int &a, int &b) { first of swap function not swap original arguments. swaps copies of original arguments destroyed after exiting function. if want function indeed swap original arguments parameters have declared referemces void swap(int &a, int &b) { int tmp = a; ...

java - Set a delay on System.exit(0) -

i have code below, want in function run 5 seconds after system.out.println statement examples system.out.println("well done"); //***5 second delay*** system.exit(0);` how go creating 5 second delay between println , exit? system.out.println("well done"); thread.sleep(5000); system.exit(0);` or little more specific, can use timeunit#sleep method on timeunit.seconds : system.out.println("well done"); timeunit.seconds.sleep(5); system.exit(0);` on note, information trivial find through google. search term "java pause" or "java sleep" throws number of links relevant question.

android - Does i need different SHA1 key to perform Google Map -

hj. using google map api v2 project. in office, works fine cert_fingerprint key 1 but when doing in home, got blank google map. trace log can see this: 03-17 04:40:44.288 12461-12510/com.dump.dms e/google maps android api﹕ in google developer console ( https://console.developers.google.com ) ensure "google maps android api v2" enabled. ensure following android key exists: api key: aizasydee3cocewpzte_cppl*********l2cm_a android application ( < cert_fingerprint > ;< package_name >): ef:fa:c1:36:bd:fa:d6:6a:de: ** : ** : ** :53:c8:8b:16:c1:15:c7:ed;com.dump.dms (call cert_fingerprint key 2 ) so must replace cert_fingerprint key 2 . app works normally. could explain why need 2 cert_fingerprint key that? how can use 1 cert_fingerprint key ? when deploying app debug build, problem @ home debug.keystore different @ work. in office, used debug.keystore generate sha1 key used generating google maps api key. when deploy app @ home now...

java - Android Studio cannot find AAR packages -

Image
i having problem android studio recognizing classes inside @aar library imported locally. so... i've made library , exported aar file. inside android studio selected import module , them import .jar or .aar package . the project compiles , works classes inside aar file android studio can not find classes or offer auto completion of all. here few of screenshots: the same problem happens other @aar libraries imported same way: any suggestions? edit: build.gradle: ... dependencies { compile filetree(dir: 'libs', include: ['*.jar']) compile project(':upplatformsdk') compile project(':simpleorm') ... // more libraries here } settings.gradle: include ':app', ':upplatformsdk', ':wear', ':simpleorm' looks how manually include external aar package using new gradle android build system if have them in lib folder repositories { flatdir { dirs 'libs' } }...

javascript - How to call cleanup code in Angular on browser refresh -

i have server api holds session state in form of managed objects. unfortunately, there no way references managed objects apart when created. this means there need destroy objects when web application finished them (otherwise accumulate on server , hit limit no more can created). have cleanup code in controller destroy event handlers, don't seem called when user, say, refreshes browser. what's proper angular-ish way call cleanup code on refresh or close? there such pattern or should server api refined provide way such references? unfortunately, i'm not in position able change server api easily.

c - Weird error when using fread with struct -

so, trying read bmp image using fread , structs. create following struct read header struct head{ char sigbm[2];//this 'b' , 'm' chars int filesize; int reserved; int offset ... }; and in main function used fread(pointertostruct,sizeof(struct head),1,image); and got weird results. decided take char sigbm[2] struct , read different fread. like: char sigbm[2]; struct head *p = malloc(sizeof(struct head));/* without char sigbm[2] */ fread(sigbm,sizeof(char),2,image); fread(p,sizeof(struct head),1,image); and worked! i got working, want know why worked that your data seem written disk without padding. is; integer filesize comes directly after 2 chars. not how structs kept in memory. the size of struct head{ char sigbm[2];//this 'b' , 'm' chars // 2 padding bytes hide here int filesize; } is 8 on machine. not 2+4 may expect. if read/write same compiler options on same platform can expect struct read in correctly. if not...

c# - WPF in-memory image not rendering after assigned to Image.Source -

i've been searching hours find what's problem , can't find it. i'm using function convert base64string bitmapimage public static bitmapimage base64stringtobitmapimage(string base64string) { byte[] bytebuffer = convert.frombase64string(base64string); memorystream memorystream = new memorystream(bytebuffer); memorystream.position = 0; bitmapimage bitmapimage = new bitmapimage(); using (memorystream) { bitmapimage.begininit(); bitmapimage.cacheoption = bitmapcacheoption.onload; bitmapimage.streamsource = memorystream; bitmapimage.endinit(); bitmapimage.freeze(); } memorystream.close(); memorystream = null; bytebuffer = null; return bitmapimage; } and assign property of viewmodel bound view: processimage = base64stringtobitmapimage(_imagestring); mainwindow.xaml <image x:name="part_image" width="...

arrays - Pointer and String Outputs in C -

i trying understand why following piece of code produces output of bcd123 123 . void f(char *p) { *p += 1; } int main() { int i; char a[] = "abc" "123"; char *p = a; (i = 0; < 3; i++) f(p++); printf("%s ", a); printf("%s ", p); return 0; } void f(char *p) { *p += 1; } adds 1 character passed in. 'a' + 1 = 'b' etc. in ascii table http://www.asciitable.com/ part 2 char a[] = "abc" "123"; // same char a[] = "abc123"; (i = 0; < 3; i++) f(p++); <<<<===== moves p along string 3 places (once each loop) printf("%s ", a); printf("%s ", p); <<< p points @ 4th char

cobol - Is there a way to automatically fill in array after getting user input? -

i have array of 5 elements , each of elements holds character. want accept user input in 1 line. example: abcde. , intend element 1 of array have , element 2 of array have b , on. this? have attached relevant portions of code below: environment division. input-output section. file-control. select standard-input assign keyboard. select standard-output assign display. data division. file section. fd standard-input. 01 stdin-record pic x(80). fd standard-output. 01 stdout-record pic x(80). working-storage section. 01 input-area. 02 inputcharacters pic x(1) occurs 5 times. 01 print-line. 02 inputcharacters pic x(1) occurs 5 times. procedure division. open input standard-input, output standard-output. read standard-input input-area @ end close standard-input, standard-output end-read. write stdout-record print-line after advancing 5 line end-write stop...

c# - Format doubles with General numeric format and pad right with zeros -

i'm trying output doubles of various sizes, negative , non-negative, columns. use g5 standard numerical format exponential format when appropriate (i.e. values tiny), regular formatting otherwise. values padded zeros appropriately line in columns (i.e. pad zeros on right normally, , pad zeros before e in exponentials). currently, have: string.format("{0} {1} {2}", a.tostring("g5"), b.tostring("g5"), c.tostring("g5")); this doesn't work great since doesn't pad. output this: 1.234000000 0.123400000 1.23450e-03 4.56780e-08 -1.2345e-09 0.001234000 // negative signs can line else -12.34500000 0.045678900 -1.23450e-06 // or line each other, whatever easier, not both how can achieve this? edit: using : format {0:10} above numbers yields: 1.234 0.1234 0.0012345 4.5678e-08 -1.2345e-09 0.001234 -12.345 0.045679 -1.2345e-06

javascript - Adding Stripe payment data to a Multi Part Wizard form in AngularJS -

i'm trying create 3 page wizard in angular js, final part taking payment details. however, looking through stripe docs notice there no name attributes on of form elements related stripe. at moment i'm using buttons link next step in wizard, , have single form, submitted together. 3 page wizard based on tutorial: https://scotch.io/tutorials/angularjs-multi-step-form-using-ui-router as can see i'm using: <div class="col-xs-6 col-xs-offset-3"> <a ui-sref="form.payment" class="btn btn-danger"> next section <span class="glyphicon glyphicon-circle-arrow-right"></span> </a> </div> to navigate next form page. my question - how can submit both objects bound model (formdata), and stripe data within same form. possible? if - how can , still keep wizard functionality? below controller: angular.module('formapp') .controller('formcontroller', ['$scope', ...

c++ - Performance AVX/SSE assembly vs. intrinsics -

i'm trying check optimum approach optimizing basic routines. in case tried example of multiplying 2 float vectors together: void mul(float *src1, float *src2, float *dst) { (int i=0; i<cnt; i++) dst[i] = src1[i] * src2[i]; }; plain c implementation slow. did external asm using avx , tried using intrinsics. these test results (time, smaller better): asm: 0.110 ipp: 0.125 intrinsics: 0.18 plain c++: 4.0 (compiled using msvc 2013, sse2, tried intel compiler, results pretty same) as can see asm code beaten intel performance primitives (probably because did lots of branches ensure can use avx aligned instructions). i'd utilize intrinsic approach, it's easier manage , thinking compiler should best job optimizing branches , stuff (my asm code sucks in matter imho, yet faster). here's code using intrinsics: int i; (i=0; (minteger)(dst + i) % 32 != 0 && < cnt; i++) dst[i] = src1[i] * src2[i]; if ((minteger)(src1 + i) % 32 == 0) ...

loops - C# Wait until condition is true -

i trying write code executes when condition met. currently, using while...loop, know not efficient. looking @ autoresetevent() don't know how implement such keeps checking until condition true. the code happens live inside async method, may kind of await work? private async void btnok_click(object sender, eventargs e) { // work task<string> task = task.run(() => greatbigmethod()); string greatbigmethod = await task; // wait until condition false while (!isexcelinteractive()) { console.writeline("excel busy"); } // work console.writeline("yay"); } private bool isexcelinteractive() { try { globals.thisworkbook.application.interactive = globals.thisworkbook.application.interactive; return true; // excel free } catch { return false; // excel throw exception, meaning busy ...

javascript - Why does Brackets (code editor) open a new instance of Chrome when using Live Editor? -

in new instance of chrome, of accounts signed out , have relog in. in task bar can see original chrome , can open them side side. the old instance of chrome: all apps accounts signed in the new live preview instance of chrome: i dont have of apps no accounts signed in essentially if using chrome first time what asking is, safe sign accounts on new instance of chrome? the chrome profile brackets launches live preview has chrome remote debugging api enabled. there 2 reasons brackets uses separate profile this: remote debugging off default, , enabling requires re-launching chrome. using separate profile means existing browsing session doesn't have restarted, disruptive if have lots of tabs open. it reduces security -- other processes on local machine use remote debugging api monitor / interfere other browsing in chrome window. (the api not exposed network, if trust computer malware-free, less of concern). if don't having open separate chrome...

Selectable categories and products in magento admin -

goal i upgrading custom in-house module magento ee. module groups clients , has special rules can applied group or individuals of group. need add tab allows, on per group basis, select items and/or categories. when selected people within group not allowed see categories or products. what have i have the tab created , know need on front-end achieve goals. issue creating selector. have played couple hours , made no real headway of yet. have been doing magento development past 5 weeks, new framework. what need with i select categories , items in same fashion when go catalog->categories->manage categories. left column has tiered list. have 1 check boxes selection. when looking @ promotions->shopping cart rules->actions(tab), select rule, choose actions tab. in second fieldset, if add new rule 'category' , select icon tiered tree want. same idea products, okay if different. need able both ways. i need able store selected values, , retrieve the...

javascript - invalid non-string/buffer chunk Node.js -

i'm studying node.js @ college, , it's first time learning kind of programming language. i've got errors in attempt of chat server. when try connect 1 client server, connection closes inmmediately , appears error 'invalid non-string/buffer chunk'. upload screenshots , can check wrong, because i've been thinking while , don't find solution. click here see git bash my code in javascript: var net = require('net'); var s = require var sockets = []; var nombres = []; var nombresusados = []; console.log("se ha iniciado el sevidor"); var server = net.createserver(function(socket){ socket.push(socket); nombres.push("cliente:" + sockets.indexof(socket)); nombresusados.push("cliente:" + socket.indexof(socket)); console.log("cliente aceptado, nick:" + nombres[sockets.indexof(socket)]); socket.write("bienvenido" + nombres[sockets.indexof(socket)]+ "\n"); ![enter ...

c# - Programmatically detect a redirected folder in Windows 7 and above -

Image
as example of redirected folder, map onedrive folder non-os, larger disk drive follows using move button under location: the onedrive settings still point old location when opened in windows explorer, takes newly assigned location e.g. f:\onedrive . is there way programmatically determine whether arbitrary folder has been redirected , if yes, where? edit : please note question not how retrieve onedrive folder in first place. detecting redirection on arbitrary folder.

microcontroller - How to move a variable's value into another variable in assembly -

i trying learn assembly programming mplab x , pic18f1320 microcontroller. have been following mpasm user's guide ( http://ww1.microchip.com/downloads/en/devicedoc/33014j.pdf ) , have gotten led blink rb0 pin on microcontroller. wrote program make led blink once every 512 ticks. having trouble figuring out how change delay 512 variable quantity can change somewhere else in code. ideally, line movf 0xff,count1 would replaced count1=delay1 where delay1 variable set 0x20 earlier in code. here code: #include "p18f1320.inc" config osc = intio1 ; oscillator selection bits (internal rc oscillator, clko function on ra6 , port function on ra7) cblock 0x20 ;start of data section count1 ;delay variable delay1 ;length of delay endc org 00 ;\ movwf portb ; | movlw 0x00 ; | movwf trisb ; |--start program , configure i/o pins movlw 0x00 ...

javascript - Jquery logo parade not starting, not seeing errors -

i can't narrow down problem simple logo parade. i'm working on @ promasterautomotive.com can see context of problem. logo parade @ bottom, faded logos. i opened console in chrome (ctrl+shift+j) i'm not seeing errors. here javascript. pulled directly example. $(function() { $("#logoparade").smoothdivscroll({ autoscrollingmode: "always", autoscrollingdirection: "endlessloopright", autoscrollingstep: 1, autoscrollinginterval: 25 }); // logo parade event handlers $("#logoparade").bind("mouseover", function() { $(this).smoothdivscroll("stopautoscrolling"); }).bind("mouseout", function() { $(this).smoothdivscroll("startautoscrolling"); ...

javascript - include json data in the load more button function -

how include json data in load more button function at load more button : jsfiddle example var index = 1; $(document).on("pagecreate", "#page1", function(){ $("#btnadd").on("click", function(){ var allitems = ''; (var = 0; < 100; i++) { allitems += '<li><a href="javascript:showdetails(' + (index + i) + ')" >item number ' + (index + i) + '</a></li>'; } index += 100; $("#listtemp").empty().append(allitems).listview("refresh"); var element = $("#listtemp li").detach(); $("#listdspqry").append(element); }); }); my json url : http://www.beritanisma.com/category/superlawak/?json=get_category_posts been trying days ended showing no results, please me masters, thank you.. var index = 0; $(document).on("pagecreate", "#...

MATLAB: String Manipulation and File Input/Output -

ok have data file similar 1 containing names , weights of people: darby george 166.2 helen dee 143.5 giovanni lupa 192.4 cat donovan 215.1 im supposed read script strings 1 line @ time, save weight vector, , print each person's name in form 'last,first' followed weight: george, darby’s weight 166.20 lbs. dee, helen’s weight 143.50 lbs. lupa, giovanni’s weight 192.40 lbs. donovan, cat’s weight 215.10 lbs. this code: fid = fopen('patwts.dat'); if fid == -1 disp('file open not successful') else while feof(fid) == 0 % read 1 line string variable aline = fgetl(fid); %save vector , fprintf here strtok(aline,' ')=[first last num]; fprintf('%s %s %3.2f',last,first,num) mat=['%3.2f %3.2f %3.2f %3.2f %3.2f %3.2f 3.2f %3.2f %3.2f %3.2f'] end closeresult = fclose(fid); if closeresult == 0 disp('file close successful') else disp('...

Understanding Class Inheritance in Python from learningPythonthehardway -

i have been learning python , understood inheritance means between classes , objects. here code want make sure got down right: class animal(object): def __init__(self, name): self.name = name print self.name def howl(self, name): print "eeh %s" % name class dog(animal): def __init__(self, name): ##has-a __init__ function takes self , name parameters. self.name = name print "%s barks , happy" % self.name def sound(self, name): print "%s barks" % name rover = dog("rover") rover.sound("rover") rover.howl("rover") in order better understand way classes behaved "base class" animal , put print s on place , can see dog able call howl , function parent class, animal (is right?) my other question when use rover = dog("rover") , how come it's using __init__ function call? purpose of __init__ function when set value variabl...

callback - Executing imported Javascript functions in order -

i want execute 2 functions in specific have imported 2 other .js files have made. function needs complete first takes bit of time , 2nd 1 starts before first ended , need files first 1 created work. here's .js looks like: var pdftopng = require("./pdftopng.js"); var dostufftopng = require("./dostufftopng.js"); var pdffilepath = process.argv[2]; var pngfilepath = pdftopng.convert(pdffilepath);//convert takes path //and makes png , returns path //to png dostufftopng.dostuff(pngfilepath); //i want "dostuff()" start after "convert()" done. im pretty sure has callbacks, i'm javascript noob , need help. can work settimeout(), seems "duct tape fix" me. there way more elegant? edit: wonderful people wanted , asked post this, pdftopng.js: var spindrift= require('spindrift');//this node module var fs = require('fs'); //makes pn...

php - Magento Call to a member function setAttribute() on a non-object after adding 2 custom fields in address -

using magento 1.9.0.1, added module insert 2 custom fields address. please view codes in other question . after installed module, billing address appears error: fatal error: call member function setattribute() on non-object in /home/onceecom/public_html/dev/includes/src/mage_eav_model_attribute_data.php on line 80 the page has not been modified display new fields, error has appeared. how can debug such error? p.s. not sure if it's related, modified customer address display options in system > configuration > customer > customer configuration > address template > html : {{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}<br/> {{depend company}}{{var company}}<br />{{/depend}} {{if street1}}{{var street1}}<br />{{/if}} {{depend street2}}{{var street2}}<br />{{/depend}} {{depend street3}}{{var street3}}<br /...

java - Android bitmap sometimes returning null -

Image
i making brick-breaker game android , attempting change image of background. on first run of game works 100% of time. mbackgroundimage = bitmapfactory.decoderesource (gameview.getcontext().getresources(), r.drawable.planet3); planet3 in res/drawable folder. if return previous screen , start new game, npe 90% of time. if use resource provided framework working on in same folder "planet3", strangely works 100% of time regardless of whether new game or first game etc. why happening of time , not others. find when work because debugging , stepping through line line, coincidence. the code have @ moment follows, thegame current thread game running on, code pasted above in constructor of this, i.e. everytime new game made, background should set. can see file structure on left verify file "background" in same folder "planet3": as far error concerned don't have actual error message says mooc has stopped work...

Aren't bash script variable untyped (converted automatically)? -

touch "data" if [ $(stat -c%s "data") < 1024 ]; echo "not file" fi it cannot check whether file size less 1mib. (of course, data should empty file.) it give error: ./chk.sh: line 2: 1024: no such file or directory aren't bash script variable untyped (converted automatically)? you should using -lt instead of < integer comparison = , != used string comparisons < , > used redirection

openstreetmap - Extracting nodes from highways -

i using overpass turbo extract nodes highways(=motorway). below code using. however, code gives me nodes in bounding box , not filter highways. [out:xml]; ( (way(39.90,32.83,39.96,32.89);)->.a; ((way.a["highway"="motorway"]);)->.b; ((way.a["highway"="motorway_link"]);)->.b; ); (.b;>;); out body qt; see answer posted on help.osm.org: https://help.openstreetmap.org/questions/41754/extracting-node-from-highways

android - Xamarin Debug Keystore Seems to have Changed -

i developing android application using xamarin.android in xamarin studio. uses google play game services. the project has run , tested find until point. yesterday upgraded development pc windows 7 windows 8.1. in process had reinstall xamarin studio. now when app attempts connect google play, fails error "result_app_misconfigured" far can tell means app not authorized access google play api. however, nothing has changed. i tested older version of app, , still able connect google play api. nothing in code has changed, think must upgrade of windows, or recent re-install of xamarin studio. any thoughts on narrow down problem? possible debug keystore has changed somehow? an additional clue: when attempt build deploy device has older, working version of app on it, following error: deployment failed because of internal error: failure [install_failed_update_incompatible] i have manually uninstall old version before new 1 can deployed. as has been poi...

Any way to bring Unity3d to the foreground? -

i have sent user out browser application.openurl . , want programatically bring unity foreground. is there way without plugin? thanks. if using unity3d in windows, try below code after calling application.openurl(...) : [dllimport("user32.dll")] private static extern bool setforegroundwindow(intptr hwnd); var prc = process.getprocessesbyname("..."); //get unity's process, or var prc = process.getcurrentprocess(); if (prc.length > 0) setforegroundwindow(prc[0].mainwindowhandle);

c++ - boost::asio::ssl::stream<tcp::socket> is closed before read -

i'm trying write synchronous ssl client. here code: class chttpssession { public: chttpssession(io_service& io_service, ssl::context &context, tcp::resolver::iterator endpoint_iterator) : m_socket(io_service, context) { error_code error = error::host_not_found; tcp::resolver::iterator end; while (error && endpoint_iterator != end) { m_socket.lowest_layer().close(); m_socket.lowest_layer().connect(*endpoint_iterator++, error); } if (error) { throw system_error(error); } m_socket.handshake(ssl::stream_base::client); } void sendrequest(chttprequest& request) { write(m_socket, request.getrequest()); } void receiveresponse(chttpresponse& response) { streambuf reply; error_code error; read(m_socket, reply, transfer_all(), error); //here error received if (error &...

What is the best way to precompile EmberJS templates on Windows -

i'm trying determine best way precompile emberjs templates using windows , can't seem find options. can recommend proven solution? i'm using ember v 1.10.0 edit: have installed latest version of nodejs , followed instructions here: http://www.ember-cli.com/#getting-started . for record, using windows 8.1 running on surface pro 2. i have tried installing ember cli using nodejs , following error(s): c:\>npm install -g ember-cli npm warn engine makeerror@1.0.10: wanted: {"node":"0.6.x"} (current: {"node":"0. 12.0","npm":"2.5.1"}) npm warn engine tmpl@1.0.3: wanted: {"node":"0.6.x"} (current: {"node":"0.12.0", "npm":"2.5.1"}) c:\users\me\appdata\roaming\npm\ember -> c:\users\me\appdata\roaming\npm \node_modules\ember-cli\bin\ember npm err! windows_nt 6.3.9600 npm err! argv "c:\\program files\\nodejs\\\\node.exe" "c:\\progra...

html - Working with links in Django -

i working in small blog application using django. sorry if question obvious, newbie. third since started online course. have following queryset: def all(request): alltiles = post.objects.values('title') allposts = post.objects.all()[:3] context = {'posts': allposts,"titles":alltiles} template = "home.html" return render(request, template, context) and follwing html code: <ol class="list-unstyled"> {% singletile in titles %} <li><a href="#">{{singletile.title}}</a></li> {% endfor %} </ol> as can see every title creates link. lets assume person decides read 1 of posts. how can use title name , send request database content of post. it better use id or slug field such task. but if surely want use title parameter apply urlencode filter field's value: <a href="{% url 'post_detail' %}...

javascript - Cross-dissolve transition for scrolled elements -

i creating long single page website , using scrollmagicjs v1.3.0 trigger events , make elements sticky. create variety of other transition effects 1 scrolls down page. here's jsfiddle replicates horizontal scrolling of site. scrollcontrol = new scrollmagic({ vertical: false, }); var myscrollscene = new scrollscene({ triggerhook: 0, offset: 0, triggerelement: '#shot-0-1', duration: '100vw', pushfollowers: true }) .setpin('#shot-0-1') .addto(scrollcontrol); for instance, want create fade-to-black, flare-to-white, , cross-dissolve transitions between pages. i understand of basic principles of html5 transitions, how make 1 image dissolve another, haven't been able figure out clever way using scrollmagic scrolling. things i've considered: next page slides under current page , transitions 1.0 0 opacity using scrollmagic triggers? but how in way non-hacky , consistent scrollmagic's framework? ...

lua - Why does my while code cause my simulator to crash? -

whenever add while code game, simulator stops responding. know while code causes problem because if take while code out, game works supposed to. whats wrong while code, , how fix it? let me know if need more information solve problem. here code: function scene:createscene ( event ) local group = self.view local tap = display.newtext("tap:", 0, 0, "helvetica", 36) tap.x = 100 tap.y = screentop + 20 group:insert(tap) local imagefiles = {"redbox.png", "bluebox.png"} local imagefile = imagefiles[math.random(2)] local randomimage = display.newimage(imagefile, centerx, screentop + 20) local button1 = display.newimage("redbox.png") button1.x = centerx button1.y = centery group:insert(button1) local button2 = display.newimage("bluebox.png") button2.x = centerx button2.y = centery - 100 group:insert(button2) local function endgame(event) if imagefile == "redbox.png" button1.x = math.random( 55, 300) button1.y = ma...