Posts

c++ - How are state flags represented and how bitwise OR is used to work with bit flags? -

if open file reading, may define 1 or more state flags, example: ios::out ios::out | iso::app i read bitwise or, , how "merges" 2 bit sets, for example: 1010 | 0111 = 1111 now being said, not understand how works "behind scenes" when use method ifstream.open(filename, stateflaga | stateflagb | stateflagc) , on. can elaborate more on inner workings of these state flags , memory representation? edit: give more emphasis on trying understand (if helps), assume open method receive 1 or more state flags separate arguments in signature, , not delimited bitwise or, want understand how bitwise or works on these state flags produce different final state when combining several flags, , result allows me use 1 argument state flag or set of state flags. ie: ifstream.open(filename, stateflaga | stateflagb | stateflagc) and not ifstream.open(filename, stateflaga , stateflagb , stateflagc) if take gnu libstdc++ implementation , @ how these implemented,...

mongodb - Check if value exist into array field mongoid rails -

i have groups field in mongodb database "groups" : "[\"5514efcc6970640f40150100\", \"5514efcc6970640f40160100\", \"5514efcc6970640f40170100\", \"5514efcc6970640f40180100\"] please suggest query check if field exist above database array. like modelname.find(:groups=> 5514efcc6970640f40150100) looks have string in groups , not array. string looks called inspect on array of bson objectids in ruby , stored stringified array in mongodb. the leading double quote here: ⬇ "groups" : "[\"5514efcc6970640f40150100\", ... ⬆ tells you have string. inside string have looks array of strings still string. if that's have think you're stuck regex searches (which slow), like: model.where(:groups => /"5514efcc6970640f40150100"/) that assumes groups strings consistently formed , stringified arrays of hexadecimal strings. if case i'd suggest fi...

python - If statement deleted by else statement in Tkinter -

i'm creating dictionary myself in tkinter , when added else statement (for query isn't in dictionary) deleted first if statement (index). i don't know why. entry (exe) works without problems else , index works else deleted. def search_button(self, event=none): if self.entry.get() == 'index': self.search_result.set("alea jacta est") if self.entry.get() == 'exe': self.search_result.set("lorem ipsum") else: self.search_result.set("entry not in database.") your 2nd if should elif : def search_button(self, event=none): if self.entry.get() == 'index': self.search_result.set("alea jacta est") elif self.entry.get() == 'exe': self.search_result.set("lorem ipsum") else: self.search_result.set("entry not in database.") the problem code if entry text 'index' search_result set "alea jacta...

Searching for a list of words within a Tkinter text widgit in Python 2.7 -

i've been trying button check on tkinter gui search entered text text widget specific word , make appear red, i've managed using following code: list_of_words = ["foo", "bar`enter code here`"] def check(): global counter text.tag_remove('found', '1.0', end) idx = '1.0' x = 0 while true: idx = text.search(list_of_words[x], idx, nocase=1, stopindex=end) if not idx: break lastidx = '%s+%dc' % (idx, len(list_of_words[x])) text.tag_add('found', idx, lastidx) idx = lastidx text.tag_config('found', foreground='red') counter += 1 print counter however need able search input words on list_of_words list , display them red. there way of doing this? your code not increment x so, if first word present, while loop never terminate. does, however, increment global variable counter no apparent reason. why not iterate on list of target words loop? inner while loop se...

opencv - Draw convex hull on android -

i try draw convex hull on image.for this, find contours , select max area contour. drawcontours accepts matofpoint convexhull gives me matofint . read question , run codes. of them draw convex hull, cannot find convex points. i use below code, has runtime error on last line m.fromarray(hullpoints.get(i)); . hullpoints.get(i) has 1 point , code cannot create matofpoint object. how can convert matofpoint matofint ? // find convex hull list<matofint> hull = new arraylist<matofint>(); for(int j=0; j < contours.size(); j++){ hull.add(new matofint()); } for(int j=0; j < contours.size(); j++){ imgproc.convexhull(contours.get(j), hull.get(j)); } // convert matofint matofpoint drawing convex hull // loop on contours list<point[]> hullpoints = new arraylist<point[]>(); for(int j=0; j < hull.size(); j++){ point[] points = new point[h...

jquery - loop through text and replacing * with span -

i struggling script should replace text , make bold via css. but problem is, script isn't looping. takes first text. can me out? here's my fiddle . and here's code $(document).ready(function (i) { $('.main:contains("*")').each(function () { $(this).html($(this).html().replace('*', '<span class="highlight">')); $(this).html($(this).html().replace('*', '</span>')); }); }); this 1 trick: $(document).ready(function (i) { function replace(o) { $(o).html($(o).html().replace('*', '<span class="highlight">')); $(o).html($(o).html().replace('*', '</span>')); if ($(o).html().indexof("*") >= 0) { replace(o); } } replace('.main:contains("*")'); });

html - not splitting div's properly -

this has been posted before, couldn't find solution searching. i'm new html , css started ~1 week ago, if there solution explanation go long way rather modified code/solution. so attempting split div 2 columns 1 of 25% width , other 75% width. haven't started doing css yet hence why styling inline @ moment. general div of 100% width displays fine when try split 2 inner div's seems work list trying create displays correctly next column of 75% appears below div. why , there anyway fix it. <div style="width:100%;background:orange"> <div style = "text-align:center;width:25%;background-color:red;"> list <ul> <li> something</li> <li> something</li> <li> something</li> <li> something</li> <li> something</li> </ul> </div> <div style="width:75%;background:purple;"> ...