Given /^The Navigation API is running$/ do
  begin
    @response = get('servicestatus', 'text/plain')
...

Ruby Step Definition

by https://www.google.com/accounts/o8/id?id=AItOawnvtFGh-r9ibK5ZHTYiZh2UzxDww7-bwI0, October 08, 2011 05:19, No refactoring

Fairly new to ruby, wondere...

55502f40dc8b7c769880b10874abc9d0 Talk
test "should not save with name > 60 chars" do
  name = ""; name << 61.times.each{|x| name << "a"}
  @author.name = name
...

Ruby validates length of in rails

by Luciano Sousa, September 21, 2011 07:00, 10 refactorings, tagged with ruby rails test unit

what's better idea for this?

9af091720396af75791d4f7187fca39e Talk
def steps
    unless @steps
      if scenario.class == Cucumber::Ast::OutlineTable::ExampleRow
...

Ruby unless.. if..

by https://www.google.com/accounts/o8/id?id=AItOawmZADKQPpupLegafoFEaOnWDyZ6Kd_VfMI, September 26, 2011 05:39, 6 refactorings, tagged with rails

These two methods both seem...

55502f40dc8b7c769880b10874abc9d0 Talk
if self.is_a?(Dog)
    with_new_options do
      $options << :Dog_videos
...

Ruby if/else with code duplication

by https://www.google.com/accounts/o8/id?id=AItOawldlqFajuby_15kAm_eqdxsKUOQpKvE99o, September 30, 2011 07:02, 4 refactorings, tagged with rails short clean ruby

As you see, Event.queue sel...

55502f40dc8b7c769880b10874abc9d0 Talk
def bad_books(good_book_ids)
  Book.all(:conditions => ["id NOT IN (?)", good_book_ids])
end
...

Ruby is there a smart way to usi...

by Fred Liang, September 08, 2011 02:36, 3 refactorings, tagged with ruby sql ActiveRecord

Is there a better way to re...

48986aabbdbcdeacdbc3a6dc2945a9ff Talk
class GroupByDate
  attr_reader :date, :id

...

Ruby Group by date

by coco-avisagsa-com.myopenid.com, September 01, 2011 07:09, 1 refactoring

I'm using a dirty trick to ...

55502f40dc8b7c769880b10874abc9d0 Talk
require 'open-uri'
require 'net/http'

...

Ruby Find valid URLs

by Nathan, September 05, 2011 07:08, 1 refactoring, tagged with uri, brute-force, urls, 404, 200

Some selected URLs exist wh...

D5145c421cd25af6fa577c15219add90 Talk
require 'rubygems'
require 'facets'
...

Ruby getting the diff of two hashes

by https://www.google.com/accounts/o8/id?id=AItOawmHJ1ONaW6q8tTA21erxFUKoFCJsNY0QiE, September 21, 2011 05:04, 1 refactoring

if I run a regular merge wi...

55502f40dc8b7c769880b10874abc9d0 Talk
def find_factors(number)
  factors = [1,number]
  i = 2
...

Ruby Find the factors of a number

by Aziz Light, September 12, 2011 13:18, 1 refactoring

This little function will f...

D69bd6b89f0c9204eed89de9d7ee4632 Talk
#!/usr/bin/env ruby

require 'rubygems'
...

Ruby automatic info plist versio...

by slf, September 30, 2011 11:30, No refactoring, tagged with ruby, git, xcode, plist

I hacked up a script to aut...

098e5c1a565b47e9860539fbebc3fa98 Talk
.---. 
     |   v*
 .--------------.  
...

Ruby Instance-level authorization

by dagobah.myopenid.com, September 07, 2011 04:49, No refactoring, tagged with rails, database, authorization, instance-level

Is this database structur...

55502f40dc8b7c769880b10874abc9d0 Talk
class Job
  has_many :tasks

...

Ruby Convert SQL scopes to somet...

by KieranP, September 07, 2011 15:46, No refactoring, tagged with rails, postgres, named_scope, scopes

Using Rails 3.0.10, and Pos...

74198b06bc9e68739debfe6c23e070d3 Talk
if @image.update_attributes params[:product_image]
  if request.xhr?
    render :json => { :status => 'success', :data => {:message => I18n.t('product_image.results.reordered')} }
...

Ruby DRY up a controller action

by Nick, August 05, 2011 11:13, 6 refactorings, tagged with rails, ruby, controller, DRY

Any suggestions for DRYing ...

49de4cd2f26705785cbef2b15a9df7aa Talk
class IRC < TCPSocket
  def cmd str
    send "#{str}\r\n", 0
...

Ruby Calling methods from elsewhere

by moshee, August 03, 2011 07:26, 5 refactorings, tagged with noob, classes

Is there any way to call cm...

