Skip to content

Instantly share code, notes, and snippets.

@rezonant
rezonant / clean_binding_sample.rb
Created November 3, 2010 23:41
Making a clean, modular, disposable binding for a shell
module SomeCommands; def add(x, y) x + y end; end; import SomeCommands;
add 1, 1 # => 2
String.add 1, 1 # => 2 # ... with some solutions
"hello".add 1, 1 # => # ... with others
"hello".add 1, 1 # NoMethodError # is what I want
"hello".instance_eval "add(1, 1)" # NoMethodError # as well
@rezonant
rezonant / test.js
Created September 30, 2020 05:00
Microbenchmark of Resig's compress() function versus more modern equivalents
// Microbenchmark of Resig's compress() function versus more modern equivalents
// Because I had nothing better to do apparently
//
// https://news.ycombinator.com/item?id=24615882
//
// Results on my system (Core i7 7700, Node.js v10.15.3, Windows 10 2004)
// Remember: Microbenchmarks are not indicative of actual performance in the
// wild
//
// Comparing 7 implementations, 1000000 repetitions each