Posts

python - Backtracking to generate all numbers within constraint -

i trying create function generates numbers can formed through combination of primes satisfy constraint of being within 99% of number , less or equal number. primes [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43] , exponents [39, 19, 9 , 6, 3, 3, 2, 2, 1, 1, 1, 1, 1, 1] the code have uses 1 of each prime , stops, 2^1*3^1*5^1*...*17^1 or something, doesn't increment exponents. not sure wrong here, don't know problem is. here code def rec(start): global freqa global global exp if start >=length:return true print a," ",freqa if a>= int(0.99*curt): in xrange(length): exp[i]=exponents[i]-freqa[i] rec1(0) in xrange(exponents[start]): freqa[start]+=1 a*=primes[start] if a<=curt , rec(start+1): return true freqa[start]-=1 a/=primes[start] return false line exp[i]=exponents[i]-freqa[i] not in loop just in case: 17! = 355 687 428 096 000

android - Exiting asynctask midway through doinBackground on conditional -

i'm loading data async task. in doinbackground() , want check if json string returned contains error, if want stop asynctask , display textview, if there's no error, want continue executing asynctask. code. protected string doinbackground(string... args) { // building parameters httpclient client = new defaulthttpclient(); httppost post = new httppost(url_all_open_bets); list<namevaluepair> params = new arraylist<namevaluepair>(); post.setheader("user-agent","mozilla/5.0 (macintosh; intel mac os x 10_9_5) applewebkit/537.36 (khtml, gecko) chrome/43.0.2357.81 safari/537.36"); params.add(new basicnamevaluepair("email", name)); params.add(new basicnamevaluepair("user-agent","mozilla/5.0 (macintosh; intel mac os x 10_9_5) applewebkit/537.36 (khtml, gecko) chrome/43.0.2357.81 safari/537.36")); try { post.s...

ruby on rails - Can I send delayed_job an in-memory only ActiveRecord object? -

so had emails didn't go out due mailing service api key not being instantiated. however, detail model objects preserved in database. don't want re-create these in database. i wrote rake task send out emails , easier try , create temporary in-memory objects rather try find correct activerecord objects based on in detail_params. send out emails using detailmailerjob , pass in instantiated detail object. temp_obj = detail.new(detail_params) detailmailerjob.new.delay.notify_job(temp_obj) but i'm noticing following error in delayed::job.all queue after running rake task: last_error: "activerecord::recordnotfound does mean way me pass in detail object detailmailerjob first find instantiated record in database? (i.e., no in-memory objects) edit: here detailmailer & detailmailerjob class. class detailmailerjob def notify_job(detail) detailmailer.notify_job(detail).deliver end end class detailmailer < actio...

reactjs - missing ) after argument list when using react-router -

i'm using react-router v0.13.3 , react 0.13.3 build simple web app. big issue happened when tried integrate react-router. so, here's error message: uncaught syntaxerror: missing ) after argument list app.jsx var router = window.reactrouter; var route = router.route; app.view_search = 'search_view'; app.view_favorite = 'favorite_view'; app.view_result = 'result_view'; var routehandler = router.routehandler; var app = react.createclass({ render () { return ( <div> <h1>app</h1> <routehandler/> </div> ) } }); // declare our routes , hierarchy var routes = ( <route handler={app} path="/"> <route path="search" handler={app.searchview}/> <route path="about" handler={app.aboutview}/> <router.defaultroute handler={app.searchview}/> </route> ); router.run(ro...

spring websocket - Can I add request parameter to SockJs constructor so that it can be send to server -

i initialize sockjs url as var protocols = ['xhr-polling', 'xdr-polling', 'xdr-streaming', 'xhr-streaming']; var options = {protocols_whitelist: protocols, debug: true,server:tets}; _ws = new sockjs(url, null, options); i want send out request parameter , example somesite/sockjs/info?someparam=tets" is possible? documentation of sockjs refers options map can have key value not sure key use here. i verified url @ server sockjs sends on , http://http_backend/cecobrowsega-3.0.0.0.31/sockjs/testapp/620/4ydem52f/xhr?null so in absence of request param appending null, seems there way send on request param! it's available in latest sock js client. discussion here https://github.com/sockjs/sockjs-client/issues/72 we can pass query string along connection url, same syntax http call

c - read() not working properly -

i trying read txt file using read() , print out output. the text file has these numbers: 123 456 227 and code shown below #include<stdio.h> #include<stdlib.h> #include <fcntl.h> #include<io.h> int main(int argc, char*argv[]){ char* input; char* output; int fd; int temp = 0; if(argc != 3){ printf("too many or few arguments\n"); exit(-1); } input = argv[1]; output = argv[2]; fd = open(input,o_rdonly,0); if(fd == -1){ printf("read failed"); exit(-1); } while(read(fd, &temp ,sizeof(int)) != 0){ printf("%d\n", temp); } close(fd); } i tried running , output 221458993 909456394 842150410 842150455 what doing wrong? you need perform formatted i/o int value representation. fscanf() or better, fgets() friend.

Magento Translate is not defined -

i'm getting error in site , messing css , of js files. uncaught referenceerror: translate not defined any ideas? in page.xml file in layout directory missing translate.js file <action method="addjs"><script>mage/translate.js</script></action>