Posts

python - Can executables made with py2app include other terminal scripts and run them? -

so have nice python app os x working great. runs external terminal script , include in python app. ideally, i'd able run py2app , have script bundled executable , able include , run in python portion of code. possible? thanks in advance! extra edit: script using compiled. can't inside , paste it. see http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html#option-reference , @ --resources parameter. example: python setup.py py2app --resources foo if shell script, valid thing do. binary executable, it's bit more hacky. first, p2app's documentation says "not code!". second, os x documentation says not put executables in resources directory. main reason code signing: default settings "seal" in resources part of main app's signature, separate executables not supposed sealed way, they're supposed signed separately. however, being said, still work. except won't end +x permissions, after py2app step, you'll have "chmod +x ...

mongodb: field sorted by number of occurances -

i have collection each document representing virtual auction. want find common item id given time period. in sql, i'd select item, count(*) count group item , usual sorting , limits. there mongodb equivalent this? mongodb has several options here. in version 2.1.0+ can use new aggregation framework . there's conversion chart right here . in older versions can use either map / reduce for simple versions of aggregation ca use special aggregation operators . each of these options have different syntax , different speed. in of these cases, find these options relatively slow. map / reduce jobs intended run "off-line", "cron job" or "scheduled task". note if plan lot, want pre-aggregate data.

C++ basic array assignment is not working -

so have function f(int d[],int a[],int len){ for(int k = 0; k < len; k++) d[k] = a[k]; and if output d numbers wrong. function f called d initialised int* d = new int[100000]; in main function , a because output in function , looks ok. so... can't understand problem is... tried memcpy(d+k,a+k,sizeof(int)); , doesn't work. your loop works perfectly. problem must somewhere else in code. here example program copies data in 3 different ways: for loop, memcpy , , std::copy : #include <algorithm> #include <cstring> #include <iostream> #include <iterator> void copy1(int d[], int a[], int len) { for(int k = 0; k < len; k++) d[k] = a[k]; } void copy2(int d[], int a[], int len) { std::memcpy(d, a, len*sizeof(int)); } void copy3(int d[], int a[], int len) { std::copy(a, a+len, d); } int main () { int a[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; int *d = new int[10]; std::ostream_iterator<int> out(std::cout, ","); // first, print...

python - unpack the first two elements in list/tuple -

is there way in python this: a, b, = 1, 3, 4, 5 and then: >>> 1 >>> b 3 (the above code doesn't work throw valueerror: many values unpack .) just add nolen's answer, in python 3, can unpack rest, this: >>> a, b, *rest = 1, 2, 3, 4, 5, 6, 7 >>> 1 >>> rest [3, 4, 5, 6, 7] unfortunately, not work in python 2 though.

PHP MYSQLI number of rows doesnt work no errors -

i have login form when user clicks login checklogin.php called , should check username , password matches record on database if true else print wrong password or username so far wrong password username though correct username&&password. have made somechanges no echo, printf or error how can fix issue? form <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#cccccc"> <tr> <form name="form1" method="post" action="checklogin.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#ffffff"> <tr> <td colspan="3"><strong>member login </strong></td> </tr> <tr> <td width="78">username</td> <td width="6">:</td> <td width="294"><input name=...

sshfs - Why is vim syncronous in file loading and saving? -

i'm working on vim on sshfs mounted filesystem high latency. opening , saving file takes 9 seconds of blocking editor. is there way can block tab i'm in , still work other tabs while files saving , loading? writing blocking operation because vim single threaded: can't 2 things @ same time. afaik when vim has written file locally, sshfs uploads remote server before "notifying" vim it's done. whole process can , take quite time. there better ways: vcs (git, svn, mercurial…) or ftp client folder monitoring capabilities (transmit, yummy ftp, fetch…) example.

php - MySQL finding rows in one table with information from another -

currently, have 2 mysql tables. first table stores relation between friend , picture. table 1 id | pic_id | friend_id ---------------------------- 0 | 123 | 84589 1 | 290 | 11390 2 | 884 | 84589 table 2 second table stores more information pic... id | pic_id | title | color | detail ---------------------------------------------- 0 | 123 | hello | black | brush 1 | 124 | world | red | paint 2 | 884 | sample | green | star i have friend_id , need grab pic_id table 1 , use pic_id grab columns table 2(title, color, detail)... how in mysql? thank you! simply join 2 tables. select b.title, b.color, b.detail table1 inner join table2 b on a.pic_id = b.pic_id friend_id = 84589