This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onClick(selector, fn) { | |
document.addEventListener('click', function(e) { | |
if ( _matchesSelector(e.target, selector) ) fn(e); | |
}, false); | |
} | |
function _matchesSelector(el, selector) { | |
var doc = document.documentElement; | |
var fn = doc.matchesSelector || doc.webkitMatchesSelector; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// particles.c - Simple particles example using the OpenVG Testbed | |
// Installing & Running: | |
// 1. Download the OpenVG Testbed (https://github.com/ajstarks/openvg) | |
// | |
// $ git clone https://github.com/ajstarks/openvg.git | |
// $ cd openvg/client | |
// | |
// 2. Place a copy of this file (particles.c) in that directory | |
// 3. Add the following to the Makefile: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Original Source | |
// http://thecodeplayer.com/walkthrough/make-a-particle-system-in-html5-canvas | |
// | |
// Modified to work with `node-openvg-canvas` on the Raspberry Pi | |
// - use RequestAnimationFrame instead of setInterval | |
// - correct the number of arguments in call to `ctx.arc()` | |
// | |
// Usage: | |
// - install Node.JS | |
// (refer to Installing Node section here: http://blog.rueedlinger.ch/2013/03/raspberry-pi-and-nodejs-basic-setup/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://requirebin.com/?gist=8f13d5147c1c252ab1691115bfa8b7c5 | |
var Promise = require('es6-promise').Promise; | |
new Promise(function() { | |
console.log("We're running..."); | |
// nothing happens, this error is silently swallowed. and yes this could just as | |
// well be a typo. issue: https://github.com/stefanpenner/es6-promise/issues/70 | |
throw 'err'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = require('bluebird'); | |
new Promise(function() { | |
console.log("We're running..."); | |
// A crazy error is thrown here, but you will see this in your Chrome console. | |
// Seems like Bluebird has the right default here! | |
throw 'Nice job Bluebird'; | |
console.log("We'll never get here."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = require('es6-promise').Promise; | |
function foo() { | |
return new Promise(function(resolve, reject) { | |
console.log("We're running..."); | |
// We totally resolve and all is good ... | |
resolve(); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = require('yaku'); | |
function MyCoolErr() {} | |
function foo() { | |
return new Promise(function(resolve, reject) { | |
console.log("We're running..."); | |
// Resolve and all is good ... | |
resolve(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = require('es6-promise').Promise; | |
function MyCoolErr() {} | |
function foo() { | |
return new Promise(function(resolve, reject) { | |
console.log("We're running..."); | |
// Resolve and all is good ... | |
resolve(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = require('rsvp').Promise; | |
function MyCoolErr() {} | |
function foo() { | |
return new Promise(function(resolve, reject) { | |
console.log("We're running..."); | |
// Resolve and all is good ... | |
resolve(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = require('rsvp').Promise; | |
new Promise(function() { | |
console.log("We're running..."); | |
// nothing happens, this error is silently swallowed. and yes this could just as | |
// well be a typo. issue: https://github.com/stefanpenner/es6-promise/issues/70 | |
throw 'err'; | |
console.log("We'll never get here."); |
OlderNewer