Posts

javascript - Sticky Element catching on down scroll and catching on up scroll -

i have sticky side bar , right using js have catching , staying fixed t point. when scroll need catch , not go further starting point. code far. $(window).scroll(function(e){ $el = $('.why_social'); if ($(this).scrolltop() > 735 && $el.css('position') != 'fixed'){ $('.why_social').css({'position': 'fixed', 'top': '-62px'}); } }); you should have add opposite check. should started. $(window).scroll(function(e){ $el = $('.why_social'); if ($(this).scrolltop() > 735 && $el.css('position') !== 'fixed') { $('.why_social').css({'position': 'fixed', 'top': '-62px'}); } if ($(this).scrolltop() <= 735 && $el.css('position') === 'fixed') { { $('.why_social').css({'position': ''}); // remove `position: fixed;` } }); btw: if you...

python - Calculate number of jumps in Dijkstra's algorithm? -

what fastest way in numpy calculate number of jumps dijkstra's algorithm uses? have 10000x10000 element connectivity matrix , use scipy.sparse.csgraph.dijkstra calculate filled distance matrix , predecessor matrix. naive solution follows: import numpy np numpy.random import rand scipy.sparse.csgraph import dijkstra def dijkway(dijkpredmat, i, j): """calculate path between 2 nodes in dijkstra matrix""" wayarr = [] while (i != j) & (j >= 0): wayarr.append(j) j = dijkpredmat[i,j] return np.array(wayarr) def jumpvec(pmat,node): """calculate number of jumps 1 node others""" jumps = np.zeros(len(pmat)) jumps[node] = -999 while 1: try: rvec = np.nonzero(jumps==0)[0] r = rvec.min() dway = dijkway(pmat, node, r) jumps[dway] = np.arange(len(dway),0,-1) except valueerror: break return jumps #...

Javascript value set null if value equals nothing -

right working on timesheet users can set in time, out time, , how long they've been @ lunch. use function subtracts in time & lunch out time figure out hours, plus possible overtime. want have javascript set value of overtime field '' (aka null) if amount of time @ work 8 hours or less. my code checking overtime this: // return difference between 2 times in hh:mm[am/pm] format hh:mm function checkovertime(timein, timeout, away) { // small helper function pad single digits function z(n){return (n<10?'0':'') + n;} // difference in minutes var subtotal = daytimestringtomins(timeout) - daytimestringtomins(timein) - timestringtomins(away); var regularhours = '08:00'; if (subtotal > timestringtomins(regularhours)) {var overtime = daytimestringtomins(timeout) - daytimestringtomins(timein) - timestringtomins(away) - timestringtomins(regularhours);} else {var overtime = '0';} return z(overtime/60 | 0) + ':...

python - Pythonic way of checking bit values -

i have set of constants declarations self.poutput = 1 self.ppwm = 2 self.pinput = 4 self.punused = 8 self.psonar = 16 self.pultra = 32 self.pservod = 64 self.pstepper = 128 self.pcount = 256 self.pinputdown = 512 self.pinputnone = 1024 what pythonic way of checking whether value matches of input states (4,512 , 1024) please? info: i'd use bit pattern checking in simpler languages wondered if there better way in python :) each pin can have 1 of i/o states above if pin of of input values 1 action occurs e.g if pin == 4 or 512 or 1024 -> something testing set membership (which seem doing) best done using set . self.input_states = {self.pinput, self.pinputdown, self.pinputnone} # later if value in self.input_states: do_something() of course handle in variety of essentially-identical ways, 1 way or have encode knowledge of these magic numbers "input states". now if, has been suggested, want bit-maski...

how to default a value for non existing node in xslt -

i have following xml element in source , map element in target. whenever there no node in source, want default string "none" --------------------------source xml---------------------------------------------- <?xml version="1.0" encoding="utf-8"?> <instructions instructiontype="gen">some message</instructions> <instructions instructiontype="test">some other message</instructions> ---------------------------transformation xsl-------------------------------------- <xsl:if test='/ns1:orderresponse/ns1:orderresponsebody/ns1:orderresponseproperties/ns1:instructions/@instructiontype = "gen"'> <xsl:choose> <xsl:when test='/ns1:orderresponse/ns1:orderresponsebody/ns1:orderresponseproperties/ns1:instructions[@instructiontype = "gen"] != ""'> <ns0:sigen> <xsl:value-of select='substring(/...

graph - Segmentation Fault C++ -

the input in following format 5 1 2 9.0 1 3 12.0 2 4 18.0 2 3 6.0 2 5 20.0 3 5 15.0 0 1 5 the first number number of vertexes in graph. next lines 0 edges of graph. first , second numbers being vertexes , third being how far edge between them. trying read in data , store edges there locations in list adjacency vertex. example make graph 5 vertexes edges 1 2&3. 2 4&3&1 etc. i getting segmentation fault after entering 4 numbers. fault happening on line mygraph.vertexinfo[p1].adjacency -> vertex=p2; starts trying store information. why getting fault? #include <cstdio> using namespace std; struct listcell { listcell* next; int vertex; double weight; listcell(int v, double w, listcell* nxt) { vertex = v; weight = w; next = nxt; } }; typedef listcell* list; struct vertex { bool signaled; long distance; list adjacency; }; struct graph { int numvertices; vertex* vertexinfo; graph(int n) { ...

PHP is not working on Apache 2 on Windows -

i have installed apache 2.4.9 windows 7 64 , php 5.5.10 (also 64 bit), used articles step step detailed manual installation. cannot open php files in browser reason. have checked other threads similar problems on different websites , made sure httpd.conf has necessary lines included or uncommented. apache starts , stops after enter httpd -k start/stop. when enter httpd -t says 'syntax ok'. when enter localhost/phpinfo.php in address bar in browser 'not found on server'. when try in command line 'php phpinfo.php' 'could not open input file'. i don't know else check, answers found in forum threads give same hints , include same elements of configuration file must included in httpd.conf, including root directory, engine = on, display errors = on, load module, addtype , used . i appreciate or suggestions. if not - go through installation once again. troubleshooting: check files stored in right directory (generally htdocs apache) look...