Posts

c# - Json.NET parse array in object -

i'm having extremely difficult time parsing multiple arrays out of array, embedded in several object in json. basically json looks like { took:8, success:true, items:[ keywords:{...}, maininfo:{ name:'...', expdate:'...', targetcities:[...], targetstates:[...] }, additionalinfo:{ skills:[], hometime:'' } } my c# looks like: public class job{ public string name{get;set;} public list<string> targetcities{get;set;} public list<string> targetstates{get;set;} public list<string> skills{get;set;} public string hometime{get;set;} } public class jobs{ private jobject o; private list<job> jobs; public jobs(string json){ this.o=jobject.parse(json); } public list<job> tolist(){ list<jobject> alljobs=o["items"].select(t => (jobject)t).tolist(); foreach(jobject in alljobs){ job j=new job(); j.name=(string)i["maininfo"][...

python - pytee can not produce proper output in python3 -

i have piece of code runs in python 2.7.5 doesn't work python 3. the major problem tee.write , can not write file. this piece of code suppose write 20 letters a file /tmp/tee-test-1 , /tmp/tee-test-2 not, 2 files empty… could 1 give me advice? import sys import os import subprocess #from netsa.util.shell import * string import template __author__ = 'brandon sandrowicz <brandon@sandrowicz.org>' __version__ = '0.1' valid_modes = ['a','w'] def create_tee(files, mode, buffer_size=128): if mode not in valid_modes: raise ioerror("only valid modes create_tee() are: %s" % ', '.join(valid_modes)) tee_list = [] file in files: if type(file) == str: fp = open(file, mode) tee_list.append(fp) else: tee_list.append(file) pipe_read, pipe_write = os.pipe() pid = os.fork() if pid == 0: ...

Python: how to pass a index range as parameter -

i know possible, there other way pass 0:100 ? a=range(1000) ohlc.c.ix[a] thank you! pass slice object. a = slice(0, 100)

how to scale an image on python-opencv? -

when tried scale photo in python gives me error: indentationerror: unindent not match outer indentation level my code: cv.setimageroi(image, (pt1[0], pt1[1],pt2[0]-pt1[0], int((pt2[1] - pt1[1]) * 0.6))) the problem indentation in python. in python code must aligned when in same scope.

django - how to make python __FILE__ display symbolic path when accessed use symbol path -

the __file__ convenient macro designed access current file path in python. there's issue when use it. have file /home/a/b.py when accessed directory __file__ macro in b.py should give /home/a/b.py correct. created symbol link under /var/www/a -> /hom/a when b.py accessed /var/www/a expect macro in b.py give path /var/www/a/b.py . not case. although file accessed form symbol path /var/www/a, macro still giving real file path /home/a/b.py i've tried abspath , realpath in python os package. there api can peel out symbolic path wanted? you can use first argument command line if script called full path. here's example ran: import sys print(sys.argv) from command line: python test.py # results in ['test.py'] python /full/path/test.py # results in ['/full/path/test.py']

How to parse PHP output that has multiple arrays -

ok i'm using btc-e api , i'm calling using this: $btc_usd = $btceapi->getpairticker('btc_usd'); // show information print_r($btc_usd); and output print array ( [ticker] => array ( [high] => 640.04199 [low] => 605.00201 [avg] => 622.522 [vol] => 4217103.07651 [vol_cur] => 6723.54768 [last] => 636.1 [buy] => 636.1 [sell] => 635.999 [updated] => 1394418227 [server_time] => 1394418228 ) ) how parse returns/prints number [last] example: so output looks "636.1" can save variable. this array of arrays. outer element ticker : $btc_usd["ticker"]["last"];

ios - tabbarcontroller + navigation. How to make so that landscape one representation had an orientation -

i created application in has: viewcontroller , navigationviewcontroller , tabbarviewcontroller . i have many tabs , respectively many representations. problem when click 1 tab there should portrait orientation. when click following tab should have representation types of orientation. precisely understand want, start skype application on iphone. first tab can't pass landscape, second can't transfer. if opening chat should possible transfer mode of orientation. i tried add following code, works in navigationcontroller not in tabcontroller . tabcontroller : int test = 0; public override uiinterfaceorientationmask getsupportedinterfaceorientations() { int = 0; foreach (var v in viewcontrollers) { if (v.gettype () == typeof(createcompviewcontroller)) { test = i; break; }i++; } int s = test; test++; if (...