Skip to content

Instantly share code, notes, and snippets.

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]
class Tileset
{
private Dictionary<String, Texture2D> tiles;
public Texture2D this[string key]
{
get
{
return tiles[key];
}
}
class Job < Sequel::Model
plugin :serialization, :marshal, :args
end
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
mixin DumbEqualsOperand
equals: (other) ->
this == other
class MyClass implements DumbEqualsOperand
m = new MyClass
n = new MyClass
console.log(m.equals n)
@nanodeath
nanodeath / spec_custom_matchers.rb
Created November 21, 2010 17:54
Main file containing your custom matchers
# 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
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
<!--
<script src="/external.js"></script>
<!-- -->
Even this doesn't quite work -- it works on Chrome, but Firefox prints out "<!--".
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]
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]));
}