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

Calling #sort if no block i...

7f00244a6387413b37ee449f234ec045 Talk
1
2
3
# in ruby 1.8.7 or require 'backports'

title.rpartition(' > ').last

Ruby On rindex

by Marc-Andre, September 04, 2009 20:16

I like Pierre's version. If...

7f00244a6387413b37ee449f234ec045 Talk
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...

7f00244a6387413b37ee449f234ec045 Talk
1
2
3
4
module Enumerable
  def frequency
    returning Hash.new(0) do |hash|
...

Ruby On Count words in a string

by Marc-Andre, May 05, 2009 02:06

Daniel: The added advantage...

7f00244a6387413b37ee449f234ec045 Talk
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...

7f00244a6387413b37ee449f234ec045 Talk
1
2
3
4
def prettify_output(rows)
  rows.map do |date, location, surface, price, tickets, winners|
    location, tourney = location.split("\n")
...

Ruby On ATP Tournament iCalendar

by Marc-Andre, April 20, 2009 17:49

Here's a prettified prettif...

7f00244a6387413b37ee449f234ec045 Talk
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, ...

7f00244a6387413b37ee449f234ec045 Talk
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...

7f00244a6387413b37ee449f234ec045 Talk
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...

7f00244a6387413b37ee449f234ec045 Talk

Ruby On Converting all umlaut chara...

by Marc-Andre, March 17, 2009 19:52

@Tj: Bit-shifting? For all ...

7f00244a6387413b37ee449f234ec045 Talk
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...

7f00244a6387413b37ee449f234ec045 Talk
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 ...

7f00244a6387413b37ee449f234ec045 Talk
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...

7f00244a6387413b37ee449f234ec045 Talk
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.
...

Ruby On Integer puzzle

by Marc-Andre, October 18, 2007 18:04 Star_fullStar_fullStar_fullStar_full

Well, I'd say I am such a c...

7f00244a6387413b37ee449f234ec045 Talk

Ruby On Integer puzzle

by Marc-Andre, October 18, 2007 00:14

Hi Daniel!
Congrats on solv...

7f00244a6387413b37ee449f234ec045 Talk