Skip to content

Instantly share code, notes, and snippets.

View rwaldron's full-sized avatar

Rick Waldron rwaldron

  • Boston, MA
View GitHub Profile
@rwaldron
rwaldron / class.js
Created November 3, 2011 18:14 — forked from rauschma/class.js
Yet another simple class proposal
// Guidelines:
// - Class declarations and object literals should have the same features
// - Keep new features at a minimum (apart from what’s already in the object literal proposal)
// - Don’t obscure the fact that private names are actually name objects.
// => They can also be imported from somewhere else – a use case that needs to be supported.
// Rules:
// - Use # to denote const-ness
// Alternative: keyword `const`
// - Use @ to refer to name objects
@rwaldron
rwaldron / from.js
Created November 18, 2011 16:56 — forked from dherman/from.js
possible meanings of Array.from
Array.from = function from(x) {
var result = new Array();
for (var i = 0, n = x.length; i < n; i++) {
if (i in x)
result[i] = x[i];
}
return result;
};
// If Object.getPrototypeOf(Subarray) === Array, then:
/*
* Minimal classList shim
* Use with an Array.prototype.indexOf shim to support IE 8
* Derived from work by Devon Govett
* MIT LICENSE
*/
// NOT INTENDED FOR PRODUCTION USE.
@rwaldron
rwaldron / gist:1463473
Created December 11, 2011 23:27 — forked from padolsey/gist:1463408
`given(d).define(m)` - an alternative to `define(d,m)`
function given(dependencies) {
return {
define: function(module) {
return define(dependencies, module);
}
};
}
// usage:
@rwaldron
rwaldron / gist:1463586
Created December 11, 2011 23:50 — forked from brianarn/gist:1463450
`given(d).define(m)` - an alternative to `define(d,m)`
function define() {
console.log( arguments );
}
function given( dependencies ) {
return {
define: function( id, module ) {
if ( module != null ) {
// Assume the first arg is the module
module = id;
@rwaldron
rwaldron / tiny Promise.js
Created December 22, 2011 19:02 — forked from unscriptable/tiny Promise.js
A minimalist implementation of a javascript promise
// (c) copyright unscriptable.com / John Hann
// License MIT
// For more robust promises, see https://github.com/briancavalier/when.js.
function Promise () {
this._thens = [];
}
Promise.prototype = {
@rwaldron
rwaldron / awesome.html
Created January 13, 2012 03:01 — forked from max-mapper/awesome.html
node-serialport + arduino + popcorn.js DIY video scrubber
<html>
<head>
<script src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<script src="http://burritopizza.local/socket.io/socket.io.js"></script>
<script src="https://gist.github.com/raw/952547/f298c7e30d0978da0c78df0ff79436e883efbad2/gistfile1.txt"></script>
<script src="http://popcornjs.org/code/players/youtube/popcorn.youtube.js"></script>
<style type='text/css'>
body {
}
@rwaldron
rwaldron / _ie_warning.html
Created January 25, 2012 01:01 — forked from pamelafox/_ie_warning.html
IE ChromeFrame conditional prompt and alert
<!--[if lt IE 7]>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
<script>
// The conditional ensures that this code will only execute in IE,
// Therefore we can use the IE-specific attachEvent without worry
window.attachEvent("onload", function() {
CFInstall.check({
mode: "overlay"
});
var tester = {
testing: [],
console: window.console || {log: function(a) {window.status = a}, warn: alert},
defineBaseTests: function() {
this.baseTestBefore = [this.argumentsDefinedTest, this.thisBindingTest];
this.baseTestAfter = [this.returnTest];
},
testAll: function(root, options) {
@rwaldron
rwaldron / gist:1691179
Created January 27, 2012 22:05 — forked from dmethvin/gist:1676346
Breakpoint on access to a property
function debugAccess(obj, prop, debugGet){
var origValue = obj[prop];
Object.defineProperty(obj, prop, {
get: function () {
if ( debugGet )
debugger;
return origValue;
},