This file contains hidden or 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
fs = require 'fs' | |
path = require 'path' | |
isDirectory = (base, p) -> | |
fullPath = path.resolve base, p | |
fs.statSync(fullPath).isDirectory() | |
mergeExports = (theExports, otherModule) -> | |
for otherExport, func of otherModule | |
theExports[otherExport] = otherModule[otherExport] |
This file contains hidden or 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
class Tileset | |
{ | |
private Dictionary<String, Texture2D> tiles; | |
public Texture2D this[string key] | |
{ | |
get | |
{ | |
return tiles[key]; | |
} | |
} |
This file contains hidden or 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
class Job < Sequel::Model | |
plugin :serialization, :marshal, :args | |
end |
This file contains hidden or 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 Person(){} | |
Person.prototype.greet = function(){ alert("Hi!"); }; | |
var p = new Person(); | |
JSON.parse(JSON.stringify(p)).greet(); // throws Object #<an Object> has no method 'greet' in Chrome |
This file contains hidden or 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
mixin DumbEqualsOperand | |
equals: (other) -> | |
this == other | |
class MyClass implements DumbEqualsOperand | |
m = new MyClass | |
n = new MyClass | |
console.log(m.equals n) | |
This file contains hidden or 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
# Custom matchers | |
module CustomMatchers | |
class TimeTaken | |
def initialize(lower_seconds, upper_seconds=nil) | |
@lower_seconds = lower_seconds | |
@upper_seconds = upper_seconds | |
end | |
def matches?(given_proc) | |
range = @lower_seconds..@upper_seconds |
This file contains hidden or 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 "thread" | |
require "monitor" | |
require "timeout" | |
class Worker < Thread | |
def initialize(joblist, mon, input_cv, output_cv) | |
@busy = false | |
@mon = mon | |
super do | |
while true |
This file contains hidden or 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
<!-- | |
<script src="/external.js"></script> | |
<!-- --> | |
Even this doesn't quite work -- it works on Chrome, but Firefox prints out "<!--". |
This file contains hidden or 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
x_file = "x.txt" | |
task :prepare_x do | |
bunch_of_files = calculate_all_upstream_files_slowly | |
bunch_of_files.each {|filename| file x_file => filename} | |
end | |
task :real_x => [x_file] | |
task :x => [:prepare_x, :real_x] |
This file contains hidden or 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 tests = ...; | |
for(var i = 0; i < tests.length; i++){ | |
var generateTest = function(test){ | |
return function(){ | |
ok(test.valid); | |
// etc... | |
} | |
} | |
test("test: " + i, generateTest(tests[i])); | |
} |