1.upto 100 do |n|
  puts [[:fizz][n%3], [:buzz][n%5]].join[/.+/m] || n
end

Ruby On Fizz Buzz

by mxcl, February 13, 2011 12:57

A slightly more readable ve...

25ff3dfe48d3847ecf9971aab99589fb Talk
a = [5, 123, 2131231, 67, 4]

a.each_index do |index|
...

Ruby On Is this code rubyish?

by mxcl, April 01, 2010 11:43

Ruby has such a wonderfully...

25ff3dfe48d3847ecf9971aab99589fb Talk
@var = if current_user
  current_user.search_terms.build
else
...

Ruby On if else more elegant

by mxcl, March 25, 2010 17:21 Star_full

I'm no fan of ternary opera...

25ff3dfe48d3847ecf9971aab99589fb Talk
class String
  def dedent
    lines = split "\n"
...

Ruby On ruby dedent whitespace in a...

by mxcl, March 05, 2010 17:47 Star_fullStar_fullStar_full

Could you be more clear abo...

25ff3dfe48d3847ecf9971aab99589fb Talk
def hash_from_string string, value
  string.split('.').reverse.inject(value) { |rv, e| rv = { e => rv } }
end

Ruby On Nested Hash from delimiter-...

by mxcl, March 05, 2010 10:55 Star_fullStar_fullStar_fullStar_fullStar_full

Here's your one liner:

(ed...

25ff3dfe48d3847ecf9971aab99589fb Talk
class String
  def squish
    x = 0
...

Ruby Function to remove consiste...

by mxcl, February 27, 2010 15:01, 3 refactorings

The code doesn't feel elega...

25ff3dfe48d3847ecf9971aab99589fb Talk
attributes.collect{ |(key, value)| "#{$1}.#{value}" if key =~ /^svc_(\w\w)_id$/ }.compact

Ruby On Ruby Hash Extraction Using ...

by mxcl, February 25, 2010 13:42

This is probably the most s...

25ff3dfe48d3847ecf9971aab99589fb Talk

Ruby On Create a baseXX string base...

by mxcl, February 22, 2010 11:17

I experimented with this to...

25ff3dfe48d3847ecf9971aab99589fb Talk