Posts

Python imaplib deleting multiple emails gmail -

my code this... import imaplib import email obj = imaplib.imap4_ssl('imap.gmail.com','993') obj.login('user','pass') obj.select('inbox') delete = [] in range(1, 10): typ, msg_data = obj.fetch(str(i), '(rfc822)') print x = response_part in msg_data: if isinstance(response_part, tuple): msg = email.message_from_string(response_part[1]) header in [ 'subject', 'to', 'from', 'received' ]: print '%-8s: %s' % (header.upper(), msg[header]) if header == 'from' , '<sender's email address>' in msg[header]: delete.append(x) string = str(delete[0]) xx in delete: if xx != delete[0]: print xx string = string + ', '+ str(xx) print string obj.select('inbox') obj.uid('store', string , '+flags', '(\deleted)') obj.expunge() obj.close() obj.logout() the error ...

Lucene 6.2 and ISO-8859-1 (latin) characters -

i'm trying lucene index searcher on project. the content of documents indexed have latin (iso-8859-1) characters, users can (and will) search using charset. as far know, lucene generates index files using utf-8. questions: 1) there way specify charset when searching lucene? or have manually convert query utf-8 , run search? 2) indexsearcher.search() method not ignoring whitespaces, have guess "tokens" right meaningful results show up. if user forgets add whitespaces on searched term, no results showed. there way configure searcher (or queryparser) ignore whitespaces? not quite sure running trouble here. presume reading user input string, i'm don't know issue come up. providing code clarify that. if are, indeed, reading byte array user input, yes, converting necessary. it's not laborious process convert byte[] string though. use string ctor . queryparser tokenizes @ whitespace if analyzer have passed it does. standardanalyzer ty...

c++ - Getting error message saying my class does not name a type when trying to overload the "+" operator -

the part giving me error message in implementation file when wrote definition friend function overloads operator +. saying statistician not name type. friend function , written in implementation file header included not sure why not recognize this. realize spelled statistician wrong file name, don`t know how rename file in codeblocks. //header file #ifndef statistician_h #define statistician_h namespace gregory_stocker_statictician{ class statistician{ public: statistician(); void next_number(double); void erase_sequence(); int get_length() const {return length_sequence;} double get_sum() const{return sum;} double get_mean() const; double get_largest() const; double get_smallest() const; double get_last() const; friend statistician operator + (const statistician &,const statistician &); private: int length_sequence; double sum; double smallest; double largest; double last; }; #endif } //implement...

android - Add the result of several broadcasts on a single activity -

in application have broadcastque receives pushs notifications in background, push open activity information request accepted, happens @ same moment reading request receive app open on top in new intent. public class broadcastreceiveronesignal extends broadcastreceiver { @override public void onreceive(context context, intent intent) { bundle extras = intent.getbundleextra("data"); try { jsonobject customjson = new jsonobject(extras.getstring("custom")); if(customjson.has("a")){ string id = customjson.getjsonobject("a").getstring(constants.id_corrida); intent = new intent(context, activty.class); i.putextra(constants.id, id); i.addflags(intent.flag_activity_clear_top |intent.flag_activity_new_task); context.startactivity(i); } }catch (exception e){ e.printstacktrace(); } } } you can check if activity in foreground change it's content. if not, start activity. you c...

ruby - Sinatra / Rails : How to pass user input between views -

i've been looking bit , can't find or rather understand do, i'm sure quite simple i'm new ruby , web apps, 1 in sinatra simplicity. i'd pass @multiplication_table variable things user puts inputs next results page can see if put in answers correctly dont know how to, think know how form_for dont know how having loop. this web.rb file # web.rb require 'sinatra' def create_table(number) possibles = [1,2,3,4,5,6,7,8,9,10,11,12] int_set = possibles.shuffle result = [] @answer_list = [] while int_set.length > 0 random_int = int_set[0] string = (number.to_s + " x " + random_int.to_s) int_set.delete(random_int) if (random_int.to_s).length == 1 string += " &nbsp;&nbsp;= ______" else string += " = ______" end result << string @answer_list << random_int.to_i * number.to_i end return result ...

javascript - Three.js Inaccurate Raycaster -

i trying detect clicks on plane mesh. set raycaster using examples guide. here code: http://jsfiddle.net/bar24/o24eexo4/2/ when click below marker line, no click detected though click inside plane (marker line has no effect). also try resizing screen. then, clicks above marker line may not work. maybe has use of orthographic camera? or not updating required matrix? function onmousedown(event) { event.preventdefault(); mouse.x = (event.clientx / window.innerwidth) * 2 - 1; mouse.y = -(event.clienty / window.innerheight) * 2 + 1; //console.log("x: " + mouse.x + ", y: " + mouse.y); raycaster.setfromcamera(mouse, camera) var intersects = raycaster.intersectobjects(objects); if (intersects.length > 0) { console.log("touched:" + intersects[0]); } else { console.log("not touched"); } } your css affect raycasting calculations. 1 thing can set body { margin: 0px; } for more information, s...

c++ - How to set the top/bottom margins of a Win32 richedit -

Image
we can use em_setmargins message set left/right margins of richedit control. don't know how set top/bottom margins. body knows? thanks. use em_getrect / em_setrect message combination modify margins: rect rc; // current control rectangle sendmessage(hwndrichedit, em_getrect, 0, (lparam)&rc); rc.left += 20; // increase left margin rc.top += 20; // increase top margin rc.right -= 20; // decrease right margin rc.bottom -= 20; // decrease bottom margin (rectangle) // set rectangle sendmessage(hwndrichedit, em_setrect, 0, (lparam)&rc); the resulting control has 4 margins: update : per barmak shemirani , iinspectable comments below use getclientrect function current rectangle , inflaterect function manipulate rectangle / margin dimensions.