def create_files files = [] sizes = ['10K', '100K', '500K', '1M', '2M', '5M', '10M', '20M'] ...
Ruby Eliminate temporary collect...
A simple method to create a...
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
I wrote the following to ge...
for y in 0...height
for x in 0...width
# BGR => RGB & miror y
...
Ruby Symplify few loops
I need to reformat .bmp dat...
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
How can I turn this into so...
def sort
if params[:fact_id]
@fact = Fact.find_by_id(params[:fact_id]) || Fact.new
...
Ruby Ugly IF, ELSE
Trying to make this a lot c...
q = "query1=apa&query2=apa2"
Hash[q.split("&").collect{|a| a.split("=")}.flatten]
=> {"query1"=>"apa", "query2"=>"apa2"}
Ruby Parse a querystring
I'm looking if someone can ...
# call-seq: # StatisticsUtils.merge_sum(hash1, hash2, ...) -> merged_hash # ...
Ruby Total the values in multipl...
This is obviously not very ...
brew = "rdadadroxmocpronogomocdmqzx" alphabet = "abcdefghijklmnopqrstuvwxyz" word = "" ...
Ruby Newb needs some cleanup
Some code I've written for ...
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 ...
res = []
path_without_calculation.gsub(/\{(.*?)\}/) {|match|
res << match[1.. match.size-2]
...
Ruby Extract text between {} bra...
Can this be written shorten?
# Ruby Quiz 2 - Scalable LCD Monitor # Gerard (smeevil) de Brieder - Govannon - 2008-06-12 ...
Ruby Looking for comments on sty...
Hi all,
I am looking for...
#!/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...
I have a hash like this one...