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 Refinements = {}; | |
Refinements.modules = {}; | |
Refinements.register = function(name, fn) { | |
Refinements.modules[name] = fn; | |
}; | |
Refinements.using = function() { | |
var args = Array.prototype.slice.call(arguments); |
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
mocha.sinon = { | |
test: function(fn) { | |
var sandbox = sinon.sandbox.create(); | |
if (fn.length >= 2) { | |
return function(done) { | |
var origOnError = window.onerror; | |
window.onerror = function() { | |
sandbox.restore(); |
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
mocha.sinon = { | |
test: function(fn) { | |
var sandbox = sinon.sandbox.create(); | |
if (fn.length >= 1) { | |
return function(done) { | |
fn.call(sandbox, function(err) { | |
done(err); | |
sandbox.restore(); | |
}); |
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 coro(f) { | |
var g = f(function(x) { g.send(x) }); | |
g.next(); | |
} | |
function wait(ms, next) { | |
setTimeout(function() { | |
next('bar'); | |
}, ms); | |
} |
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 Foo = Class.extend({ | |
method: function() { | |
console.log('Hi!'); | |
} | |
}); | |
var Bar = Foo.extend({ | |
}); | |
var Baz = Bar.extend({ |
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://ejohn.org/blog/simple-javascript-inheritance/ | |
function Class() {} | |
Class.extend = function extend(props) { | |
var SuperClass = this; | |
function Class() { | |
if (typeof this.init === 'function') { | |
this.init.apply(this, arguments); |
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 Foo() { | |
if (!(this instanceof Foo)) { | |
throw new Error('called without new'); | |
} | |
// initialize | |
} | |
var foo = Foo(); |
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 Foo() { | |
'use strict'; | |
this.prototype; | |
// initialize | |
} | |
var foo = Foo(); |
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
require 'test/unit' | |
require 'date' | |
def year_diff(a, b) | |
month_diff = (a.year * 12 + a.month) - (b.year * 12 + b.month) | |
month_diff -= 1 if a.month == b.month && a.day < b.day | |
month_diff / 12 | |
end |
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 express = require('express'); | |
var http = require('http'); | |
var app = express(); | |
app.get('/', function(req, res) { | |
res.send( | |
'<body>' + | |
'<form action="/a" method="POST">' + | |
'<input type="text" name="foo">' + | |
'<input type="submit">' + |