(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.
var app = require('express')(); | |
var puzzle = require('./flipboard/maze'); | |
app.get('/maze/new', puzzle.init); | |
app.get('/maze/update/:id', puzzle.update); | |
app.listen(3000, 'localhost'); |
// http://james.padolsey.com/snippets/cross-domain-requests-with-jquery/ | |
// enableCORS(); | |
var enableCORS = function() { | |
jQuery.ajax = (function(_ajax){ | |
var api = 'http://query.yahooapis.com/v1/public/yql', | |
query = 'select * from html where url="{URL}"'; | |
return function(o) { | |
var q = query.replace('{URL}', o.url); | |
o.url = api; | |
o.dataType = 'json'; |
(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.
# Invoke Python with -m to use the server module | |
python -m SimpleHTTPServer 3000 |
USERNAMES=("aada" "aaro" "aino" "aleksi" "anni" "eeli" "eemil" "eetu" "eevi" "eino" "elias" "ella" "elsa" "emil" "enni" "helmi" "joona" "kerttu" "lauri" "leevi" "lenni" "lilja" "lotta" "luka" "lumi" "matias" "mikael" "mila" "nella" "niilo" "niklas" "olivia" "onni" "oona" "peetu" "pihla" "siiri" "veera" "veeti" "venla" "vilho" "vilma"); | |
RAND_BASE=8; | |
RAND_POWER=3; | |
GROUP_NAME="demo"; | |
DUMMY_FILE_SIZE=4096; | |
TMP_DUMMY_DIR="/tmp/dummy"; | |
time_in_ms() { | |
date +"%s" |
function setLoader(store) { | |
// Now `store` is imported into the closure scope | |
return function set(val) { | |
/** | |
* To update a value, reassign a property, not a variable | |
* For example, `store = { value: 'new value' };` would NOT | |
* work. It just reassigns the scope variable `store` to | |
* point to something else, rather than going to the memory | |
* spot of what `store` points to and alter the value there | |
*/ |
!function(){function t(t,e,r){function a(){b&&clearTimeout(b),v&&clearTimeout(v),x=0,s=v=g=b=w=void 0}function u(e,n){n&&clearTimeout(n),v=b=w=void 0,e&&(x=T(),m=t.apply(g,s),b||v||(s=g=void 0))}function c(){var t=e-(T()-d);0>=t||t>e?u(w,v):b=setTimeout(c,t)}function f(){return(b&&w||v&&$)&&(m=t.apply(g,s)),a(),m}function l(){u($,b)}function p(){s=arguments,d=T(),g=this,w=$&&(b||!h);var n=!1,i=!1;if(j===!1)n=h&&!b;else{v||h||(x=d);var o=j-(d-x);i=0>=o||o>j,i?(v&&(v=clearTimeout(v)),x=d,m=t.apply(g,s)):v||(v=setTimeout(l,o))}return i&&b?b=clearTimeout(b):b||e===j||(b=setTimeout(c,e)),n&&(i=!0,m=t.apply(g,s)),!i||b||v||(s=g=void 0),m}var s,v,m,d,g,b,w,x=0,h=!1,j=!1,$=!0;if("function"!=typeof t)throw new TypeError(o);return e=i(e)||0,n(r)&&(h=!!r.leading,j="maxWait"in r&&y(i(r.maxWait)||0,e),$="trailing"in r?!!r.trailing:$),p.cancel=a,p.flush=f,p}function e(t){var e=n(t)?m.call(t):"";return e==a||e==u}function n(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function i(t){if(n(t)){var i=e(t.valueOf)?t |
alias gg="git grep -n" | |
# -n: show line numbers | |
function ggl { | |
RESULTS=$(gg -l "$*" | tr "\n" " "); | |
# -l: file name (path included) only | |
# tr: replace $1 with $2 | |
if [ -z "${RESULTS// }" ]; then | |
# "${VAR// }" removes whitespace in $VAR | |
# -z: not empty |
var xhr = new XMLHttpRequest(); | |
xhr.responseType = 'arraybuffer'; | |
xhr.onload = function() { | |
if (this.status == 200) { | |
var buffer = new Uint8Array(this.response); | |
var i = buffer.length; | |
var binary = new Array(i); | |
while (i--) { | |
binary[i] = String.fromCharCode(buffer[i]); | |
} |
var delay = function(i) { | |
setTimeout(function() { | |
console.log(i); | |
}, i * 100); | |
}; | |
for (var i = 1; i <= 10; i++) { | |
delay(i); | |
} |