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
# 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
#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
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
<% 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 ...

by JohnnyBusca, November 28, 2007 07:53, 5 refactorings, tagged with in_groups_of

I would like to have a piec...

0fe01b8879c35beee8c9b2e9212a5b87 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
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
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
#!/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
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
# 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 zipcode=(new_zipcode)
    if new_zipcode != self.zipcode
      write_attribute(zipcode, new_zipcode) #problem here
...

Ruby overwriting an activerecord...

by Alain, November 28, 2007 03:13, 1 refactoring, tagged with rails

I simply want to overwrite ...

Ca35abdcc0ebbaada3c935c2746ed5ea 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
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...

5ee610e858812d3ce19941a85c5b99ef 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 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...

364d0e86994a268906392f6b6146af38 Talk
#!/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 ...

55502f40dc8b7c769880b10874abc9d0 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
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...

6b5a68d41436ce28831a0e0ca6bcd124 Talk
if self.location_type.to_s == 'point'
  breaker = self.lang == 'fr' ? 'proximite' : 'near'
 else  
...

Ruby Iffy

by Gary Haran, October 11, 2007 19:15, 6 refactorings

With all the magic surround...

403e57e2be130d2218f992b86dfa8260 Talk
# 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...

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

6b5a68d41436ce28831a0e0ca6bcd124 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
# 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 ...

0fe01b8879c35beee8c9b2e9212a5b87 Talk