def remove_insults(sentence)
sentence.gsub(/#{%w( stupid moron dumbass retard ).join('|')}/i) { |insult| '*' * insult.size }
end
...
Ruby On Rubyize this : 3rd edition
by hungryblank,
October 12, 2007 13:39
500.times { puts((1..16).map { rand(10) }.to_s) }
Ruby On Random number generator
by hungryblank,
October 03, 2007 03:34
and in case you really want...
500.times { puts((1..16).inject('') { |a,n| a << '1234567890'[rand(10),1] }) }
# or
...
Ruby On Random number generator
by hungryblank,
October 03, 2007 03:25
stressing a bit the [] meth...
# samples # show_value_or_default(user, :phone) # show_value_or_default(user2, :phone, "leeg") ...
Ruby On Show a default value if obj...
by hungryblank,
October 03, 2007 02:50
As a first step you can avo...
array_of_arrays_of_hashes = array_of_hashes.map { |e| e[:callid] }.uniq.inject([]) do |grouped_array, callid|
grouped_array << array_of_hashes.select { |h| h[:callid] == callid }
end
Ruby On Grouping an array of hashes
by hungryblank,
October 01, 2007 15:40
I thought for you it was im...
CssObj = Struct.new(:selector, :attributes) class CssObj def self.extract_file(filename) ...
Ruby On Extracting style from a CSS...
by hungryblank,
September 28, 2007 04:39
I just played some mins aro...

This solution uses a differ...