Posts

oop - Python overriding getter without setter -

class human(object): def __init__(self, name=''): self.name = name @property def name(self): return self._name @name.setter def name(self, value): self._name = value class superhuman(human): @property def name(self): return 'super ' + name s = superhuman('john') print s.name # doesn't work :( "attributeerror: can't set attribute" s.name = 'jack' print s.name i want able override property able use super parent's setter without having override setter in child class. is pythonicaly possible? use just .getter decorator of original property: class superhuman(human): @human.name.getter def name(self): return 'super ' + self._name note have use full name reach original property descriptor on parent class. demonstration: >>> class superhuman(human): ... @human.name.getter ... def name(self): ... return...

android - Cannot open navigationbar -

i click floatingactionbutton open navigation menu, not working drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout); floatingactionbutton fab = (floatingactionbutton) findviewbyid(r.id.fab); fab.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { drawer.isdraweropen(gravitycompat.start); } }); no errors in logcat. 1 help. your isdraweropen method checks if drawer open or not , not doing checks. can use in onclick method: if(drawer.isdraweropen(gravitycompat.start)) { closenavdrawer(); }else { drawer.opendrawer(gravitycompat.start); } closenavdrawer method: protected void closenavdrawer() { if (drawer != null) { drawer.closedrawer(gravitycompat.start); } }

c++ - Compilation errors with CImg -

i using cimg library first time , compilation errors simple test program includes cimg.h. why that? how can fix this? program code: #include "../headers/cimg.h" using namespace cimg_library; int main() { return 0; } compilation errors: in function 'file* cimg_library::cimg::fopen(const char*, const char*)': 5065|error: '_fileno' not declared in scope in function 'int cimg_library::cimg::fseek(file*, int_ptr, int)': 5093|error: '_fseeki64' not declared in scope in function 'int_ptr cimg_library::cimg::ftell(file*)': 5102|error: '_ftelli64' not declared in scope this done on pc 64 bit windows 8.1. command: g++.exe -wall -fexceptions -g -std=c++11 -c "d:\informatics\projects\image experiments\rectangle circle stretcher\sources\main.cpp" -o obj\debug\sources\main.o i tried without -std=c++11 part , 2 errors instead of 3. don't 5065|error: '_fileno' not declared in scope . same happens ...

sql - MySQL - Filter records which date is biggest -

i have mysql select query: select s.* campaign_statistic s inner join campaign c on s.campaign_id = c.campaign_id c.campaign_id = 51 , date(s.created_date) between date(c.start_date) , date(c.end_date) and getting result: id campaign_id instagram_id media_id has_tag comments_count likes_count created_date status ** *********** ************ **************************** ******** ************* *********** ******************* ****** 1 51 1230544324 957801995790641919_1230544324 1 16 2015-11-01 13:10:29 1 2 51 1230544324 957799073015065299_1230544324 2 11 2015-11-01 13:10:29 1 3 51 1230544324 957790310736521811_1230544324 5 20 2015-11-01 13:10:29 1 4 51 1230544324 957801995790641919_1230544324 1 16 ...

dictionary - Swift MapKit Polygon overlay -

Image
i have polygon on mapview, want add 2 1 in different color. there way todo so? this mapview should 2. polygon overlay in different color func addboundry() { var points=[ cllocationcoordinate2dmake(51.711963, 8.738251), cllocationcoordinate2dmake(51.711963, 8.763717), cllocationcoordinate2dmake(51.718574, 8.763717), cllocationcoordinate2dmake(51.71855, 8.754448)] let polygon = mkpolygon(coordinates: &points, count: points.count) mapview.addoverlay(polygon) } func mapview(mapview: mkmapview!, rendererforoverlay overlay: mkoverlay!) -> mkoverlayrenderer! { if overlay mkpolygon { let polygonview = mkpolygonrenderer(overlay: overlay) polygonview.fillcolor = uicolor(red: 0, green: 0.847, blue: 1, alpha: 0.25) return polygonview } return nil } is there way todo so? solved via .title use in if

osx - How to run php files after upgrading OS X Yosemite to El Capitan? -

i've upgraded os x el capitan. created php file inside local server. newly created file displayed without error, previous files in same directory shows php code in browser. also, cannot access phpmyadmin , shows forbidden you don't have permission access /phpmyadmin/ on server. i have run ls -l see file permissions in folder working on, seems ok. don't see change previous files new file have created. how can fix this? upgrading el capitan reset apache config. need change enable modules requires in case mod_alias .

find - Capturing data between specific tag in python -

i getting url content in python... want capture between <h1> , </h1> . what tried is: mystring='''<h1>kgkgjgjgkjgkjgkj</h1> <h1>kdfgggggggggggggggggggkgjgjgkjgkjgkj</h1> dsfgdfgg <h1>kgkgjgjgkdfgdfgdgdfjgkjgkj</h1> dfgdffdgf <h1>kgkgjgjsdssssssssssssssssssssgkjgkjgkj</h1> dfgdfgdg <h1>kgkgjgjgkjgkjgkgggggggggggggggggggj</h1> ''' if '<h1>' in mystring: startstring='<h1>' endstring='</h1>' print mystring[mystring.find(startstring)+len(startstring):mystring.find(endstring)] i have multiple h1 tags. capture data between first h1 tag. how can capture data between h1 tags? i go beautifulsoup-- attempt from bs4 import beautifulsoup import requests url = 'http://accessibility.psu.edu/headingshtml/' respons = requests.get(url).content soup = beautifulsoup(respons,'lxml') h1tags = soup.find_all('h1...