require 'spec_statistics'
...

Ruby rake stats for RSpec

by Ben Burkert, October 17, 2007 19:47, 2 refactorings

I want to get some statisti...

4d1c9dad17af98e55cb65b4efce27c42 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
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
# 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
$c = []
def fork_reality(*l)
  callcc {|c| $c << c }
...

Ruby Combinatorial explosion wit...

by michiel, October 14, 2007 10:57, 1 refactoring

This code tries to find all...

7c45f63f61e478233f0c2ad3006b178c Talk
require 'erb'
class ClientMigrator
  def self.create(fields)
...

Ruby Dynamic migrations for rails

by danielharan, October 12, 2007 04:27, 1 refactoring

How do you create a rails p...

880cbab435f00197613c9cc2065b4f5a 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
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
def preview
...

Ruby Ajax form Preview

by Cedric, October 05, 2007 16:24, No refactoring

This is my first bit of Aja...

D329280c04406af1e2e010a8c0ccd092 Talk
# Converts:
# {:hash => [{:foo => 1}, {:foo => 2}]}
# 
...

Ruby Recursively convert multidi...

by Jarrod, October 05, 2007 08:02, 3 refactorings

there has got to be a bette...

376dc89f458bb3b9ac3fd4d559098645 Talk
def self.find_left_sibling( parent_id, cat_name )
    parent = Category.find( :first, 
                            :conditions => [ "id = ?", parent_id] )
...

Ruby Looking for alphabetized pl...

by midas, October 04, 2007 07:39, 3 refactorings

Set in array is in alpha or...

3092831491e0e9f9d654fbc080ceca91 Talk
x < lower ? lower : x > upper ? upper : x

# Or should I just go this way:
...

Ruby Enforcing bounds

by michiel, October 04, 2007 04:55, 4 refactorings

Given a value and a range, ...

7c45f63f61e478233f0c2ad3006b178c 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
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
SUPPORTED_LANGUAGES = [["English", "en"], ["German", "de"]]
# request.env["HTTP_ACCEPT_LANGUAGE"] = "en-us,us;q=0.5"
@languages = request.env["HTTP_ACCEPT_LANGUAGE"].split(';')[0].split(',')
...

Ruby Accept Language Array

by anshkakashi, October 02, 2007 12:47, 3 refactorings

This is some rails code whe...

B87cf29c05d9ce7a26588d6c48e5d988 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
# given this structure:
array_of_hashes = [
  {:callid => '1', :foo => '1', :created_at => '2007-09-21 11:45:15'}, 
...

Ruby Grouping an array of hashes

by Jarrod, October 01, 2007 14:15, 3 refactorings

This chunk of code takes an...

376dc89f458bb3b9ac3fd4d559098645 Talk
cap_growth = 5

v =  (@property.current_value / 100 * cap_growth) + @property.current_value
...

Ruby compound interest

by nootopian, September 30, 2007 12:50, 6 refactorings

there must be a better way ...

62c433a96de9da99d09afedcded5de76 Talk
before_filter :login_required
...

Ruby restful_authentication role...

by jamesgolick, September 27, 2007 10:40, 7 refactorings

This is a couple of lines t...

F6eddf2f983d23c2d031e407852625e9 Talk
def parse_line
  if line_is_parsable? 
    if line_is_nested? 
...

Ruby Arrow Code

by Ben Burkert, September 26, 2007 17:00, 9 refactorings

I hate arrow code. It's ug...

4d1c9dad17af98e55cb65b4efce27c42 Talk
task :extract_style do
  css = File.read 'public/stylesheets/code.css'
  css.gsub! "{\n", '{'
...

Ruby Extracting style from a CSS...

by macournoyer, September 25, 2007 21:18, 2 refactorings

Here's a Rake task I use to...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk
class CodeFormatter
  cattr_reader :syntaxes
  @@syntaxes = Uv.syntaxes.sort
...

Ruby [FEATURE] Sections in code!

by macournoyer, September 22, 2007 08:44, No refactoring

Introducing a new feature: ...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk
# Behave like +link_to_remote+, but shows a spinner while the request is processing.
#   link_to_remote_with_spinner 'Hi', :url => hi_path
# You can specify the spinner and the container to hide
...

Ruby link_to_remote_with_spinner

by danielharan, September 20, 2007 14:17, 5 refactorings

We use this utility interna...

880cbab435f00197613c9cc2065b4f5a Talk
def test_should_create_image_if_necessary_before_trying_to_give_it_data
  file = mock()
  file.expects(:content_type).returns('jpg')
...

Ruby Knowing mocha

by jamesgolick, September 20, 2007 11:53, 2 refactorings

Before

F6eddf2f983d23c2d031e407852625e9 Talk
puts `find test/ -name "*_test.rb" | wc -l`.to_f / `find app/ -name "*.rb" | wc -l`.to_f

Ruby Test file to code file ratio

by macournoyer, September 20, 2007 09:19, 3 refactorings

Hackish script to get the t...

Bfec5f7d1a4aaafc5a2451be8c42d26a Talk