Posts

Showing posts from September, 2011

jquery - Making vertical list scroll on mouse over -

i have vertical list in navigation longer screens height. when start hover on list list start in move when mouse around half way down list. any advice on appreciated. thank in advance. one approach, below: var ul = $('ul:first'), ulheight = ul.outerheight(); ul.on('mousemove', function(e){ var win = $(window), cst = win.scrolltop(); if (e.pagey>=(ulheight/2)){ win.scrolltop(cst + 20); } else { win.scrolltop(cst - 20); } });รข€‹ js fiddle demo . this based upon halfway point of list itself, , therefore relies on halfway point being visible on page itself. to make more functional, ul within containing element, , scrolling based upon being past halfway point of containing element: var div = $('#wrap'), wrapheight = div.height(), listheight = div.find('ul').outerheight(); div.on('mousemove', function(e){ var cpointy = e.pagey, cst = div.scrolltop(); if (cpointy >= (wrapheight/2)) { div.scrolltop(cst + 15); } else { div.scrolltop(cst...

Is Python reevaluating arithmetic operations with bignums each time the resut is used? -

okay, trying throw in large number evaluation on python - of order of 10^(10^120)- realized quite huge. anyways, receded 10**10**5 , 10**10**6. checking time difference of 2 brought me strange finding see inefficiency. the finding when tried cprofile.run("x=10**10**6") took 0.3s , cprofile.run("print 10**10**6") took 40s . then tried x= 10**10**6 took no time thereafter every time interpreted x ( x followed enter ) take long time ( 40s suppose). so, assuming every time interpret x calculates entire value on again. so question is: isn't extremely inefficient? had declared variable in module, x= 10**10 , , every time reference x python interpreter compute value of 10**10 on , on again ? gory details appreciated. the value not being recalculated each time print it, long delay see cost of converting large number string displaying.

objective c - Restkit object mapping gives null objects -

i have entity (on core data ) called contact , each contact has neighborhood , user , contactorigin entities related it. when retrive json data server, this: { "contact" : [ { "prospect" : { "pkprospect" : 21, "name" : "test contact", "email" : "test@domain.com", "phone" : "5555555555", "address" : "test avenue", "media" : { "pkmedia" : 3, "name" : "referรƒยชncia entrevista move" }, "neighborhood" : { "pkneighborhood" : 15857, "name" : "donwtown" } }, "user" : { "firstname" : "john", "pkperson" : 5, "lastname" : "doe" } } ] } so can see, have array of contacts , each contact has user node, neighborhood node , media node (which use origin on database). restkit seems mapping right way code: // getting object manager. rkobjectmanager *obje...

c# - .net File.Copy very slow when copying many small files (not over network) -

i'm making simple folder sync backup tool myself , ran quite roadblock using file.copy. doing tests copying folder of ~44,000 small files (windows mail folders) drive in system, found using file.copy on 3x slower using command line , running xcopy copy same files/folders. c# version takes on 16+ minutes copy files, whereas xcopy takes 5 minutes. i've tried searching on topic, find people complaining slow file copying of large files on network. neither large file problem nor network copying problem. i found interesting article better file.copy replacement , code posted has errors causes problems stack , near knowledgeable enough fix problems in code. are there common or easy ways replace file.copy more speedy? one thing consider whether copy has user interface updates during copy. if so, make sure copy running on separate thread, or both ui freeze during copy, , copy slowed down making blocking calls update ui. i have written similar program , in experience, code ran fas...

xcode - New build settings with LLVM Compiler on macros -

i created new cocoa project on xcode 4.3.3. preprocessor macros apple llvm compiler 3.1 settings have debug=1 $(inherited) value assigned. removed , add again, , i'm getting error when compiling : clang: error: no such file or directory: 'debug=1' i search value on project settings , saw value defined in "other warning flags" my questions are: what difference between having debug vs debug=1 ? what $(inherited) do? what doing on other warning flags? first, if you're getting compilation error, put macro in incorrect place in project settings. please ensure you've put debug configuration branch of preprocessor macros item under apple llvm compiler x.x - preprocessing section. for other questions: the first version defines macro debug it's empty. can test whether exists or not exist, not much. second sets 1 preprocessor can comparisons #if debug && should_die_on_error might abort if application comes across validation erro...

javascript - Knockout JS - data-bind multiple values -

question js knockout library - have 3 inputs, data-bind-ed same variable. 2 have boolean value of false , 1 has boolean value of true. (i can't change them ints, unfortunately, make problem easier). although 2 false-valued inputs share behavior, need differentiate between them somehow trigger different behaviors. is possible data-bind each variable, different values? instead of each being <input data-bind="checked:test" value="false"> i have like <input data-bind="test, test2" value="false, 1"> and <input data-bind="test, test2" value="false, 2">? i tried directly , didn't work don't know if it's possible. much. you cant bind multiple variables directly creating custom bind function trick you. example : http://jsfiddle.net/gurkavcu/epw8y/ ** change input value (true , false) trigger update function html <input data-bind="customdata: test , v1 : test2"/> ...

java - Python - communicate with subprocess -

i'm running python 2.7 on win32 os, i'm hoping write platform-independent code. i'm trying use python interact in real-time java program wrote, , figured pipes best way this. python script calling java subprocess. essentially, java gui , python end. (i don't want use jython or wxpython because want dependent upon standard libraries each language provides.) trying set communication between 2 has been terrible. can send message (parent) python script (child) java class using process.stdin.write(msg) process.stdin.flush() but reading java's output has not worked. use process.stdout.read() but apparently blocks forever if there's nothing read. , process.communicate() off limits because doesn't until subprocess terminates. according research, common method people use around problem "use threads" (although suggested appending newline when writing -- didn't work), being new python , threading in general have no idea how look. i've tried look...

jquery - Parse json from an external site with JavaScript -

i trying parse json on external site having trouble. must javascript or jquery, chrome extension. point: need number external url json {"_visitor_alertsunread":"0"} , set number returned variable. how go doing this? i have tried several things such json.parse isn't working:( in short: how number json, on external site, , set variable? you cannot data external url (in different domain) in javascript unless site supports jsonp or cross-origin resource sharing. if does, use xmlhttprequest data , json.parse() read it. script: var xhr = new xmlhttprequest(); xhr.open( 'get', 'example.com/json', true ); xhr.onload = function () { var unread = window.json.parse( xhr.responsetext )._visitor_alertsunread; }; xhr.onerror = function () { //process error }; xhr.send();

java - JavaFX wont import after JRE 7u5 install on OSX Lion -

Image
i installed jdk 7u5 javafx on osx machine running lion use mp3 playing code. but, when do: import javafx.scene.media.media; it says "the import javafx cannot resolved". have set jdk 7 preferred jdk in applications/utilities/java preferences added jdk eclipse, , have set jdk project. i have installed , uninstalled jdk few times. java - javafx wont import after jre 7u5 install on osx lion - stack overflow stack overflow questions developer jobs documentation beta tags users current community help chat stack overflow meta stack overflow communities sign up or log in customize list. more stack exchange communities company blog tour start here quick overview of site center detailed answers questions might have meta discuss workings , policies of site learn more stack overflow company business learn more hiring developers or posting ads log in sign up ...

How to do group capture in xpath -

i looking in xpath can do: //foo[@n="$1"]//bar[@n="$2"] can return me $1 , $2 . or @ least return me both <foo> , <bar> here more detail, have xml document: <xml> <foo> <a n="1"> <b n="1"/> <b n="2"/> </a> </foo> <a n="2"> <b n="1"/> </a> <a n="3"> <b n="1"/> <foo> <b n="2"/> </foo> <b n="3"/> </a> </xml> i want generate string base on n attribute in <a> , <b> have xpath: //a[@n]//b[@n] every result back, use: ./@n , ./ancestor::a/@n info want. this working fine, need more intelligent, because have lot structure this, , need auto generate xpath. so above example, looking xpath like: //a[@n="$1"]//b[@n="$2"] return me: `(1, 1), (1, 2), (2, 1), (3, 1), (3, 2), (3, 3) here 1 xpath 1.0 expression selects wanted n ...