# i use this method instead of "render" render_from_cache_or_render(:cache_key =>â€cache keyâ€, :cache_expire_after => ConstantHelper::TAG_CLOUD_EXPIRED_IN, # minute ...
Ruby fragment cache
i was getting serious perfo...
#Input string msg = "I wonder if this code can be better." ...
Ruby Circular Cipher
by amoeba.myopenid.com,
November 05, 2007 22:21,
6 refactorings, tagged with cipher, encryption, ascii
Simple cipher program. Modi...
def test_destroy_category_with_dependent
category = Category.find(3)
...
Ruby managable test method
by we4tech,
November 21, 2007 09:13,
5 refactorings, tagged with test, ruby, test case, method, unit test
in my test case method, i w...
<% col_size = (friends.size/4.0).ceil %> <% friends.in_groups_of(col_size, false) do |group| %> <div class=‘list‘> ...
Ruby split_in_groups instead of ...
I would like to have a piec...
SIXTYTWO = ('0'..'9').to_a + ('a'..'z').to_a + ('A'..'Z').to_a
def to_s_62(i)
...
Ruby Base 62 Encoding
Base WHAT??? Well, 62 is th...
module ModelHelpers def self.included(base) ...
Ruby textilize model helper
OK, so I just realized ther...
require 'rubygems' require 'uri' require 'net/http' ...
Ruby Technorati Ping
This code is made to be in ...
#!/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...
regexp = Regexp.new(ARGV[0]) match_index = (ARGV[1] || 1).to_i ...
Ruby Print out the Regex Capture
by DougBTX,
November 05, 2007 02:08,
2 refactorings
My aim: Print out the regex...
def zipcode=(new_zipcode)
if new_zipcode != self.zipcode
write_attribute(zipcode, new_zipcode) #problem here
...
Ruby overwriting an activerecord...
I simply want to overwrite ...
has_many :expenses, :dependent => :destroy do
def for_week(day)
find(:all, :conditions => { :spent_at => day.to_time.beginning_of_week.to_date..(day.to_time.beginning_of_week.to_date + 6)})
...
Ruby Finding all in a date range...
So my User has an associati...
chars="1234567890" #only numbers random_code="" ...
Ruby Random number generator
by khillabolt.myopenid.com/,
October 02, 2007 18:38,
18 refactorings
I am a total newbie when it...
class Bug attr_accessor :type attr_accessor :name ...
Ruby Rubyize this : 4th edition
by FrankLamontagne,
October 23, 2007 12:26,
16 refactorings
Welcome to the 4th edition ...
def remove_insults(input) ctr = 0 input.each do |word| ...
Ruby Rubyize this : 3rd edition
by FrankLamontagne,
October 11, 2007 15:21,
10 refactorings
This snippet is coming from...
#!/usr/bin/ruby require 'benchmark' include Math ...
Ruby is_prime?
by trappist3.myopenid.com/,
October 01, 2007 14:50,
10 refactorings
This is as fast as I could ...
class String
def postal?
self.match(/[a-zA-Z]{1}\d{1}[a-zA-Z]{1}([\x20-])*\d{1}[a-zA-Z]{1}\d{1}/) ? true : false
...
Ruby Is This String Postal?
We've had the debate over w...
def add_phone_link(name) ...
Ruby Combining add/remove links
by Etandrib,
October 16, 2007 21:41,
7 refactorings
I've got a bunch of add and...
# Merges two sets of condition options for ActiveRecord::Base find calls def merge_conditions(base_conditions, new_conditions, boolean_operator="AND") return base_conditions if new_conditions.blank? ...
Ruby Merging two sets of conditions
by Barry Hess,
October 15, 2007 21:10,
6 refactorings
I found myself in a situati...
def phone_attributes=(phone_attributes)
phone_attributes.each do |attributes|
...
Ruby Combine contact attributes ...
by Etandrib,
October 16, 2007 20:34,
5 refactorings
We have a model where a per...
<%= f.text_field :first_name, :size => 15 %> ...
Ruby Three groups, three bits of...
by Etandrib,
October 25, 2007 13:42,
5 refactorings
I have three classes of peo...
require "erb" # build data class ...
Ruby Need explaination
by daveg,
October 24, 2007 23:11,
5 refactorings
This is from the documentat...
# this method returns a default when the object does not exist or the value given in the block does not exist. # # Example: ...
Ruby Show a default value if obj...
by JohnnyBusca,
October 03, 2007 00:48,
5 refactorings
Often in the view you want ...
Backstory on my blog: http:...