Posts

php - HttpURLConnection check whether JSON string has been inserted in mysql successfully -

i implemented android code send json string server. getting json string '{"mac": "23:a5:j0:06:c6:e9", "latitude":84.16898451,"longitude":3.16561387,"route": 1}' output in doinbackground method , getting output output of getresponsecode: the output of getresponsecode: 200 in client side. i checked php file in localhost , when fresh index.php homepage, bus table being created , data updated if change values in json string. not connect s4 device localhost directly check since using public hotspot. i have uploaded index.php file online file manager in htdocs directory on byethost.com server, table bus being created no record being inserted , updated. is possible httpurlconnection check whether data has been inserted/updated in bus table? should add path first parameter of file_get_contents method else php://input ? doinbackground method: protected void doinbackground(string... params) { // todo auto-ge...

c - include errno if not accessed directly -

do need include errno.h if don't access errno directly? eg. void *mem = malloc(16384); if (mem == null) { perror("malloc"); exit(exit_failure); } i tried simple piece of code without including errno.h , worked, i'm not sure if it's ok this. maybe errho.h included in other libraries stdlib.h , don't need explicitly include myself? you don't need <errno.h> if use perror() . from linux programmer's manual : name perror - print system error message synopsis #include <stdio.h> void perror(const char *s); #include <errno.h> const char *sys_errlist[]; int sys_nerr; int errno; this means need <errno.h> if use sys_errlist , sys_nerr or errno . note sys_errlist , sys_nerr bsd extensions. similar entries can found on c99 standard. 7.19.10.4 perror function synopsis #include <stdio.h> void perror(const char *s); and need ...

python - Get last element of type string in a list -

suppose have list of different types: i.e. [7, 'string 1', 'string 2', [a, b c], 'string 3', 0, (1, 2, 3)] is there pythonic way return 'string 3' ? if have given type, can use several kinds of comprehensions need. [el el in lst if isinstance(el, given_type)][-1] # gives last element if there one, else indexerror or next((el el in reversed(lst) if isinstance(el, given_type)), none) # gives last element if there one, else none if you're doing enough, can factor function: def get_last_of_type(type_, iterable): el in reversed(iterable): if isinstance(el, type_): return el return none

How to call/use data returned by python function in javascript? -

i've defined function in views.py this def ma_fonction_bokeh(request, numero = none): cdr_common = settings.dbcon[settings.mongo_cdrstats['cdr_common']] acc = cdr_common.find() donnees = [] # on initialise une liste in acc: if i['accountcode'] == numero: donnees.append([calendar.timegm(i["start_uepoch"].timetuple()), i["duration"]]) data = simplejson.dumps(donnees) return render(request,"frontend/mongraphe.html", {"name": numero, "data": data}) then in mongraphe.html file i've created javascript code plot got http://www.highcharts.com/stock/demo/dynamic-update want customize plot own data returned function defined @ first... how can that? i've tried ajax function without result you can transfer data python code javascript in several ways. the "proper" way create endpoint returns json data , use ajax request (for example, jquery.getjs...

Import data from text file to mysql in php -

i want import data txt file mysql in php my txt file as: id name rollno grno inoutdatetime 1 test 1 1 10/4/2015 05:20:00 2 test2 2 2 11/4/2015 08:20:00 and not have insert duplication of date data row create database table columns according needs. create table yourtablename ( id int, name varchar(100), rollno int, grno int, inoutdatetime varchar(100) ) engine=innodb; if txt file follows same format example. $fhandle=fopen("textfile.txt", "r"); fgets($fhandle); //first fgets read on header line. while($line=fgets($fhandle)){ //explode line space delimeter $words=explode(" ",$line); /* additional checks , data sanitizing here. */ //if every line follows format in example, , not empty, insert table here $sql="inser yourtablename values ($words[0], $words[1], $words[2], $words[3], $words[4])"; ...

android - Update ListView everytime the Data changes -

i'm building chat using php , java, i'm getting data chat using json file, , inserting data calling php file inserts new message database. i'm listing messages in listview , , trying update listview everytime new message sent, code working, automatically update listview when send new message. i have click @ chat room again see listview updated. update listview both users, receiver , sender. i tried update adapter using: notifydatasetchanged(); didn't work. how can that? code: my adapter: @override protected void onpostexecute(void result) { super.onpostexecute(result); // dismiss progress dialog if (pdialog.isshowing()) pdialog.dismiss(); /** * updating parsed json data listview * */ adapter = new costumeadapter( chatroomactivity.this, contactlist, r.layout.chat_row, new string[]{ tag_message, tag_conversation }, ...

Filtering out correlation values in seaborn corrplot -

Image
i'm using corrplot function in seaborn , works flawlessly. however, want little filtering on data. there way hide correlations below or above value? have large data frame , want see correlations greater arbitrary number, .4. i'd 'squares' in image not greater .4 set white, grey or other color. i'm not sure how because corrplot takes full data frame , calculates correlations internally. don't want filter on data frame values, resulting correlation values. maybe there's way resulting image underlying matshow call own code , replot filtering image itself?