def include_class?(obj_class)
      stack = []
    
...

Ruby hash.include_class?, recursive

by unixcharles, August 09, 2010 00:20, 1 refactoring, tagged with short, ruby

I have a hash like this one...

23e6178f295b9cb7473d44d9e501a2b3 Talk
def create_files
  files = []
  sizes = ['10K', '100K', '500K', '1M', '2M', '5M', '10M', '20M']
...

Ruby Eliminate temporary collect...

by Josh, June 23, 2010 22:52, 3 refactorings, tagged with short

A simple method to create a...

D41d8cd98f00b204e9800998ecf8427e Talk
tl = Time.now.localtime
(0..356).each {|i| d =  (Date.new(tl.year, tl.month, tl.day) +i );
 printf("\n%03s\n\n", Date::ABBR_MONTHNAMES[d.month]) if d.day == 1;
...

Ruby Generate Days of a Year

by gregelin.myopenid.com, February 27, 2010 15:51, 2 refactorings, tagged with short

I wrote the following to ge...

57f954ba5409a6504af785ed8d42e009 Talk
for y in 0...height
  for x in 0...width
    # BGR => RGB & miror y
...

Ruby Symplify few loops

by darkleo.myopenid.com, January 30, 2010 20:36, 7 refactorings, tagged with short, ruby

I need to reformat .bmp dat...

61f1b34f172ee1fbc1af42ab3ce0eca9 Talk
Clip.find_by_sql(["select * from clips where not exists
        (select 'clip_id' from histories where histories.clip_id = clips.id
        and histories.user_id = ?) ORDER BY clips.created_at DESC LIMIT 20", user.id])

Ruby ActiveRecord find_by_sql

by David, January 17, 2010 20:52, 5 refactorings, tagged with rails, sql, short, ruby, activerecord

How can I turn this into so...

D41d8cd98f00b204e9800998ecf8427e Talk
101.times do |n|

  next if n == 0
...

Ruby Fizz Buzz

by jhindle, January 15, 2010 13:08, 11 refactorings, tagged with short, fizzbuzz

Wrote a Fizz Buzz http://en...

6bff7d5313e73334ef0edc691a7564f7 Talk
def sort
    if params[:fact_id]
      @fact = Fact.find_by_id(params[:fact_id]) || Fact.new
...

Ruby Ugly IF, ELSE

by serek.openid.pl, December 18, 2009 10:17, 3 refactorings, tagged with rails, short, dry

Trying to make this a lot c...

597821ce12359ab2d95437c8164d5254 Talk
q = "query1=apa&query2=apa2"
Hash[q.split("&").collect{|a| a.split("=")}.flatten]
=> {"query1"=>"apa", "query2"=>"apa2"}

Ruby Parse a querystring

by Simon, October 05, 2009 19:47, 2 refactorings, tagged with short, ruby, fun

I'm looking if someone can ...

865351a8b8bb963c7ee935b3f342854e Talk
# call-seq:
  #   StatisticsUtils.merge_sum(hash1, hash2, ...) -> merged_hash
  #
...

Ruby Total the values in multipl...

by Trejkaz, July 08, 2009 00:54, 2 refactorings, tagged with short, hash, sum, merge

This is obviously not very ...

42b570f6f4312a872c2fc671e3ddc82b Talk
<%= f.select :something, 1.upto(10) do |i| i end %>

Ruby Select tags

by sfusion.myopenid.com, April 02, 2009 11:01, 9 refactorings, tagged with rails, short, select

I find myself doing this a ...

4f5d54213efb6502baab202f3fb2f09e Talk
brew = "rdadadroxmocpronogomocdmqzx"
alphabet = "abcdefghijklmnopqrstuvwxyz"
word = ""
...

Ruby Newb needs some cleanup

by redpidgin, December 23, 2008 16:16, 7 refactorings, tagged with short, ruby, decode

Some code I've written for ...

5ce36f73f075f18632c284f56cedd23d Talk
def factorial( n )
  if !(n.is_a? Integer)
    raise ArgumentError, "argument must be a positive integer"
...

Ruby A simple factorial program.

by lordzoner.myopenid.com, November 12, 2008 02:16, 9 refactorings, tagged with short, ruby, factorial

I'm quite new to Ruby, and ...

D41d8cd98f00b204e9800998ecf8427e Talk
res = []
      path_without_calculation.gsub(/\{(.*?)\}/) {|match|
        res << match[1.. match.size-2]
...

Ruby Extract text between {} bra...

by stephan, October 22, 2008 11:54, 4 refactorings, tagged with short, regexp, gsub

Can this be written shorten?

349779c687ad1de3e116f3a5feaf3f92 Talk
# Ruby Quiz 2 - Scalable LCD Monitor 
# Gerard (smeevil) de Brieder - Govannon - 2008-06-12

...

Ruby Looking for comments on sty...

by smeevil, June 16, 2008 14:37, 3 refactorings, tagged with short, codereview, critics

Hi all,

I am looking for...

912b664b56818fd36821d006577ff3aa Talk
#!/usr/bin/env ruby

files = ARGV.collect { |fname| File.new(fname, 'w') }
...

Ruby Randomly split input lines.

by Scott Robinson, November 15, 2007 08:56, 2 refactorings, tagged with functional, short, oneliner, one-liner

My first Ruby script. I'm c...

1945ab4cdb87eaf5a5c906fa884c29f1 Talk