D41d8cd98f00b204e9800998ecf8427e Talk
def insertion_sort(list) #insertion sort
  @list = list
  index_a = 1
...

Ruby Insertion Sort

by https://www.google.com/accounts/o8/id?id=AItOawmBGCnNiwxOiv77AwKGzLCYF1WOOMBZIdc, August 11, 2011 23:42, 3 refactorings

Trying to write the easiest...

731b5eaa680b94fd463c668b35afcf06 Talk
def randomize_case(string)
  letters = string.split("")

...

Ruby Randomize case

by Aziz Light, August 22, 2011 06:32, 3 refactorings, tagged with random, String Manipulation

Is there a better, shorter ...

D69bd6b89f0c9204eed89de9d7ee4632 Talk
def new
    if current_user.has_credit_card_on_file?
      redirect_to edit_user_billing_path, :notice => "We've detected that you already have a credit card on file, please edit the details below"
...

Ruby Feels like an easy refactor...

by https://www.google.com/accounts/o8/id?id=AItOawmRvMhcLFwL72d7b-9gx7YpThiobwkY3Co, August 18, 2011 08:44, 2 refactorings, tagged with rails3 controller

I've got the method below w...

1772298f2d14152c13bbd3221e6ab6ec Talk
require "rspec"

module PrimeModule
...

Ruby Programming puzzle

by michal-pochwala.myopenid.com, August 24, 2011 07:35, 2 refactorings, tagged with ruby, puzzle

Problem to solve:

The pr...

55502f40dc8b7c769880b10874abc9d0 Talk
@visits_by_day_and_hour = visits.group_by{|day| day.created_at.strftime("%Y-%m-%d")}.map {|d, items| [d, items.group_by{|hour| hour.created_at.strftime("%H")}.map{|k,v| [k, v.length]}]}

Ruby Group array elements by day...

by https://www.google.com/accounts/o8/id?id=AItOawlsPHX5ps6aEa58SFp7fTjKFgMmK9Hi-Dg, August 07, 2011 23:45, 2 refactorings, tagged with ruby, arrays, group_by, map array

Hi, I have a set of objects...

55502f40dc8b7c769880b10874abc9d0 Talk
@stop_words = ["and", "on", "was", "in", "an", "it", "of", "a"]
words = "Here are 175 healthy recipes calibrated for males and females trying to lose fat.".split(/ /)
@stop_words.each { |a| if words.include?(a) then; words.delete(a) end;}

Ruby Array.include

by https://www.google.com/accounts/o8/id?id=AItOawkSg8scJklKELdYX2Rx5_OZpV3OPeKROdg, August 11, 2011 14:10, 1 refactoring, tagged with Array include

this part of removing stop ...

3d0281c16e03f71cc69e1fce607d023d Talk
scope :by_game, lambda{|game_id| where("team_game_id IN (SELECT id FROM team_games WHERE game_id = ?)", game_id)}

Ruby Bad Scope

by https://www.google.com/accounts/o8/id?id=AItOawkVKyrxjyHdaZjxtdWZH7QHlcULMtVNZ4I, August 05, 2011 06:41, 1 refactoring, tagged with rails3 activerecord

I know this scope has an ea...

55502f40dc8b7c769880b10874abc9d0 Talk
require 'set'

class StatComputations
...

Ruby Mean Median in Ruby

by https://www.google.com/accounts/o8/id?id=AItOawl0nTuHS77YHoJ_YssSDUGitTHCLZVvgrA, August 28, 2011 20:10, 1 refactoring, tagged with ruby, ruby1.9, mean, median

Here is the snippet of mean...

B6d7dffed1196ab1a2ac35504a0cb03c Talk
# Operators => Priority
OPERATORS={
  '+' => 0,
...

Ruby Simple tokenizer

by tzar, August 06, 2011 03:17, No refactoring, tagged with ruby, parsing

Takes a string and returns ...

9a75a91432c4a6b40bfbb6c6016296ec Talk
def input
  ret = STDIN.gets.lstrip
  return ret.rstrip unless [?', ?"].include? ret[0]
...

Ruby User input with mutiple lines

by https://www.google.com/accounts/o8/id?id=AItOawnIPSSqMcibd_8s-QGdKZzB56unfy48gZc, August 08, 2011 11:22, No refactoring, tagged with STDIN, gets

This method will get the us...

55502f40dc8b7c769880b10874abc9d0 Talk
FILE = File.join(File.dirname(__FILE__), '..', 'activity_exercise_sport.csv')

  WEIGHTS = [130, 155, 180, 205]
...

Ruby CSV to hash

by Chirantan Rajhans, August 24, 2011 04:34, No refactoring, tagged with one-liner, array hash

The part where weight_calor...

18bcc556d7688096bd4daa5d72bd6c32 Talk