1
2
3
4
  def make_activation_code
    counter = 0
    loop do
...

Ruby restful_auth

by davidhq, May 13, 2008 22:00, 8 refactorings, tagged with restful authentication

make_activation_code and ma...

4057d36ea1505c263efbdbdc0bf511cd Talk
1
2
3
4
class WhoIsQuery
    query = ARGV[0]
    puts "Querying whois with #{query} ..."
...

Ruby Whois refactoring

by MexicanHacker, May 12, 2008 15:19, 1 refactoring, tagged with whois rubyize-this

I'm new to ruby and I make ...

7a1f5bc20a17bba473d54617d9893466 Talk
1
2
3
4
def save_feed  
  @feed = FeedTools::Feed.open('http://losangeles.craigslist.org/apa/index.rss')
     @feed.items.each_with_index do |item,i| 
...

Ruby RSS model method

by Deepak Gole, May 12, 2008 10:17, 2 refactorings, tagged with FeedTools

Its very simple method whic...

51224bdd17878b3b19e8987e9bb336a2 Talk
1
2
3
4
class Article < ActiveRecord::Base

  # Find all articles in the given date range based on the published_at field
...

Ruby Building a dynamic date range

by claytonlz, May 08, 2008 23:45, 2 refactorings, tagged with date range, date

I've got a route that handl...

E17d936d4535519716b6e810052feac5 Talk
1
2
3
4
<% @purchase_order.grants.each do |grant| %>
  <table>  
    <tbody>
...

Ruby Please help me simplify thi...

by schof, May 01, 2008 14:04, No refactoring, tagged with ruby rails each loop

Is there a way in Ruby to p...

Cfaf074970ce958900608fceaac38543 Talk
1
2
3
4
class CampaignsController < ApplicationController
  before_filter :load_campaign_or_redirect, :except => [:index, :sent, :new, :queued, :create, :processing]

...

Ruby Step-REST uuuuugly controller

by Pożycz Badge, April 23, 2008 16:01, 2 refactorings

Proably it's possible to cl...

Avatar Talk
1
2
3
4
n=16
s="1"
s1=""
...

Ruby Verber's puzzle

by timurv, April 22, 2008 08:51, 1 refactoring, tagged with verber

1
11
21
1211
111221
31...

E775d684d712540a4b76849b3026e70f Talk
1
2
3
class UserMailer < ActionMailer::Base 
  def signup_notification(user)
...

Ruby before_filter in model???

by Jeaf, April 21, 2008 11:19, 2 refactorings, tagged with Ruby on Rails

I have to call the setup_em...

99b003c2a01aa0dc3b0fe7c5d72f56a0 Talk
1
2
3
4
class VotingSystem  
  #Hello, I am Rodger the old and unhappy programmer. the variable nbrOfVotes is an array of 2 dimensions. The first dimension contains the number of votes for the answer "YES, IT SUCKS"... and the other dimension contain the number of votes for the answer "NO, IT DOESN'T SUCK". In the near future there will be other possible answers... but I don't care! I retire in 2 days!
  @@nbrOfVotes = Array.new
...

Ruby Rubyize this : 6th edition

by FrankLamontagne, April 17, 2008 00:20, 8 refactorings, tagged with rubyize-this, ruby, fun

Ouch... this guy badly need...

364d0e86994a268906392f6b6146af38 Talk
1
2
3
4
   def self.valid?(key)
       h=find_by_key(key)
 
...

Ruby Better Nest Ifs

by pcorral.myopenid.com, April 13, 2008 03:02, 6 refactorings

Any idea about better code?

82c793022ec1bce6ea7573bc27b2340b Talk
1
2
3
4
require 'erb'

# GOAL: render the template with the following vars
...

Ruby Given a hash of variables, ...

by mislav, April 12, 2008 15:12, 3 refactorings, tagged with erb, singleton, metaclass, metaprogramming, hash, render

This works. Now, is there a...

8f93a872e399bc1353cc8d4e791d5401 Talk
1
2
3
4
   def assigned_to_id=(user_id)
     if user_id == ""
       if self.ticket_assigment != nil-
...

Ruby WTF

by prekitt.myopenid.com, April 09, 2008 19:56, 1 refactoring, tagged with Ruby on rails activerecord

There's got to be a better ...

