Posts

ios - UICollectionView indexPathsForVisibleItems don't update new visible cells -

i have viewcontroller collectionview inside. when view loads, visible cells (9 cells) shown correctly. when scroll down, want load visible items in collectionview loadimagesforonscreenrows calling indexpathsforvisibleitems partnercollectionview. when loadimagesforonscreenrows indexpathsforvisibleitems has allways first 9 cells in it, when cells 10 18 should visible on screen. code use is: #import "partnerlistviewcontroller.h" #import "appdelegate.h" #import "partner.h" #import "imageloader.h" #import "partnerdetailviewcontroller.h" @interface partnerlistviewcontroller () @end @implementation partnerlistviewcontroller @synthesize lbltitle; @synthesize partnercollectionview; @synthesize imagedownloadsinprogress; @synthesize fetchedresultscontroller; @synthesize managedobjectcontext; - (void)viewdidload { [super viewdidload]; // additional setup after loading view. appdelegate * appdelegate = (appdelegate *) [[uiappl...

python - How can I force ElementTree to write to disk every change? -

i have deal huge xml file create big database. from database structure generate xml tree, ends eating memory (over 10gb now), process never end since system can't process new query. i think solution avoid saving xml structure memory, , dump directly disk whenever add new. is can do? how? thanks! i'm not sure how code works, it's done. depending on how it's structured, create timestamp , compare incoming data old data, or scan file whether current xml has been added. after (assuming new code) following: path = "path/" name = "filename" xmlroot = element("root")#create root element xml structure xmlsub = subelement(xmlroot,"sub") subname = subelement(xmlcard,"name") subname.text = "element text" savename = path + name + ".xml" #constructs location of xml file (path/filename.xml) tree = elementtree(xmlroot) #compiles tree tree.append(savename) #appends specified file this outpu...

c# - How can I get two controls on separate forms bound to the same datasource to update each other? -

i have form lot of fields on it, of optional; reasons beyond control, required fields scattered throughout form rather than, say, grouped @ top big "required" label. i've been asked make separate form can launched main form has required fields. idea user can bring "required fields" form, enter necessary data automatically shows in main form enter it, close "required fields" form , fill in optional fields want on main form, , save form. i've got fields on "required" form bound exact same data sources associated fields in main form, , know that's working because can enter information in "required" form , save, , entered data gets saved. problem while data source behind scenes gets updated, corresponding field on other form doesn't . i'd able have typed in required field on either form instantly show in corresponding field on other form, people understand it's storing input regardless of field use. i know...

multithreading - java.concurrent.ReentrantLock - why we want to acquire the same lock multiple times -

this question has answer here: why use reentrantlock if 1 can use synchronized(this)? 5 answers i know if using reentrantlock, allows same thread acquire same lock more once. internally, has counter count number of lock acquisition. if acquired same lock twice, need release twice. question why want acquire lock multiple times, should 1 time acquisition enough? can give me common use case? consider following case in need set of operations isn't atomic, atomic. example may want set value of array return current value upon setting. (try-finally removed brevity). final reentrantlock lock = new reentrantlock(); final object[] objects = new object[10] public object setandreturnprevious(int index, object val){ lock.lock(); object prev = get(index); set(index,val); return prev; lock.unlock(); } public void set(int index, object val){...

.htaccess - Rewrite rules for a branch of content formerly under a CNAME alias -

i'm migrating blog installation new server. original installation on amazon server. new server location true server amazon install made appear @ through dns changes , cname alias. the aliased urls looked this... blog.domain.tld/articles/{title of articles} at new , true domain location, false "blog" aliasing dropped, , new url structure be... domain.tld/articles/{title of articles} i need setup mod_rewrite rules calls old fake urls land people @ new , true ones. i've seen examples online of root-to-subdirectory or subdirectory-to-root redirects on same server, in case faux subdirectory involved on different server, i'm not sure do. i'm not sure makes sense (or possible) redirect aliased url. anyone have pointers, insights, or examples? in advance. this similar redirecting www. links non-www links, following should work: rewritecond %{http_host} ^blog\.domain\.tld$ rewriterule (.*) http://domain.tld/$1 [r=301,l]

Windows gadget - javascript changing CSS -

i'm working on schedule school on windows desktop. have issue changing, because value of "getday" still on 0 , display default.css. here check code: var currdate = new date(); var currday = currdate.getday(); var newcss = "default.css"; if (currday = 0) newcss = "default.css"; if (currday = 1) newcss = "pondeli.css"; if (currday = 2) newcss = "utery.css"; if (currday = 3) newcss = "streda.css"; if (currday = 4) newcss = "ctvrtek.css"; if (currday = 5) newcss = "patek.css"; if (currday = 6) newcss = "default.css"; document.getelementbyid('sitecss').href = newcss; whats wrong? :-) use "==" in ifs: if (currday == 0)...

arrays - using perl, how to select last 2 lines in the case of each row has same word? -

bini -- -21.89753 -20.47853 -20.27835 -18.34952 -16.23454 bini -- -16.89753 -14.47853 -13.27835 -12.34952 -11.23454 bini -- -10.09014 my file has array shown above. , array starting bini array having multilines showing 3 lines here. wanted try extract last 3 elements last 2 lines. so, -12.34952 -11.23454 -10.09014 these 3 elements wanted. sometimes, last line may have elments 2 5 depending on files. here, has 1 elements last line. what tried follows while(my $line = <file>) { if($line =~ /bini/) { #extract last 3, 2, 1 element @entries = split(/ws+/,$line); $element1 = (pop@entries); $element2 = (pop@entries); $element3 = (pop@entries); } as result, see element1 -10.09014, unfortunately, couldn't element 2 , element 3. me? .. i want keep original script. mean,, creaing process of result.txt , opening method of "log" output format. blockquote #!/usr/bin/perl use warnings; use strict; u...