1 2 3 4
SIXTYTWO = ('0'..'9').to_a + ('a'..'z').to_a + ('A'..'Z').to_a def to_s_62(i) ...
Ruby Base 62 Encoding
Base WHAT??? Well, 62 is th...
1 2 3 4
class String unless ''.respond_to?(:to_proc) def to_proc(&block) ...
Ruby On String#to_proc (by Reginald...
by michiel,
October 28, 2007 18:35
Ok, I've removed the nested...
1 2 3 4
require 'rubygems' require 'active_support' ...
Ruby On Rubyize this : 4th edition
by michiel,
October 24, 2007 11:15
Building on Mark Van Holsty...
1 2 3 4
$c = [] def fork_reality(*l) callcc {|c| $c << c } ...
Ruby Combinatorial explosion wit...
by michiel,
October 14, 2007 10:57,
1 refactoring
This code tries to find all...
1 2 3 4
# Converts: # {:hash => [{:foo => 1}, {:foo => 2}]} # ...
Ruby On Recursively convert multidi...
by michiel,
October 05, 2007 09:31
In your inner loop, i == a[...
1 2 3 4
def self.find_left_sibling( parent_id, cat_name ) parent = Category.find( :first, :conditions => [ "id = ?", parent_id] ) ...
Ruby On Looking for alphabetized pl...
by michiel,
October 04, 2007 15:47
The previous refactoring is...
1 2 3 4
x < lower ? lower : x > upper ? upper : x # Or should I just go this way: ...
Ruby Enforcing bounds
by michiel,
October 04, 2007 04:55,
4 refactorings
Given a value and a range, ...
1 2 3 4
def show_value_or_default(object, default = "-") return default if object.nil? tmp = yield(object) ...
Ruby On Show a default value if obj...
by michiel,
October 03, 2007 18:52
The original solution is fi...
1 2 3 4
class Integer PR = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47] def is_prime? ...
1 2 3 4
class Array def pick at rand(size) ...
Ruby On Random pronouncable password
by michiel,
October 01, 2007 13:18
There is duplication in the...

