1 2 3 4
module Enumerable def stable_sort(&block) block &&= Proc.new do |(x, i), (y, j)| ...
Ruby On Stable sort in ruby
by Marc-Andre,
December 15, 2009 03:08
1 2 3
require 'backports' exceptions = exceptions.to_s.lines.to_a
Ruby On Running Ruby 1.9 or 1.8 code
by Marc-Andre,
September 01, 2009 18:43
Shameless plug for my backp...
1 2 3 4
FREQUENCY = { 'weekly' => 7, 'bi_monthly' => 14}.freeze def check_appt_conflicts appointments.any? do |appointment| ...
Ruby On Return from function within...
by Marc-Andre,
April 23, 2009 15:21
Can't agree more with Tj. R...
1 2 3 4
def prettify_output(rows) rows.map do |date, location, surface, price, tickets, winners| location, tourney = location.split("\n") ...
1 2 3 4
def passes_luhn_check?(str) sum = 0 numbers = str.split(//).map(&:to_i) ...
Ruby On Swedish Personnummer in Rai...
by Marc-Andre,
April 07, 2009 18:26
My Swedish is a bit rusty, ...
1 2 3 4
def date_range_by_week(selected_date) first_in_calendar = selected_date.beginning_of_month.next_week(:monday) - 7 (first_in_calendar...(first_in_calendar+7*6)).to_a.in_groups_of(7) ...
Ruby On Splitting array into define...
by Marc-Andre,
March 25, 2009 17:44
And if you don't need those...
1 2 3 4
def offset(selected_date) wday = selected_date.beginning_of_month.wday wday == 0 ? 6 : (wday - 1) ...
Ruby On Splitting array into define...
by Marc-Andre,
March 25, 2009 17:26
I'm presuming you're coding...
Ruby On Converting all umlaut chara...
by Marc-Andre,
March 17, 2009 19:52
@Tj: Bit-shifting? For all ...
1 2 3 4
class Asset < ActiveRecord::Base belongs_to :account belongs_to :asset_type ...
Ruby On Advanced search form & ...
by Marc-Andre,
March 17, 2009 15:45
I'd use a naming convention...
1 2 3 4
class String # returns an array of unicode codepoints, in canonical order def split_codepoints ...
Ruby On Converting all umlaut chara...
by Marc-Andre,
March 17, 2009 14:48
There are way more accents ...
1 2 3 4
def create_vouchercode begin self.vouchercode = generate_vouchercode(8) ...
Ruby On While loop to get unique value
by Marc-Andre,
January 13, 2009 01:49
...and if you favor using a...
1 2 3 4
# We deal with the problem by writing classes of numbers in tree form. # Leaves can be a specific number (Centile), a generic centile (GenericValue) or a subtree (another GenericNumber). # Each such GenericNumber can be expanded one level by replacing the leftmost GenericValue by specific values. ...

Calling #sort if no block i...