1
2
3
4
  def translation_links
    lang = [
      %w[en english us], 
...

Ruby nested array to set of html...

by seaofclouds, October 09, 2008 07:51, 2 refactorings, tagged with ruby, array, hash, translation

i have a simple array that ...

F55e8e113669f6ea7d1d99f38907ce54 Talk
1
2
3
# Simple method to calculate the square of a number
...

Ruby Conditional Assignment

by ruphin.myopenid.com, September 21, 2008 15:01, 15 refactorings, tagged with ruby, assignment

This is a tiny bit of code ...

C54b1538124ee5c6f3af5f628e1750dc Talk
1
2
3
4
class RSExp

	def equate(xp)
...

Ruby Cleaner Ruby

by codvious, September 20, 2008 03:43, 5 refactorings, tagged with ruby

Noob to Ruby here. Any way ...

E0dabbf83e6c56adc987e069e4b83a2b Talk
1
2
3
feed = RssParser.run("http://ws.audioscrobbler.com/1.0/user/me/recenttracks.rss")
  song1 = feed[:items][0][:title]
...

Ruby Think this needs a loop

by juo100@gmail.com, September 06, 2008 19:54, 3 refactorings, tagged with ruby, loop, noob

Im new to Ruby, I think it ...

B543a43dc8cb0aae562278484db60d25 Talk
1
2
3
class Administration::ReportsController < Administration::HomeController
...

Ruby has_many :through collectio...

by kain, August 30, 2008 01:53, No refactoring, tagged with Ruby on Rails, rails, ruby, has many through

This is an attempt to make ...

25e782eb7e799e78d781b0026fc6a4d8 Talk
1
2
3
4
class Report < ActiveRecord::Base
  belongs_to :reportable, :polymorphic => true
  
...

Ruby A shorter way to declare cl...

by danielharan, August 14, 2008 19:47, 1 refactoring, tagged with ruby, rails, constants

I added these so I could re...

880cbab435f00197613c9cc2065b4f5a Talk
1
2
3
    artists = [1, 2, 3]
    column_1 = artists[0..artists.size/2]
    column_2 = artists[artists.size/2+1..artists.size]

Ruby Split an array into half

by gudata, August 14, 2008 09:49, 6 refactorings, tagged with ruby, array, split

The example works if the ar...

4ee8e20a519f3afdcd03bcf24681dbd8 Talk
1
2
3
4
if @events != nil
  @events.each do |event|
    if @recurrents != nil
...

Ruby superfluous if statements

by ttdavett.myopenid.com, August 10, 2008 22:51, 4 refactorings, tagged with ruby, rails, if, else

I'm pretty sure theres a be...

F677fa685a2cfe8aff31f161062db3d3 Talk
1
2
3
4
def caesar(text,shift)
count = 0
...

Ruby Caesar Cipher

by Loki, August 09, 2008 05:26, 3 refactorings, tagged with caesar cipher, ruby, noob

A Caesar Cipher, or Caesar ...

Avatar Talk
1
2
3
4
require 'csv'

def sort_csv(filename, fields = ["ID"], reverse = false)
...

Ruby Ruby Custom Sort

by cpjolicoeur, August 03, 2008 14:37, 5 refactorings, tagged with ruby, sort, csv, sorting

I had this question recentl...

Cf8a610127d1108dfe67f673320b5fe5 Talk
1
2
3
4
# generate_bf.rb
# (copyleft) Matt Gauger 2008
# Randomly generates a brainfuck program
...

Ruby Brainfuck Generator in Ruby

by mattgauger, July 31, 2008 19:05, 6 refactorings, tagged with ruby, brainfuck

Probably better ways to do ...

311c342bfd324eb9d3603222f7f36f24 Talk
1
2
3
4
    times.each do |time|
      events.each do |event|
        if time.strftime("%I:%M %p") == event.datetime.strftime("%I:%M %p")
...

Ruby two for loops cleanup?

by ttdavett.myopenid.com, July 31, 2008 00:11, 7 refactorings, tagged with rails, ruby, array, hash

times is an array of dateti...

F677fa685a2cfe8aff31f161062db3d3 Talk
1
2
3
4
i = 0
for j in ['foo', 'bar', 'baz']
    puts "#{i} #{j}"
...

Ruby Python's enumerate in Ruby?

by robby86533.identity.net, July 14, 2008 23:02, 3 refactorings, tagged with python, ruby, for, enumerate

What is the best way to emu...

Cbb09ca8a832170ec73186f5c8cafba4 Talk
1
2
3
4
xml = REXML::Document.new(data)

artists = []
...

Ruby cleaner way to limit result...

by timmyvontrimble.myopenid.com, July 14, 2008 19:12, 9 refactorings, tagged with rails, xml, array, iteration, ruby

Wow! All of these refactori...

16462f49b44507dc6522eb9bea0fce51 Talk
1
2
3
4
module DiscreteDistribution
  
  # pick_random is useful for spliting up a collection by its specified discrete distribution
...

Ruby Randomly pick an item base ...

by David Dai, June 15, 2008 06:02, No refactoring, tagged with random, algorithm, discrete, discrete distribution, ruby, load balance, multivariate, ab-test

This method is useful to lo...

535215c41c0949117577517b4506202c Talk
1
2
3
4
module Every
  @interval, @stopped = 0.0, true
  @numwords = {"one"=>1, "two"=>2, "three"=>3, "four"=>4, "five"=>5, "six"=>6, "seven"=>7, "eight"=>8, "nine"=>9,
...

Ruby Every repeat module

by Ryguy, June 13, 2008 18:38, 1 refactoring, tagged with ruby, loop

Loop a block of code every ...

Ba665f86f90a1982af7b9c857418fcdb Talk
1
2
3
<!-- THE XML IM TRYING TO PARSE -->
...

Ruby Trying to parse XML and pas...

by Jason Calleiro, May 30, 2008 20:09, 4 refactorings, tagged with ruby, rails, parse, xml, hpricot

I am completely new to ruby...

A4e2fea57f511d697f1de55198996f23 Talk
1
2
3
4
require 'net/http'
require 'rubygems'
require 'xmlsimple'
...

Ruby Parsing XML from a Web Service

by mwilliams, May 17, 2008 21:10, 3 refactorings, tagged with ruby, hash, xml, web, service

I'm working with a web serv...

4236ea6b84f4899b469e8edff4bf6d22 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
  # 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
<table class="charge">
  <tr>
    <td colspan="100%" class="mainHeader"><%=@label.label%></td>
...

Ruby Iterating through a nested ...

by mwilliams, January 31, 2008 18:21, 2 refactorings, tagged with rails, view, table, hash, nested hash, iterator, iterate, ruby, Ruby on Rails

Good afternoon. I have a n...

4236ea6b84f4899b469e8edff4bf6d22 Talk
1
2
3
4
  def planned_percent_complete
    if self.planned_complete_in_dollars != nil
      (( self.planned_complete_in_dollars.to_f / self.task.budget.to_f )  * 100).round(2)
...

Ruby Same methods, different Act...

by Chris W., January 08, 2008 18:31, 6 refactorings, tagged with ruby, rails, activerecord, dry

I know there has to be a "r...

Avatar Talk
1
2
3
4
  def self.find_matches(params)
    matches = self.find(:all)
...

Ruby Filtering Method Needs to b...

by bradly.myopenid.com, January 04, 2008 16:38, No refactoring, tagged with ruby, rails, filtering, wet

I know it looks long, but i...

0914e5093f1af95df0ab2478818856d8 Talk
1
2
3
def filename
  self.uri.split('/').last
...

C# Get the Filename segment o...

by jwmittag, January 01, 2008 15:04, 10 refactorings, tagged with ruby, rails, Ruby on Rails, RoR, C#, CSharp, C-Sharp, .net, DotNET, asp.net, Scott Porad, Comparison

On his Blog "Progress vs. P...

4bae3f603d397647c273dfa49ef8050c Talk
1
2
3
4
module Enumerable
  def to_a(n = nil)
    result = []
...

Ruby Enumerable#to_a with termin...

by Ben Kudria, December 24, 2007 23:36, No refactoring, tagged with ruby, enumerable, finite, countable, countability

Please see this ruby-talk t...

5b6484445948ebe063c264a1015dfcc4 Talk