Skip to content

Instantly share code, notes, and snippets.

@pqwy
pqwy / time-it.ls
Created October 23, 2012 00:11
v8: closure vs. lambda-lifting
# This is LiveScript, really, but GH can't colour it -- yet.
time = (n, target) ->
t0 = (new Date).getTime!
for i from 1 to n then r = target!
t = (new Date).getTime! - t0
ta = t / n
console.log "[time] #t ms (avg #ta ms)"
r
@pqwy
pqwy / gist:3883367
Created October 13, 2012 05:36
can't re-add live objects back into a relation
class A
include Mongoid::Document
has_many :bs
end
class B
include Mongoid::Document
belongs_to :a
end
class A
include Mongoid::Document
embeds_one :b
end
class B
include Mongoid::Document
embedded_in :a
end
@pqwy
pqwy / index.coffee
Created May 21, 2012 15:18
editor in derby
view.fn 'unwrap', (ob) ->
{ key, value } for own key, value of ob)