477f578e4349b6022de8517f8457a650 Talk
1
2
3
4
def hashify(object_array)
		h = Hash.new
		object_array.each do |x|
...

Ruby Less typing same functionality

by lusis.myopenid.com, April 09, 2008 16:40, 4 refactorings, tagged with ruby nagios

I know this can be done but...

Avatar Talk
1
2
3
class Race < ActiveRecord::Base
  
...

Ruby Help generating abbreviatio...

by Michael Filbin, April 06, 2008 16:16, 2 refactorings, tagged with abbreviation, string, model, attribute

Hi all,

I am attempting ...

14b8667b3bdf64068647b96c26001e0d Talk
1
2
3
4
require 'benchmark' 

def euler_chain_size(start)
...

Ruby Euler 14

by Jeff, April 04, 2008 00:30, 1 refactoring, tagged with Euler14

The problem description is ...

196b781eef85b7ce609fd12234cc1f39 Talk
1
2
3
4
class JobBoard < ActiveRecord::Base
  has_many :job_board_postings
  
...

Ruby Ruby has_finder on has_many ?

by danielharan, April 01, 2008 16:10, 1 refactoring, tagged with has_finder rails

This smells... one of the m...

880cbab435f00197613c9cc2065b4f5a Talk
1
2
3
4
#!/usr/bin/env ruby
  
# Simple Ruby XML Socket Server
...

Ruby AJAX Chat Socket Server

by Martindale, March 28, 2008 18:39, 1 refactoring

Line 224, if I change this ...

72f4ba51b784673a15a1e89d8d9f49d1 Talk
1
2
3
4
@week_endings ||= Actual.get_week_endings(4.weeks.ago.to_date)
6.times do |p|
  actual = Actual.new
...

Ruby Appending future dates to t...

by mwilliams, March 24, 2008 19:36, 2 refactorings, tagged with ruby dates mode kiss

Line 1 I'm grabbing the mos...

4236ea6b84f4899b469e8edff4bf6d22 Talk
1
2
3
4
  # OPTIMIZE: I think we can do a LOT for optimize this.
  def create
    added_counter = 0
...

Ruby Importing large collection ...

by mister, March 22, 2008 19:16, 2 refactorings, tagged with ruby, rails

This scripts get textarea w...

Avatar Talk
1
2
3
4
  def pearson(first,second)
    common = first.select{|title,rating| second.include?(title) }
    return if common.empty?
...

Ruby Pearson coefficient calcula...

by Brianthecoder, March 13, 2008 14:08, 1 refactoring

This was ported from python...

3f91cf60c92b20940674ebdeb46f6582 Talk
1
2
3
4
class Hash
  def fetch_all(key)
    results = []
...

Ruby Recursive Hash#fetch

by Neo, March 12, 2008 14:05, 1 refactoring, tagged with nested hash, hash, fetch

I wanted a Hash#fetch that ...

E64b3f6a4b0bde29f654eca45fcbb20f Talk
1
2
3
4
%w[uri net/http hpricot].each {|lib| require lib}
url = 'http://en.wikipedia.org/wiki/Night'
response = Net::HTTP.get_response(URI.parse(url))
...

Ruby Absolute links

by michael.twofish, March 11, 2008 15:02, No refactoring, tagged with URLs, absolute links, relative links

Converting all URLs in a re...

6268bd082e6c4ca2664b094f75a38759 Talk
1
2
3
4
def create
  @partner = Partner.new(params[:partner])
  if(params[:partner_request_id])
...

Ruby Fat controller method

by Teflon Ted, March 10, 2008 00:40, No refactoring, tagged with rails fat controller

I came across this monster ...

517a3f8ee4a9da153ee1b4959446e0ac Talk
1
2
3
ActionController::Routing::Routes.draw do |map|
  eval(File.open(File.dirname(__FILE__) + '/../path/to/another/routes/file.rb', 'r').read)
end

Ruby Adding routes in an externa...

by jseifer, March 07, 2008 22:40, 2 refactorings, tagged with rails

I'm trying to retain the ra...

1543059f424f9fe5b7654413e6c8dc22 Talk
1
2
3
4
def calculate_price_of_credits(credits)
  case credits
  when 1..5000
...

Ruby Ugly method for calculating...

by mister, March 07, 2008 17:53, 3 refactorings

very uglish method, please ...

Avatar Talk