Posts

Showing posts from February, 2015

Python chars compare in if/else -

the goal y or n , different things based on if/elseif/else statement. problem not see y , n proper values. know doing wrong? print 'are happy final crop?' happytest = raw_input('enter y or n: ') if happytest == 'y': happy = false elif happy == 'n': padding == int(raw_input('enter crop padding:')) else: print 'not valid input' you've got 2 problems can see: elif happy == 'n': references undefined variable, happy . meant happytest . padding == int(raw_input('enter crop padding:')) tries compare padding , int(...) . meant assign. change == = .

c++ - 3D Barycentric point Intersection -

i'm first going start saying, yes have looked not days or hours, literally months in problem. tackle problems head on, today i'm absolutely stuck. i'm trying determine if point within triangle in 3d space, , have following code in place attempt detect it. the test: bool d3dhandler::iscollidingwithterrain(d3dxvector3 pos){ (unsigned int = 1; < chunk.at(0).getwidth()-1; i++){ (unsigned int ii = 1; ii < chunk.at(0).getwidth()-1; ii++){ if (physics::polypointcollision( normalvertex{ chunk.at(0).getvertex(i, ii).x, chunk.at(0).getvertex(i, ii).y, chunk.at(0).getvertex(i, ii).z, { 0, 0, 0 } }, normalvertex{ chunk.at(0).getvertex(i + 1, ii).x, chunk.at(0).getvertex(i + 1, ii).y, chunk.at(0).getvertex(i + 1, ii).z, { 0, 0, 0 } }, normalvertex{ chunk.at(0).getvertex(i, ii + 1).x, chunk.at(0).getvertex(i, ii + 1).y, chunk.at(0).getvertex(i, ii + 1).z, { 0, 0, 0 } }, normalvertex{ p

android - Where can I find SQL keywords constants in Java, for example "DESC"? -

i have sort criteria looks following: mediastore.mediacolumns.date_added + " desc" i'd replace desc constant. another option use statement builder . knows of such? i'd replace desc constant. why. is constant, sql language point of view. nobody going change it. java point of view, it's pooled string literal. java doesn't provide keywords of other languages constants. sisyohean task. don't worry it.

c - Reading from a text file and plotting using GNU libplot -

i've made program reads file, , alphabetically sorts names contained within file. file contains planet names, mass, size, color, primary body, positions x,y,z , velocity x,y,z. i'm trying plot each planet using file, i'm unsure how go doing that. i'm using gnu libplot plot planets. i'm thinking need use loop , fscanf s x , y coordinates (can omit z now) plot each planet. here's current code: #include <stdio.h> #include <stdlib.h> #include <string.h> #define names 20 struct planets{ //sets initial characters , doubles place body. char primarybody[names]; char name[names]; char color[names]; double mass; double size; double posx, posy, posz; double velx, vely, velz; }; struct planets body[100]; int readdata(file* fd){ //this reads file solarsystem.txt , fills array int current = 0; char line[201]; char cmpline[2] = "#"; do{ fgets(line, 200, fd); // makes sure number of bytes written dont overflow cha

mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) -

i had installed mysql using sudo apt-get install on ubuntu 13 but after running terminal mysql -u root -p and entering password gives error error 2002 (hy000): can't connect local mysql server through socket '/var/run/mysqld/mysqld.sock' (2) please guide... create 1 micro instance swap space in ubuntu dd if=/dev/zero of=/swapfile bs=1m count=1024 mkswap /swapfile swapon /swapfile

ios - Applying an effect to a SKScene is that expensive? -

i developing game using spritekit. in response user getting bonus, flash screen 3 times while play action continues. flashing inverting scene colors, open use other effect. i have tried use cifilter on scene, frame rate dropped 60 fps 13 fps, making game unplayable. i have tried use cifilter on whole scene, doing this cifilter * (^invert)(void) = ^ { cifilter *filter = [cifilter filterwithname:@"cicolorinvert"]; [filter setdefaults]; return filter; }; and changing scene self.filter = invert(); self.shouldenableeffects = yes; i long time user of cocos2d. did kind of effect on app of mine developed cocos2d in past , had barely no impact on frame rate compared miserable frame rate using spritekit. i have tried apply effect character represents user, barely 100x100 pixels. frame rate dropped 60 30fps... better game unplayable. any way or achieve impressive brief effect whole screen play evolves? thanks i have game flash screen , following pi

