Posts

dictionary - extending built-in python dict class -

i want create class extend dict's functionalities. code far: class masks(dict): def __init__(self, positive=[], negative=[]): self['positive'] = positive self['negative'] = negative i want have 2 predefined arguments in constructor: list of positive , negative masks. when execute following code, can run m = masks() and new masks-dictionary object created - that's fine. i'd able create masks objects can dicts: d = dict(one=1, two=2) but fails masks: >>> n = masks(one=1, two=2) traceback (most recent call last): file "<stdin>", line 1, in <module> typeerror: __init__() got unexpected keyword argument 'two' i should call parent constructor init somewhere in masks. init probably. tried **kwargs , passing them parent constructor, still - went wrong. point me on should add here? you must call superclass __init__ method. , if want able use masks(one=1, ..) syntax have u...

java - Wizard not redrawing/revalidating jframe -

i'd create wizard app in java. came point draw frame 3 different layouts, each containing label , 'next' button, when click button on first frame see empty frame instead. import java.awt.borderlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.imageicon; import javax.swing.jbutton; import javax.swing.jframe; import javax.swing.jlabel; public class mainframe extends jframe implements actionlistener{ private borderlayout layout; public mainframe() { super("mywizz"); setsize(500, 500); setresizable(false); setdefaultcloseoperation(jframe.exit_on_close); setvisible(true); setlocationrelativeto(null); } protected imageicon createimageicon(string path, string description) { java.net.url imgurl = getclass().getresource(path); if (imgurl != null) { return new imageicon(imgurl, ...

css - element on right side of window overlapped on window resize -

i have 2 sets of (jquery mobile) buttons on left , right hand side of page. when shrink window left side, left hand set of buttons moves expected, keeping space between , window border. when shrink form right side, window overlaps set of buttons on side. how can avoid this? have both sets of buttons retain percentage horizontal position whether shrink screen right or left. (wheni shrink bottom, both sets of buttons retain space top border of window). css: #mainpage{ position:relative; } .submenuclass{ /* right side */ display: none; position: absolute; z-index: 10000; top: 2%; left:85%; } .mainmenuclass{ /*left side*/ display: none; z-index: 10000; position:absolute; top: 2%; left: 5%; } .submenuclass{ /* right side */ display: none; position: absolute; z-index: 10000; top: 2%; right:5%; /*change this,you may need adjust value*/ }

java - Design pattern for import and update actions -

i have small component required application. component loads csv file , updates customer records based on data finds. there single csv file every customer update. checks file location csv files for each csv file finds, load csv file, parse , update customer data updated data thats it. however im torn between couple of ways this. have single updater() class everything. have update() class representation of loaded csv data, knows how parse csv etc. , have updater() class responsible updating customer records. update() class have updater() which of these correct solution or there other better solutions this? if thinking of real general design, consider following: class updateset : list of updates. csv file if want. interface updateinstance : different types of updates, request point of view. csv line if want. class insertinstance : implements updateinstance . insert request. class deleteinstance : implements updateinstance . delete request. ...

join - One-to-many mapping in hibernate -

my levelterm.hbm.xml file is: <hibernate-mapping> <class name="com.entity.levelterm" table="level_term" catalog="test"> <id name="levelid" type="java.lang.integer"> <column name="level_id" /> <generator class="identity" /> </id> <property name="level" type="int"> <column name="level" not-null="true" /> </property> <property name="term" type="int"> <column name="term" not-null="true" /> </property> <property name="session" type="int"> <column name="session" not-null="true" /> </property> <list name="list_course"> <key column="level_id"/> <one-to-many column="course_code...

linux - How to execute a command inside a screen session -

i know how execute command inside screen session. searched , found : screen -s nameofscreen -x stuff "command" when type this, command typed inside screen not executed. queston how press enter using command. in bash shell can use ctrl-v explicitly put non-printable characters string. try ctrl-v ctrl-l ctrl-v ctrl-m @ end of command before " .

ios - SDWebimage to load image in custom UITableViewCell, but when scroll the image load in other cell random -

i have insert in uitableview custom uitableviewcell sdwebimage project, , load image: [cell.img_cell setimagewithurl:[self.url objectatindex:indexpath.row] placeholderimage:[uiimage imagenamed:nil] completed:^(uiimage *image, nserror *error, sdimagecachetype cachetype) {...}]; but when scroll uitableview image in 1 cell, goes in cell example doens't have loaded yet image, , continue effect cell scroll, , if scroll tableview fast cell have loaded right image first, change random said above, how can fix it? your table cells being reused scroll. means when image load finishes, cell might not "belong" original url anymore. what should set image nil in tableview:cellforrowatindexpath: clear out reused images , then cancel pending requests in tableview:didenddisplayingcell: , doesn't make efficient use of network bandwidth. a better approach move image loading code table controller (using sdwebimagemanager ) , have wait...