# 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

by we4tech, November 22, 2007 12:48, 6 refactorings, tagged with fragment cache mongrel

i was getting serious perfo...

4bb774de244da2d6e7f39a189b905077 Talk
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...

4bb774de244da2d6e7f39a189b905077 Talk
# Sample Output:
 #
 #  <tr>
...

Ruby Iterated printing in the he...

by XGamerX, November 18, 2007 03:52, 2 refactorings, tagged with rails, helper, radio button

Here is a function I have b...

55d6457963d5be7ad341343105ddc8a3 Talk
def replace_keywords(keyword_hash, text_to_parse)
  keyword_hash.each do |key, value|
    new_key = key.dup
...

Ruby Simple Text Replacement

by Bilson, November 16, 2007 02:19, 9 refactorings

A simple method that replac...

0b7b8a4ba91242f26238424ca491304a 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
<%= (@post.category ? @post.category.name : '') + ' ' + link_to(@post.title, post_path(@post)) %>

Ruby Handling nil object

by macournoyer, November 14, 2007 02:07, 13 refactorings, tagged with rails, html

@post.category can be nil, ...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk
#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...

B08d60ec1b3774a9deb5a353c37d12ce Talk
class PostsController < ResourceController::Base
...

Ruby resource_controller: Redesi...

by jamesgolick, November 05, 2007 20:27, 7 refactorings, tagged with rails, resource, restful

Backstory on my blog: http:...

F6eddf2f983d23c2d031e407852625e9 Talk
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...

Eeba234182bcbd7faed9ff52e233394d Talk
require 'rubygems'
require 'uri'
require 'net/http'
...

Ruby Technorati Ping

by Brianthecoder, November 04, 2007 08:47, 2 refactorings, tagged with xml, technorati

This code is made to be in ...

3f91cf60c92b20940674ebdeb46f6582 Talk
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...

by Barry Hess, November 02, 2007 15:15, 1 refactoring, tagged with date range, association proxy

So my User has an associati...

0218fde3a78fadbadb566bdb40d7b0dd Talk
module ModelHelpers

  def self.included(base)
...

Ruby textilize model helper

by rpheath, November 02, 2007 03:01, 3 refactorings, tagged with rails, ruby, textile, filter

OK, so I just realized ther...

E635ccff7389d9070f5e7e9fe8b36beb Talk
SIXTYTWO = ('0'..'9').to_a + ('a'..'z').to_a + ('A'..'Z').to_a

def to_s_62(i)
...

Ruby Base 62 Encoding

by michiel, November 01, 2007 01:42, 4 refactorings, tagged with speed

Base WHAT??? Well, 62 is th...

7c45f63f61e478233f0c2ad3006b178c Talk
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?

by Gary Haran, October 30, 2007 15:29, 9 refactorings, tagged with string, class, postal

We've had the debate over w...

403e57e2be130d2218f992b86dfa8260 Talk
# String#to_proc
#
# See http://weblog.raganwald.com/2007/10/stringtoproc.html ( Subscribe in a reader)
...

Ruby String#to_proc (by Reginald...

by webmat, October 28, 2007 06:27, 3 refactorings, tagged with functional

Reginald Braithwaite has a ...

A908bf6680c4fa7279dd85d5012f7ed8 Talk
namespace :migrations do
  
  desc 'reverts, renames and re-executes uncommitted migrations that conflict with already committed migrations'
...

Ruby Rails migration conflict re...

by danielharan, October 26, 2007 18:25, 1 refactoring, tagged with rails

Explained here: http://www....

880cbab435f00197613c9cc2065b4f5a Talk
# Note: Kuwait does not use DST.  
# See how the utc_offset value represents 
...

Ruby A DST-adjusted UTC offset

by Barry Hess, October 25, 2007 14:09, No refactoring

I need to get the Daylight-...

0218fde3a78fadbadb566bdb40d7b0dd Talk
<%= 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...

6b5a68d41436ce28831a0e0ca6bcd124 Talk
require "erb"

# build data class
...

Ruby Need explaination

by daveg, October 24, 2007 23:11, 5 refactorings

This is from the documentat...

584559348afbc5cc06c46c3b5746313a Talk
has_attachment :content_type => :image
...

Ruby attachment_fu integration

by Dominik, October 24, 2007 19:58, 1 refactoring

I have used the attachment_...

567298f59cff5f985ac7e502983dbf1e Talk
def new
  @course  = Course.new
...

Ruby Using partials for a golf s...

by rpheath, October 24, 2007 05:21, 2 refactorings

I'm building a golf applica...

E635ccff7389d9070f5e7e9fe8b36beb Talk
keys = {
  "a" => %w(q w s z),
  "b" => %w(v n g h),
...

Ruby Getting QWERTY misstypes

by slaskis, October 23, 2007 13:17, 3 refactorings

This is not really a refact...

Ad2ffc6b05fb4390643f36a258b86362 Talk
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 ...

364d0e86994a268906392f6b6146af38 Talk
def args_eval(line)
  tokens = []
  while(data = line.match(/\[.*\]/))
...

Ruby Argument eval

by Ben Burkert, October 22, 2007 19:56, 1 refactoring

this code evaluates a strin...

4d1c9dad17af98e55cb65b4efce27c42 Talk
class TreeNode
  def TreeNode.action(action)
    @@action = action
...

Ruby Changing contexts in a DSL ...

by claymccoy.myopenid.com, October 18, 2007 20:31, No refactoring

I use this code in a blog p...

Ad4d43ea62451b22882744a9f392b9d7 Talk