(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.
| /***************************************** | |
| /* DOM touch support module | |
| /*****************************************/ | |
| if (!window.CustomEvent) { | |
| window.CustomEvent = function (event, params) { | |
| params = params || { bubbles: false, cancelable: false, detail: undefined }; | |
| var evt = document.createEvent('CustomEvent'); | |
| evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); | |
| return evt; | |
| }; |
| var animating = false; | |
| // Define an animator consisting of optional incoming and outgoing animations. | |
| // alwaysAnimate is false unless specified as true: false means an incoming animation will only trigger if an outgoing animation is also in progress. | |
| // forcing dontClone to true means the outward animation will use the original element rather than a clone. This could improve performance by recycling elements, but can lead to trouble: clones have the advantage of being stripped of all event listeners. | |
| function animator( incoming, outgoing, alwaysAnimate, dontClone ){ | |
| // The resulting animator can be applied to any number of components | |
| return function animate( x, y, z ){ | |
| var config; | |
| var parent; |
(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.
| /*jslint indent:2, node:true, sloppy:true*/ | |
| var | |
| gulp = require('gulp'), | |
| coffee = require('gulp-coffee'), | |
| rename = require("gulp-rename"), | |
| uglify = require('gulp-uglify'), | |
| sass = require('gulp-sass'), | |
| styl = require('gulp-styl'), | |
| concat = require('gulp-concat'), | |
| csso = require('gulp-csso'), |
| /* | |
| Timer | |
| - utilises animation frames (with a fallback to setTimeout when using the polyfill, below) | |
| - returns remaining (or running) time | |
| - pass a callback [fn], with an optional duration [ms] and autotart [bool], to the constructor or 'init' method | |
| eg. new Timer(foo, 1000) *or* (new Timer()).init(foo, 0, true) | |
| - for uniform x-browser support combine with the requestAnimationFrame polyfill from Erik Möller, et. al. | |
| [https://github.com/darius/requestAnimationFrame] | |
| */ |
| // Just before switching jobs: | |
| // Add one of these. | |
| // Preferably into the same commit where you do a large merge. | |
| // | |
| // This started as a tweet with a joke of "C++ pro-tip: #define private public", | |
| // and then it quickly escalated into more and more evil suggestions. | |
| // I've tried to capture interesting suggestions here. | |
| // | |
| // Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, | |
| // @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant, |
| /* | |
| AngularJS v1.1.4 | |
| (c) 2010-2012 Google, Inc. http://angularjs.org | |
| License: MIT | |
| */ | |
| (function(M,V,s){'use strict';function gc(){var b=M.angular;M.angular=hc;return b}function o(b,a,c){var d;if(b)if(I(b))for(d in b)d!="prototype"&&d!="length"&&d!="name"&&b.hasOwnProperty(d)&&a.call(c,b[d],d);else if(b.forEach&&b.forEach!==o)b.forEach(a,c);else if(!b||typeof b.length!=="number"?0:typeof b.hasOwnProperty!="function"&&typeof b.constructor!="function"||b instanceof P||ca&&b instanceof ca||Da.call(b)!=="[object Object]"||typeof b.callee==="function")for(d=0;d<b.length;d++)a.call(c,b[d], | |
| d);else for(d in b)b.hasOwnProperty(d)&&a.call(c,b[d],d);return b}function rb(b){var a=[],c;for(c in b)b.hasOwnProperty(c)&&a.push(c);return a.sort()}function ic(b,a,c){for(var d=rb(b),e=0;e<d.length;e++)a.call(c,b[d[e]],d[e]);return d}function sb(b){return function(a,c){b(c,a)}}function Ea(){for(var b=Z.length,a;b;){b--;a=Z[b].charCodeAt(0);if(a==57)return Z[b]="A",Z.join("");if(a==90)Z[b]="0";else return Z[b]=String.fromCharCod |
| // set-up a connection between the client and the server | |
| var socket = io.connect(); | |
| // let's assume that the client page, once rendered, knows what room it wants to join | |
| var room = "abc123"; | |
| socket.on('connect', function() { | |
| // Connected, let's sign-up for to receive messages for this room | |
| socket.emit('room', room); | |
| }); |
| // Only count bytes inserted as values, not counting keys... | |
| (function() { | |
| localStorage.clear(); | |
| var nbBytes = 5000, // about 0.5Mb | |
| oneByte = 'x', | |
| i = 0, | |
| totalBytesInserted = 0; | |
| function repeat(string, length) { |
| // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
| // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating | |
| // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel | |
| // MIT license | |
| (function() { | |
| var lastTime = 0; | |
| var vendors = ['ms', 'moz', 'webkit', 'o']; |