Posts

python - pyinstaller no predefined compiler for raspberry pi -

i want convert myscript.py exexutable file. using raspberry pi(raspbian) , python 2.7. i issuing following command sudo pip install pyinstaller sudo pyinstaller myscript.py after processing provides error fatal error: pyinstaller not include pre-compiled bootloader platform. see <http://pythonhosted.org/pyinstaller/#building-the-bootloader> more details , instructions how build bootloader. i go online build compiler not understand process. how solve problem? suspect path compilation of bootloader wrong platform may mentioned in forum here cd /usr/local/lib/python2.7/dist-packages/pyinstaller/bootloader sudo mv linux-32bit linux-32bit-arm for rpi need bootloader... may cloned pyinstaller v3.1.1 rpi same thing, change directory name arm platform after have build pyinstaller cd /path/to/pyinstaller/pyinstaller/bootloader cp -r linux-32bit linux-32bit-arm

networking - Locate pc on local network -

we have 10000 or more computers in our network. want find computer ip. there way learn switch computer connected to? have 1 router in our network. i try , mac address computer then. depending on kind of switches have telnet switch , find out if mac address connected through there. idea comment not have privilege to.

c - How to show bytes of float -

i use function show_bytes follows: #include<stdio.h> typedef char *byte_pointer; void show_bytes (byte_pointer x) { int length = sizeof(float); int i; for(i = 0;i <length;i++) { printf("%2x",*(x+i)); printf("\n"); } } int main() { float obj; printf("please input value of obj:"); scanf("%f",&obj); show_bytes((byte_pointer) &obj); } when input 120.45,which should 0x42f0e666 please input value of obj:120.45 66 ffffffe6 fffffff0 42 why many 'f' before e6 , f0 while use %.2x. your function should be: void show_bytes (byte_pointer x) { int i; for(i = 0; <sizeof(float); i++) { printf("0x%2x\n", (unsigned int)(*(x++) & 0xff)); } } or typedef uint8_t *byte_pointer; void show_bytes (byte_pointer x) { int i; for(i = 0; <sizeof(float); i++) { printf(...

How to speed up this ElasticSearch query? -

i'm trying build auto suggest based on docs title. if user types 'south', auto suggest suggest 'south korea' example. used shingle filter break title 2 words. here mapping : { "settings":{ "analysis":{ "filter":{ "suggestions_shingle":{ "type":"shingle", "min_shingle_size":2, "max_shingle_size":2 } }, "analyzer":{ "suggestions":{ "tokenizer":"standard", "filter":[ "suggestions_shingle" ] } } } }, "mappings":{ "docs":{ "properties":{ "docs_title":{ "type":"multi_field", "fields":{ ...

javascript - pass value to function in form of <select> -

this question has answer here: get selected value in dropdown list using javascript? 17 answers all want pass <select> </select> value javascript function. here code: function test() { var gender = document.getelementbyid("gender").value; } html <form action="" method="post" onsubmit="test()"> <select name="gender" id="gender"> <option selected="" value="default">select</option> <option value="male">male</option> <option value="female">female</option> </select> </form> try this var element = document.getelementbyid("gender"); var gender = element.options[element.selectedindex].value;

python - Finding if any element in a list is in another list and return the first element found -

it easy check if element of list in list using any() : any(elem in list2 elem in list1) but there anyway idiomatic way return first element found? i'd prefer one-line solution rather than: for elem in list1: if elem in list2: return elem this answer similar an answer on a similar question , @jamylak goes more detail of timing results compared other algorithms. if want first element matches, use next : >>> = [1, 2, 3, 4, 5] >>> b = [14, 17, 9, 3, 8] >>> next(element element in if element in b) 3 this isn't efficient performs linear search of b each element. create set b has better lookup performance: >>> b_set = set(b) >>> next(element element in if element in b_set) if next doesn't find raises exception: >>> = [4, 5] >>> next(element element in if element in b_set) traceback (most recent call last): stopiteration you can give default return instead, e.g. none . c...

Highcharts add several series with PHP array -

i'm using highcharts display database informations, when use 1 series haven't problems, when want add several series on chart, it's little bit difficult. first php script : foreach ($informationslier $keyfille => $fille) { $grafdata = array(); foreach ($fille['information'] $keyinfos => $information) { $mois = $information['created']->format('m'); $mois = $mois - 1; $timestamp = strtotime($information['created']->format('j').'-'.$mois.'-'.$information['created']->format('y')); //multiply 1000 seconds in js $timestamp = $timestamp * 1000; $grafdata[$keyinfos] = array($timestamp, (float)$information['valeur']); //$grafdata[$keyinfos] = implode(', ', $grafdata[$keyinfos]); //$grafdata[] = "[date.utc(".$information['created']->format('y').','.$mois.','...