Posts

python - Override a field in parent class with property in child class -

where looks this: class a(object): def __init__(self, val): self.x=val self.y=42 # other fields class b(object): def __init__(self): self.a=22 # other fields class c(a,b): def __init__(self, val): super(c,self).__init__(val) @property def x(self): # if a.x none return value can compute a.y , b.a # if a.x not none return @x.setter def x(self, val): # set field value sometimes want set assumed value x hand, in case use a . in other cases want use more complicated approach involves computing a.x 's value on basis of information organized b . idea in code make c class can a (in terms of x field) doesn't need field value set hand, instead gets derived. what can't figure out how have c.x property shadow a.x field in sensible way. the line self.x = val in a.__init__ method invoke c.x setter . have handled here. handling per instance attributes here, ...

java - How to add to an arraylist without creating an embedded array -

i know arraylist has .add() method, reason, whenever add prexisting arraylist, end getting embedded array.... have method returns objectinputstream, 1 or more objects , depending on conditional, wanted add , present user, however, it's embedding objectinputstream array. for example: 1. [item1] 2. [item1, item2] 3. [[item1, item2], item3] 4. [[[item1, item2], item3], item4] it keeps going this. i'd prefer if more this: [item1, item2, item3, item4] the issue is, using arraylist.add() method instead of arraylist.addall() method. add() method adds object passed on list, addall takes collection, , adds each element in collection list- want. another issue note is, not using generics. have avoided error completely. i have sample code convenience in online java compiler ide . as side note, in future when asking programming questions, embed small sample of relevant code in online ide codiva or ideone , want answer.

html5 - passing information of an item selected in a select tag to a table with mvc 4 -

this part of view: 1- select tag content <select name="select1" id="select1" class="nostyle" style="width: 100%;"> <option></option> @{ foreach (var item in model) { <option value=""> @html.actionlink(item.title, "getvalindicateurs", new { idindicateur = @item.id_indicateur })</option> } } </select> 2-i can select item, problem need show parameters of item in following table: <tbody role="alert" aria-live="polite" aria-relevant="all"> @if (session["listvaleur"] != null) { foreach (sire_portail.models.valeurs_indcateur item in (list<sire_portail.models.valeurs_indcateur>)session[...

javascript - Array only retriving first LatLng data from multiple locations an passes same all time to infowindow content -

ok problem facing trying retrive "latlng" array "locations" variable "tere" (sitelatlng). way shows value of first latlng value , keeps adding every marker. need passes "latlng" correspondant marker. appreciated. :) this code markers: var markers = []; function initmap() { var directionsdisplay = new google.maps.directionsrenderer; var directionsservice = new google.maps.directionsservice; var guanajuato = new google.maps.latlng(21.0158803, -101.2540116); var map = new google.maps.map(document.getelementbyid('map'), { center: guanajuato, zoom: 16 }); var locations = [ ['ocho', 21.017137, -101.253186, 1], ['siete', 21.017119, -101.252922, 2], ['seis', 21.017154, -101.253055, 3], ['cinco', 21.017444, -101.253144, 4], ]; var marker, i; var infowindow = new google.maps.infowindow(); google....

python - Looping through a paginated api asynchronously -

i'm ingesting data through api returns close 100,000 documents in paginated fashion (100 per page). have code functions follows: while c <= limit: if not api_url: break req = urllib2.request(api_url) opener = urllib2.build_opener() f = opener.open(req) response = simplejson.load(f) item in response['documents']: # here if 'more_url' in response: api_url = response['more_url'] else: api_url = none break c += 1 downloading data way slow , wondering if there way loop through pages in async way. have been recommended take @ twisted , not entirely sure how proceed. what have here not know front read next unless call api. think of like, can in parallel? i not know how can in parallel , tasks, lets try... some assumptions: - can retrieve data api without penalties or limits - data processing of 1 page/batch can done independently 1 other what slow io - can split...

c++ - Why this code runs perfectly in visual studio with multibyte characher set but not with unicode char set? -

when run code on g++ , runs smoothly, when run code on visual studio wiith unicode char set option, doesn't print product id. can explain me how fix problem , why happens? #include <windows.h> #include <stdio.h> #include <iostream> using namespace std; wchar_t* getregistrykeyvalue(const char* regkey, const char* ppidname) { hkey registry; long returnstatus; dword regtype = 0; dword regsize = 0; char* ppid = 0; returnstatus = regopenkeyex(hkey_local_machine, regkey, 0, key_query_value | key_wow64_64key, &registry); if (returnstatus == error_success) { returnstatus = regqueryvalueex(registry, ppidname, 0, &regtype, 0, &regsize); ppid = new char[regsize]; /* value. */ returnstatus = regqueryvalueex(registry, ppidname, 0, &regtype, (lpbyte)ppid, &regsize); regclosekey(registry); if (ppid[regsize] > 127 || ppid[regsize] <...

javascript - gzip compression is not detected by PageSpeed Insights (node.js) -

i build gzip-files gulp ( gulp-gzip ) , use them npm package connect-gzip-static : var app = express(); var servestatic = require('connect-gzip-static'); //... app.use(servestatic(__dirname)).listen(3000); however, pagespeed insights not detect gzip compression. but google chrome developer console says: response headers: content-encoding: gzip. other seo testing tools detecting gzip. why google doesen't ? i gziped html, js, css. should gzip svg's ? thanks! pagespeed insights should tell resources not gzipped. often third party resources out of control, or may types svg have not enabled yet. pagespeed insights should taken guide , not gospel. it's easy become hung on it. if ignore bigger reasons site slow save few bytes on 1 resource.