android - Fragments and Activities -- where do I put my application logic? -

i have created view how want look. has 1 images, input box, , button. want load activity when button clicked. confused why there fragments , activities. new android world (coming ios). my understanding activities similar viewcontrollers, not sure understand fragment is. where put event handling? package com.phppointofsale.phppointofsale; import android.support.v7.app.actionbaractivity; import android.support.v7.app.actionbar; import android.support.v4.app.fragment; import android.os.bundle; import android.view.layoutinflater; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.viewgroup; import android.os.build; public class storeurlactivity extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_store_url); if (savedinstancestate == null) { getsupportfragmentmanager().begintra

python - TypeError: int() argument must be a string or a number, not 'tuple' -

i'm trying figure out error homework assignment i'm working on. it's suppose payroll program calculates pay , overtime pay, overtime defined amount of hours on 40. my error: traceback (most recent call last): file "c:\python33\assignment6.py", line 79, in <module> main() file "c:\python33\assignment6.py", line 18, in main original_pay = calculate_pay(original_hours, original_rate) file "c:\python33\assignment6.py", line 52, in calculate_pay original_hours = int(original_hours) typeerror: int() argument must string or number, not 'tuple' my code: overtime_rate_constant = .5 overtime_limit = 40 overtime_hours = 0 def main (): greet() original_hours = get_hours() original_rate = get_rate() original_pay = calculate_pay(original_hours, original_rate) totalpay = overtime_pay + original_pay print_data(original_rate, overtime_hours, original_hours, calculate_overtime_hours, orig

Is it possible to do conditional abbreviation in vim? -

i have following abbreviation in .vimrc : :iab stdio #include <stdio.h> is possible make substitution occur when stdio not preceded < , if paste in code has line #include <stdio.h> , not expand following? #include <#include <stdio.h>.h> there might easier way heres did. function! insertheader(replacement, mapping) if getline('.')[col('.')-len(a:mapping)-2] != '<' return a: replacement endif return a:mapping endfunction iabbrev <expr> stdio insertheader('#include <stdio.h>', 'stdio') i used function checks see if mapping preceded < if return mapping. if isn't return return replacement. return value gets replaced. rereading question seems pasting code in. before pasting use :set paste this stops of abbreviations activating. after pasting use :set nopaste (or use :set paste! toggle it)

bitmap - Delphi TBitmap - why are Pixels and ScanLine different? -

while using 32 bit tbitmap, switched canvas.pixels scanline. i set value red, find displayed blue. any idea why? here's code excerpt: procedure tform1.formpaint(sender: tobject); var varbitmap: tbitmap; plock: pintegerarray; icolor: integer; begin varbitmap := tbitmap.create; varbitmap.pixelformat := pf32bit; varbitmap.width := 800; varbitmap.height := 600; // set pixels red varbitmap.canvas.pixels[0, 0] := $0000ff; // shows $ff0000 (blue) plock := varbitmap.scanline[0]; icolor := plock[0]; showmessagefmt('%x', [icolor]); // set scanline red plock[0] := $0000ff; // displays blue pixel canvas.draw(0, 0, varbitmap); end; it seems somehow tcolor not same in memory, makes no sense. any suggestions welcome. ;) 32bit pixel data in $aarrggbb format. setting blue component, not red component. use $ff0000 instead of $0000ff . or better, use rgb() function.

Proper syntax for callback on custom javascript function / jQuery -

i've simplified down, , yes... know fadein strange example... part of point. how make call function on custom function - or function nothing passed through it... example - if there no argument? here fiddle illustrate confusion - i have broken monster set of callbacks little groups, , want chain them - i'm missing something... jquery // example function function sheriff(speed) { $('.thing').fadein(speed); } $('button').on('click', function() { sheriff(1000, function() { $('body').css('background-color', 'red'); }); }); edit this actual code, proper callback in place. on simplified first example, , didn't show complicated enough use - , - others i'll leave here. jquery function pullinsocialbuttons(speed, callback) { var facebook = $('.toy-box-top .social-links li:nth-of-type(1)'); var twitter = $('.toy-box-top .social-links li:nth-of-type(2)');

Passing a pointer to an object in C++ & error: no matching function for call to -

i'm trying pass pointer vector 1 free floating function another. works good, however, when trying add vector strange compilation error. $ g++ peekclientrms.cpp peekclientrms.cpp: in function ‘void testnewword(std::string, std::vector<peekdeque<stringwrap> >*)’: peekclientrms.cpp:116:26: error: no matching function call ‘std::vector<peekdeque<stringwrap> >::push_back(peekdeque<stringwrap>*&)’ chainsp->push_back(newpd); ^ peekclientrms.cpp:116:26: note: candidate is: in file included /usr/lib/gcc/x86_64-pc-cygwin/4.8.2/include/c++/vector:64:0, peekclientrms.cpp:13: /usr/lib/gcc/x86_64-pc-cygwin/4.8.2/include/c++/bits/stl_vector.h:901:7: note: void std::vector<_tp, _alloc>::push_back(const value_type&) [with _tp = peekdeque<stringwrap>; _alloc = std::allocator<peekdeque<stringwrap> >; std::vector<_tp, _alloc>::value_type = peekdeque<stringwrap>] push_

android - How to change color of words with hashtags -

i need able display text words starting # in different color , should clickable. how can this? this should trick private void settags(textview ptextview, string ptagstring) { spannablestring string = new spannablestring(ptagstring); int start = -1; (int = 0; < ptagstring.length(); i++) { if (ptagstring.charat(i) == '#') { start = i; } else if (ptagstring.charat(i) == ' ' || (i == ptagstring.length() - 1 && start != -1)) { if (start != -1) { if (i == ptagstring.length() - 1) { i++; // case if hash last word , there no // space after word } final string tag = ptagstring.substring(start, i); string.setspan(new clickablespan() { @override public void onclick(view widget) { log.d("hash", string.format("click

neural network - Differential Hebbian Learning: why "-wij" appear in the equation -

Image
hebb's law states if 2 neurons on either side of connection activated synchronously (or asynchronously), weight of connection increased (or decreased). saw common equation: i can not understand why w_{ij} value appears in right-hand side of equation. thank in advance , sorry poor english. in standard hebbian learning weight can subtracted limit infinite growth (a known problem in hebbian learning). multiplied forgetting rate. believe role of weight decay term similar in equation provided, though, not sure if needed, since product of 2 terms can take either positive or negative sign.

.net - Binding a combobox with a list of class having public variables -

this concept cannot understand. have class class employee { public int id; public string name; } list<employee> lst = new list<employee>(); employee o = new employee(); o.id = 1; o.name = "darshan"; lst.add(o); employee o1 = new employee(); o1.id = 2; o1.name = "gopal"; lst.add(o1); combobox1.displaymember = "name"; combobox1.valuemember = "name"; combobox1.datasource = lst; the above doesn't work. when change public fields , set, works. is there way can bind without , set properties? public fields accessible outside class. can read , write value of field anywhere. why can't use them in binding? why use properties? if @ documentation : displaymember property: gets or sets property display system.windows.forms.listcontrol. when

java program to open a web page in browser and post some data into the opened page -

i m stuck problem. problem want write java code opens web page in default browser , post data opened web page. please guide me this. dont have clue in this. your appreciated. in advance you need web driver this. @ selenium i pasting code getting started selenium package org.openqa.selenium.example; import org.openqa.selenium.by; import org.openqa.selenium.webdriver; import org.openqa.selenium.webelement; import org.openqa.selenium.htmlunit.htmlunitdriver; public class example { public static void main(string[] args) { // create new instance of html unit driver // notice remainder of code relies on interface, // not implementation. webdriver driver = new htmlunitdriver(); // , use visit google driver.get("http://www.google.com"); // find text input element name webelement element = driver.findelement(by.name("q")); // enter search element.sendkeys("cheese!"); // submit form. webdri

java - Postfix evaluation for multidigit numbers -

i programming postfix evaluator, , able correctly single digit number. need idea of how multiple digit number, current program evaluates 2 digit number different numbers. here's code : public class postfixevaluation { public static void main(string[] args) { string postfix = "23+79*-"; stack stack = new stack(); (int = 0; < postfix.length(); i++) { if (postfix.charat(i) == '+') { int v1 = stack.pop(); int v2 = stack.pop(); stack.push(v2 + v1); } else if (postfix.charat(i) == '-') { int v1 = stack.pop(); int v2 = stack.pop(); stack.push(v2 - v1); } else if (postfix.charat(i) == '*') { int v1 = stack.pop(); int v2 = stack.pop(); stack.push(v2 * v1); } else if (postfix.charat(i) == '/') { int v1 =

Parse output to get a list in python -

this question has answer here: how split list evenly sized chunks? 52 answers [u'10.57518117688789', u'43.17174576695126', u'0 10.57512669810526', u'43.17172389657181', u'0 10.57509460784044', u'43.17169116727101', u'0'] i need turn list of latitudes , longitudes in order 1st last. first element being latitude , second being longitude. don't need u or '0'. right now, i'm printing them, method needs return list of coordinates in order. def get_coord_list_from_earth(filename): filename = str(filename) data = xml.dom.minidom.parse(filename) coordinates = data.getelementsbytagname('coordinates')[0].firstchild.nodevalue coordinates = coordinates.strip() print coordinates.split(',') i need output list of lists this. [10.57518117688789, 43.17174576695126

objective c - LCOV doesn't show some classes -

Image
i have abstact uiviewcontroller has methods test. @interface abviewcontroller : uiviewcontroller @property (nonatomic, strong) nsmutablearray *testresults; - (void)test; - (void)testfailedwithmessag:(nsstring *)message; @end @implementation abviewcontroller - (void)testfailedwithmessag:(nsstring *)message { if(self.testresults == nil) { self.testresults = [nsmutablearray array]; } [self.testresults addobject:message]; } @end the basic idea of class test private methods not listed on .h. the test routines implmented in subclass's "test" method. shown below. rootviewcontroller subclass of abviewcontroller. @interface rootviewcontroller () { uibutton *testbutton; } @end @implementation rootviewcontroller - (void)viewdidload { [super viewdidload]; testbutton = [[uibutton alloc] init]; } - (void)test { if(testbutton==nil) [self testfailedwithmessag:@"testbutton nil"]; } @end xctest below. - (void)

algorithm - Graph theory: Are DFS forests that correspond to a graph isomorphic? -

Image
for graph g, may have many different dfs forests if select different starting vertex or choose different unexplored edges. can construct many auxiliary graphs of g . whether auxiliary graphs of g isomorphic each other? justify answer. i know mean graph isomorphic don't know how prove right or can't think of counter example please help no not isomorphic : consider following graph : the following 2 dfs forests belong while aren't isomorphic :

python - Error when calling Executable from Tkinter -

i have executable named learn after compiling program vv.c in linux.i using tkinter (python-tk) making gui.but when running executable code.it reached error message "sh :1 : learn :not found " -t -c -b parametes passing executable. else: if self.binaryfeature == 0: cmd = "learn" + "-t " + self.type + " -c "\ + self.c + " " + self.e2.get() + " " + self.e3.get() else: cmd = "learn" + "-t " + self.type + " -c "\ + self.c + " -b 1 " + self.e2.get()\ + " " + self.e3.get() output_string = commands.getoutput(cmd) self.text.insert(insert, output_string+"\n","cprogramoutput") is error in commands executing ?please me ..thanks you need put space before "-t": cmd = "learn" + " -t " + self.type + &qu

javascript - Deal with not valid Json result in jsonp request -

i should send cross browser request , result.so use jsonp request. my result is: response: success message: authentication accepted but problem server returns json not valid , uncaught syntaxerror: unexpected identifier . use angularjs,jquery , implement request. var ud = 'json' + (math.random() * 100).tostring().replace(/\./g, ''); window[ud] = function (o) { success && success(o); }; document.getelementsbytagname('body')[0].appendchild((function () { debugger; var s = document.createelement('script'); s.type = 'text/javascript'; s.src = url.replace('callback=?', 'callback=' + ud); return s; })()); but same result how can handle problem.

compilation - Why am I getting this aclocal error? -

i'm trying compile libbsd source on ubuntu 13.04. i'm using toolchain cross-compile, automake on local machine. have aclocal-1.13 in path , everything, i'm still getting error. i've tried looking them can't lead. what's going on here? <...> config.status: executing libtool commands cdpath="${zsh_version+.}:" && cd .. && /bin/bash /home/me/libbsd/build-aux/missing aclocal-1.13 -i m4 error: cannot project version. configure.ac:9: error: ac_init should called package , version arguments /usr/share/aclocal-1.13/init.m4:23: am_init_automake expanded from... configure.ac:9: top level autom4te: /usr/bin/m4 failed exit status: 1 aclocal-1.13: error: echo failed exit status: 1 make: *** [../aclocal.m4] error 1 any appreciated. the error here configure.ac:9: error: ac_init should called package , version arguments . getting error because on line 9 of configure.ac not passing package , version arguments ac_init. the exac

sonarqube - Does Sonar Jira plugin supports REST communication with Jira 6.0 as SOAP is deprecated -

as jira 6.0 deprecates soap ( https://developer.atlassian.com/display/jiradev/soap+and+xml-rpc+api+deprecated+in+jira+6.0 ) sonar jira plugin support rest communication jira 6.0 server? yes it's still working on deprecated api.

(Cordova / Phonegap) Problems with WifiManager.addNetwork() method of Android -

currently writing app in cordova 3.4.0 should import wifi settings source, file or database. if use wifimanager.addnetwork method of android , always returns -1 "failed". on other hand: if use same code in oncreate() method of blank activity , settings added , return id of new entry. the app developed api 10 19 , call cordova code from plugin context . the android app has following permissions : <uses-permission android:name="android.permission.access_wifi_state" /> <uses-permission android:name="android.permission.change_wifi_state" /> my test device: samsung galaxy y ( gt-s5360 ) android 2.3.6 . is bug or feature? there seems no details in logcat e.g. tells more. if @ official android code , see hint external iwifimanager service seems device specific. here code: private void addwifisettings() { string ssid = "my_network"; string pwd = "my_secrect_password"; context ctx = this.c

image - Google App Engine - Busting Serving URL Cache -

Image
i've managed images rotate on app engine, i'm struggling around images being cached , standard cache busting techniques doesn't anything. so first time rotate image, different url , image rotated. the second time rotate it, same url back, after appending =s300-c image rotate, third time rotate, need change =s300-c -s301-c in order see new image. if go =s300-c, previous rotation of image. appending ?datetimegoeshere doesn't work leaves me believe caching happening on google's side , it's not browser problem. what can append image serving url in order latest version of image? i'm using following code write rotated image: gcsservicefactory.creategcsservice().delete(filename); gcsoutputchannel outputchannel = gcsservicefactory.creategcsservice().createorreplace( filename, gcsfileoptions.getdefaultinstance()); outputchannel.write(bytebuffer.wrap(newimage.getimagedata())); outputchannel.close(); and code generate new serving url: string newim

MySQL replication positioning changes -

i using concept of mysql master master replication synchronizing data between 2 servers. now problem exists me upon editing data in table, changes reflected @ other end. master_log_pos changes on every change whenever update or change in data done @ either end. can me this? thanks in advance the question seems unclear me because behavior describing normal. when data on master changes, master should write changes binlog, whether change initiated locally or came in on replicatiom stream... log file positon advance on both machines, if log_slave_updates global variable turned on @ each master. you turn off, shouldn't, because neither server's binlog have complete copy of changes, regardless of source, severely complicating or eliminating possibility of using either server's binlog point in time recovery. if thinking there's loop, you're partially correct, because there is. when "a" sends event "b," "b" execute eve

c++ - How do I register global variables independently in a single global array -

i'm writing this, well, call library guess. offers set of global variables of type mytype. now, want write source of each of these mytype's in own .cpp , .h files, unaware of rest, without needing central header file saying mytype* offerings = { &global1, &global2, /*... */ } . now, had these been different classes want able instantiate, want use factory pattern; here they're of same type, , don't need instantiate anything. think each variable needs 'registered' global array (or unordered set) somewhere in sources. so, what's idiomatic way this? you take @ registry pattern , create manager filesystem or folder manage these objects. the registry have related filesystem handling insert object names , properties in model in 1 config file or database. registry , instantiate objects on runtime. now need mechanism communicate objects rest of system. if objects not going change registry compile time objects do. the registry pattern

Caching JSON string vs Java Object -

in 1 of web services, caching result using memcached. can either cache result json or source object. if cache source object, have convert json everytime before sending result(i doing in code because i'm using json views dynamiccaly restrict few columns). if cache json string(considerably large), have return it. question is, json string consume more memory java object or bad idea cache json strings? if cache source object via memcache, has serialized , deserialized. lot of overhead. caching json object faster. two advices on this: avoid character encoding: if possible store json object byte array , not string or char array , return via httpresponse.getoutputstream(json). way bypass additional character encoding. cache whole response: if json result of rest query, event better cache complete request via caching server in front of application (e.g. varnish, nginx, apache traffic server.). put right http cache headers on , fine.

protocol buffers - How to retrieve protobuf data rendomly? -

i want store large amount of data in protobuf format in include time-stamp parameter. , want retrieve data based on time-stamp value. thanks. protobuf sequential-access format. there's no way jump middle of message looking data; have parse through whole thing. some options: devise framing format allows break datastore many small chunks, each of separate protobuf message. large project. use sqlite or actual database. use random-access-fieldly format cap'n proto instead. (disclosure: i'm author of cap'n proto, , of protobufs v2 (google's open source release).)

PostgreSQL:How to return result of a SELECT statement within a function using PostgreSQL? -

here have following function, not getting how return result. create or replace function f1() returns void $body$ begin select "fname", "lname", count("city" = 'a-b' or null) "a-b", count("city" = 'c-d' or null) "c-d", "table1" "city" in ('a-b','c-d') group 1,2 order 1,2 change return type returns table (fieldname type, fieldname type, ...) , use return query select ... . see the pl/pgsql docs .

css - vertical rhythm using less -

recently, i've read this article vertical rhythm , i'm trying implementation based on article using less , wondering if i'm doing right way because based on math 24px font have line height of 1px if math. :d ( never @ math ). .font-size(@target-px-size, @context-px-size: @base-font-size) { font-size: @topx; font-size: @torem; .rem(@target-px-size, @context-px-size); } .rhythm(@target-px-size) { .font-size(@target-px-size); @result: unit((@base-line-height / @target-px-size)); line-height: @result; margin-top: unit(@result, px); margin-top: unit(@result, rem); margin-bottom: unit(@result, px); margin-bottom: unit(@result, rem); } // rem calculator .rem(@target-px-size, @context-px-size: @base-font-size) { @divide-by: unit(@context-px-size); @sizevalue: unit(@target-px-size); @remvalue: round(@sizevalue / @divide-by, 1); @topx: unit(@sizevalue, px); @torem: unit(@remvalue, rem); } this seems work. h

c - which is more efficient? repetitive assignment or repetitive checking -

if had loop checks specific value in array and, reason, must iterate on elements , cannot break midway. which of following more efficient: blindly setting flag on each match, or checking if flag false before setting it. bool happened = false; while (...) { if (...) { happened = true; } } vs bool happened = false; while (...) { if (...) { if (!happened) happened = true; } } as far can tell, both more or less equivalent on assumption memory reads fast memory writes (ignoring instruction in second example). correct in conclusions? the compiler make decision you, if use meaningful optimization. write whatever cleanest , makes sense. me first one, since less code , doesn't introduce more code paths. fun, did tests in clang 3.4 -o3: bool happened = false; extern volatile int dontoptme1, dontoptme2, dontoptme3; while (dontoptme1) { if (dontoptme2) { happened = true; } } dontoptme3 = happened; vs bool happened = false; extern volatile

Rails server exits on startup. (Rails 4.0.2) -

rails server keeps exiting on startup. though worked little while ago. haven't tweaked since. => booting webrick => rails 4.0.2 application starting in development on http: //0.0.0.0:3000 => run `rails server -h` more startup options => ctrl-c shutdown server exiting /home/kavya/.rvm/gems/ruby-2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:229:in `default_controller_and_action': missing :controller (argumenterror) /home/kavya/.rvm/gems/ruby-2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:116:in `normalize_options!' /home/kavya/.rvm/gems/ruby-2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:64:in `initialize' /home/kavya/.rvm/gems/ruby-2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1443:in `new' /home/kavya/.rvm/gems/ruby-2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1443:in `add_route' /home/kavya/.rvm/gems/ruby-2.1.0/gems/actionpa

javascript - Chrome developer toolbar -functional clarification? -

Image
i have been using chrome developer toolbar quite long time , yet have questions regarding way displays data : question #1 why after editing dom ( f2 ) , , adding <<script>alert(1)</script> - doesn't execute alert? i mean difference make vs : var script = document.createelement('script'); script.src = "..."; document.getelementsbytagname('head')[0].appendchild(script); question #2 why changing value of input , wont reflect new value in panel ? for example : if server sends input value : and add 222 : why doesn't reflect change ? ( vice versa work). question #3 there way see in pane actual sent html (like view source)? (e.g. if server send &lt; want see &lt; , not < ). mean - sometimnes need debug browser got server... #1 editing script node text content directly when editing script node in element panel, not call script re compilation/interpretation resulting in alert not be

c++ - qt says libxml2 is not installed on windows -

i have cloned qt project git , when try build it, says libxml2 not installed. thne downloaded libxml2 , put bin's path environmental variable's described in readme. has not changed anything. shows me same error. there special way of configuring libsml2 qt?

c - 16*2 LCD interfacing with Beagleboard xM using kernel module -

i trying interface 16x2 lcd beagleboard xm using gpio. have done using shell script , it's working good. want achieve same functionality writing kernel module. know little bit kernel programming i'm in learning phase. need guidance. in advance! writing kernel module different shell scripting. must write own code in c++, declaring kernel mode, , compile it. found 1 example, don't have time check it, leaving you. here 1 example of writing kernel modules, , here 1 tutorial interfacing 16x02 lcd.

ember.js - Using current User for Ember Data Queries -

i using ember simple auth authenticate backend. got working. problem how nicely ember-data. have ressources have end points this: /api/users/:user_id/activities the problem don't know how inject :user_id route current user. and there other scenarios when want show data of user , in cases pass different user id. my routes not helping, since showing activies on dashboard, , therefore don't have user_id in route. in session, or simpleauth stores user. there's example in ember.simpleauth repo shows how extend authenticated account/current user: https://github.com/simplabs/ember-simple-auth/blob/master/examples/4-authenticated-account.html

ruby on rails - "NameError - uninitialized constant" when running function from singleton model -

i'm getting "nameerror - uninitialized constant store::directededge" when call below statement controller. store.instance.add_purchase(1, 2) below singleton 'store' model: require 'singleton' class store include singleton def initialize @database = directededge::database.new(env['directed_edge_username'], env['directed_edge_password']) end def add_purchase(user_id, product_id) item = directededge::item.new(@database, "user#{user_id}") item.link_to("product#{product_id}", "purchase") item.save end ... end anyone have idea problem is? try require directededge require 'directed_edge' . here link documentation directed edge example.

xml - How can i get appropriate .properties file using servlet when i have multiple .properties file in web-inf folder? -

<param-name>language</param-name> <param-value>en</param-value> </context-param> <context-param> <param-name>country</param-name> <param-value>us</param-value> </context-param> <context-param> <param-name>language</param-name> <param-value>jp</param-value> </context-param> <context-param> <param-name>country</param-name> <param-value>jp</param-value> </context-param> this web.xml file code. servletcontext app = getservletcontext(); localelang = app.getinitparameter("language"); localecountry = app.getinitparameter("country"); this jsp code i'm accessing properties files based on language , country. i.e., when lang en , country need access en_us.properties file , when lang jp , country jp need access jp_jp.properties file when have 100 properties file how can access propert

java - storing data from jtable into array -

i'm using jtable in application.i want store jtable data array.while i'm entering data table , when press delete button delete data in cell , click button store data array, shows error numberformatexception because of pressing delete button.how can solve this? code is int source = 0; int temp = integer.max_value; int dist = 0; adjacencymatrix = new int[nodes][nodes]; (int row = 0; row < dtm.getrowcount(); row++) { (int col = 1; col < dtm.getcolumncount(); col++) { if (dtm.getvalueat(row, col) == null || (dtm.getvalueat(row, col) == "") || (dtm.getvalueat(row, col) == " ")) { adjacencymatrix[row][col - 1] = integer.max_value; } else { adjacencymatrix[row][col - 1] = integer.parseint((string) dtm.getvalueat(row, col)); // system.out.println("row ----" + row + "------" + (col - 1) +

php - Escaping Fields Array in CakePHP -

i have: $subquery = $dbo->buildstatement( array( 'fields' => array( "case when application.program_type_id = 3 , application.program_type_id not null {$keys['program_type_id_program_type_id']} else 0 end program_type_score, case when application.priority_subject_area_id = 1 , application.priority_subject_area_id not null {$keys['priority_subject_area_id_priority_subject_area_id']} else 0 end priority_subject_area_priority_subject_area_score, user.*" ), 'table' => $dbo->fulltablename($this), 'alias' => 'user', 'limit' => null

urllib2 - Python upload fails (only half of the file uploaded) -

i have python uploader function fails because uploads part of file (tested binaries , text files). def upload_u(logger, encoded_credentials, local_file_path, remote_path): logger.info("uploading %s %s...", local_file_path, remote_path) url = "https://my-artifactory-repo-site.org/artifactory/my-artifactory-repository/%s" % remote_path authentication_header = "basic %s" % encoded_credentials logger.info("calling %s", url) f = open(local_file_path, read_file_as_binary) request = urllib2.request(url, data=f.read()) f.close() request.get_method = lambda: put_request request.add_header(authorization_header_key, authentication_header) request.add_header('content-length', os.path.getsize(local_file_path)) request.add_header('content-type', 'application/octet-stream') print request.headers response = none try: response = urllib2.urlopen(request) print res

html5 - How to fix this php syntax error? -

how fix syntax error on line 4. if ( function_exists('register_sidebar') ) register_sidebar(array( 'before_widget' => '', 'after_widget' => '<img src="<?php bloginfo('template_url');?> /img/sub_page/horizontal_separator.png" style="margin-bottom: 15px;" alt="" />', 'before_title' => '<h3>', 'after_title' => '</h3>', )); add_action( 'init', 'register_my_menu' ); you dont need reopen php echoing string. it should be: if ( function_exists('register_sidebar') ) register_sidebar(array( 'before_widget' => '', 'after_widget' => '<img src="'.bloginfo('template_url').'"/img/sub_page/horizontal_separator.png" style="margin-bottom: 15px;" alt="" />',

php - How to use CodeIgniter dompdf for large dataset -

i'm generating pdf file in codeigniter using dompdf .but gives me blank out no errors. if pass limit query pdf gets generated remove limit query gives me blank output. same thing happens when used mpdf . can 1 me solution? my code follows function pdf_create_param($html, $filename, $stream=true) { require_once("dompdf/dompdf_config.inc.php"); $dompdf = new dompdf(); $dompdf->load_html($html); $dompdf->set_paper("a3", "landscape" ); $dompdf->render(); if ($stream) { $dompdf->stream($filename.".pdf"); } else { return $dompdf->output(); } }

ios - Block is preventing dealloc although the block was copied -

i believe following rules still problem exists my class init includes block this: httpchunkreceiveblock chunkblock = ^(id connection, nsdata *data) { nslog(@"hi there!!"); }; and passing block httpconn obj class holds: operation_ = [[httpclient sharedclient] performchunkedrequest:url chunkhandler:chunkblock]; now problem: object never deallocated!! the problem seems caused because httpconn keeping pointer block , want mention 2 points: the block not referring self! the httpconn class keeping copy of block, this: chunkblock_ = [chunkblock copy]; explanation appreciated! edit extra info: have verified if i'm freeing operation_ object deallocated fine: reader.operation_ = nil; reader = nil; //previous line allows 'dealloc' called now repeating question: operation did not pointer of reader's self , holds copy of block not refer self! ok, i answer own questio

java - logic for dynamic String using split function -

string x= "100,000" string []y=x.split(","); string z= y[0]+y[1] (give me expected result 100000) my question if x dynamic, may sometime has "2 comas". "3 comas" (1,00,000 or 1,00,00,000 ) dynamic, can used separate comas , combine string. you can replace ',' nothing instead of splitting string. in java this: s.replaceall(",",""); if want split need loop iterates on string parts , puts new string. example in java: string x= "100,000" string []parts=x.split(","); string z= ""; for(string part : parts){ z+=part; }