(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| // ---------------------------------------------------------- | |
| // A short snippet for detecting versions of IE in JavaScript | |
| // without resorting to user-agent sniffing | |
| // ---------------------------------------------------------- | |
| // If you're not in IE (or IE version is less than 6) then: | |
| // ie === 0 | |
| // If you're in IE (>=6) then you can determine which version: | |
| // ie === 7; // IE7 | |
| // Thus, to detect IE: | |
| // if (ie) {} |
| echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
| . ~/.bashrc | |
| mkdir ~/local | |
| mkdir ~/node-latest-install | |
| cd ~/node-latest-install | |
| curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
| ./configure --prefix=~/local | |
| make install # ok, fine, this step probably takes more than 30 seconds... | |
| curl https://www.npmjs.org/install.sh | sh |
| /* | |
| WorkCrew - a WebWorker work queue library | |
| Usage: | |
| // Create an 8 worker pool using worker.js. | |
| var crew = new WorkCrew('worker.js', 8); | |
| // Do something whenever a job is completed. | |
| // The result object structure is |
| #!/usr/bin/env sh | |
| ## | |
| # This is script with usefull tips taken from: | |
| # https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
| # | |
| # install it: | |
| # curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
| # |
| - Trailing commas are ok | |
| - No reserved words for property names | |
| - NaN, Infinity, undefined : are all constants | |
| - parseInt() defaults to radix 10 | |
| - /regexp/ produces new reg ex object every time | |
| - JSON.parse(), JSON.stringify() | |
| - Function.prototype.bind | |
| - String.prototype.trim | |
| - Array.prototype.every, filter, forEach, indexOf, lastIndexOf, map, reduce, reduceRight, some, | |
| - Date.now() |
| var Point = function(x, y) { | |
| if (arguments.length == 1) | |
| { | |
| this.x = (x >> 12) & 0xFFF; | |
| this.y = (x) & 0xFFF; | |
| } | |
| else | |
| { | |
| this.x = x; | |
| this.y = y; |
| fractalModule =function(stdlib){ | |
| "use asm"; | |
| var pow = stdlib.Math.pow; | |
| var abs = stdlib.Math.abs; | |
| var atan2 = stdlib.Math.atan2; | |
| var cos = stdlib.Math.cos; | |
| var sin = stdlib.Math.sin; | |
| function mandlebrot(cx, cy, maxIter) { | |
| cx = +cx; | |
| cy = +cy; |
| node-debug () { | |
| PROGRAM="$(which $1)" # make sure we get an absolute path for programs in PATH | |
| shift # remove the original program argument | |
| set -- "$PROGRAM" "$@" # prepend the program path | |
| node --debug-brk $@ & # start node in paused debug mode, send to background | |
| node-inspector # start node inspector | |
| kill %% # kill the background task (if still running) | |
| } |
| /** | |
| * Sum of all elements including nested arrays. | |
| * | |
| * by Dmitry Soshnikov <[email protected]> | |
| * MIT Style License | |
| */ | |
| [1, 2, [3, 4], 5, [6, [7, 8]]].reduce(function collect(previous, current) { | |
| return ( | |
| (Array.isArray(previous) ? previous.reduce(collect) : previous) + |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.