Posts

c - Zero a large memory mapping with `madvise` -

i have following problem: i allocate large chunk of memory (multiple gib) via mmap map_anonymous . chunk holds large hash map needs zeroed every , then. not entire mapping may used in each round (not every page faulted in), memset not idea - takes long. what best strategy quickly? will madvise(ptr, length, madv_dontneed); guarantee me subsequent accesses provide new empty pages? from linux man madvise page: this call not influence semantics of application (except in case of madv_dontneed ), may influence performance. kernel free ignore advice. ... madv_dontneed subsequent accesses of pages in range succeed, result either in reloading of memory contents underlying mapped file (see mmap(2)) or zero-fill-on-demand pages mappings without underlying file. ... the current linux implementation (2.4.0) views system call more command advice ... or have munmap , remap region anew? it has work on linux , ideally have same behaviour on os...

javascript - JS: displaying an infinitely long coordinating system (grid) -

i display infinitely long coordinating system/grid (x , y axes), contains endless amount of square (something divs), using javascript. don't have idea start. seems me hard problem solve. there many factors of don't have idea build them, such as: structuring them in html element tree using right elements (probably svg elements) giving grid fluid scroll coordinating loading of each element (if has displayed) i sure there javascript libraries, can me doing it, don't know of these. what way start with? here concept of grid: (y axis) ^ | | | | |--+------+------+--- | e| squre| squre| sq | | | | |--+------+------+--- | e| squre| squre| sq | | | | |--+------+------+--- | e| squre| squre| sq +--------------------> (x axis) while in comments said similar graphing, give kineticjs peek. uses canvas's , bit of overkill attempting it's great resource has many uses since you've requested grid, here question on...

c# - Windows 8 style charmbar in WPF? -

Image
i want create wpf application docked on right side of screen. want act windows 8 charms bar. the bar shouldn't visibile on default when mouse of user comes right side of screen. how can achieve ? i want run application on vista/windows 7 example of charmbar : •you can place window of application right of screen. need handle events when mouse enters (mouseenter) , leaves (mouseleave) form move form , down. •you can use background thread call getcursorpos method @ set interval (i.e. each 500ms) second check mouse is. see link more information , sample code: http://www.pinvoke.net/default.aspx/user32.getcursorpos . (if need check mouse position, can use timer simplify application.) from: create dock application using c# , wpf to sliding effect follow how show window sliding effect right left in wpf and position window: how set location of wpf window bottom right corner of desktop? moral of story stop asking questions have been asked many time. ...

Prolog: store solutions in a list -

this simple question ;) fact(a). fact(b). test(x):-fact(x). the solutions x=a; x=b. ok i'm trying create: test(x,l):-fact(x), ??? returns l=[a,b] can me? thanks. use findall/3 aggregate solutions: test(l):- findall(x, fact(x), l).

java - MapResult with CypherDSL -

i have query, built cypher-dsl (b/c match -clause dynamic) , result-set contains nodes represented @nodeentity annotated pojos (amongst other columns). my question is: there way have result of dynamic (non-annotated) query, wrapped @mapresult (or regular map nodeentities values)? the following approach doesn't seem work, because inferred type of graphrepository has either node- or relationshipentity: @nodeentity public class customer { @graphid long id; ... } @mapresult public interface customerqueryresult { @resultcolumn("cust") customer getcustomer(); @resultcolumn("val1") int getval1(); ... } public interface customerqueryrepository extends graphrepository<customerqueryresult> { } @service public class searchservice { private customerqueryrepository repo; ... @inject public searchservice(customerqueryrepository repo, ...) { this.repo = repo; ... } public iterable...

immutability - Is using a StringBuilder a right thing to do in F#? -

stringbuiler mutable object, f# encourages employing immutability as possible. 1 should use transformation rather mutation. apply stringbuilder when comes building string in f#? there f# immutable alternative it? if so, alternative efficient? a snippet i think using stringbuilder in f# fine - fact sb.append returns current instance of stringbuilder means can used fold function. though still imperative (the object mutated), fits reasonably functional style when not expose references stringbuilder . but equally, can construct list of strings , concatenate them using string.concat - efficient using stringbuilder (it slower, not - , faster concatenating strings using + ) so, lists give similar performance, immutable (and work concurrency etc.) - fit if building string algorithmically, because can append strings front of list - efficient operation on lists (and reverse string). also, using list expressions gives convenient syntax: // concatenating strings using + ...

javascript - In Safari on iPad is there a way to stop the page rubber banding BUT still allow overflows too scroll? -

there's lot of snippets stop rubber-banding on ipad, 1 below: document.body.addeventlistener('touchmove',function(event){ event.preventdefault(); },false); however has unwanted effect of preventing divs overflows on them scrolling too? is there way top page (body) rubber-banding while still allowing overflowed-scrolled divs so? the rubber-banding of entire page seems happen when user scrolling bottom or top of div. code i've written checks see if user indeed @ 1 of extremes , if prevents scrolling action happening in directions. elem.bind("touchstart", function( e ) { xstart = e.originalevent.changedtouches[0].screenx; ystart = e.originalevent.changedtouches[0].screeny; }); elem.bind("touchmove", function( e ) { var xmovement = e.originalevent.changedtouches[0].screenx - xstart; var ymovement = e.originalevent.changedtouches[0].screeny - ystart; if( elem.scrolltop() == (elem[0].scrollheight - elem[0].client...