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...
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...
require 'rubygems' require 'active_support' ...
Ruby On Rubyize this : 4th edition
by michiel,
October 24, 2007 11:15
Building on Mark Van Holsty...
$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...
# Converts:
# {:hash => [{:foo => 1}, {:foo => 2}]}
#
...
Ruby On Recursively convert multidi...
by michiel,
October 05, 2007 09:31
In your inner loop, i == a[...
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...
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, ...
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...
class Array
def pick
at rand(size)
...
Ruby On Random pronouncable password
by michiel,
October 01, 2007 13:18
There is duplication in the...
