1
2
3
4
object.constraints.each do |c|
  p = object.particles[c.index]
  if c.component == :x
...

Ruby ruby metaprogramming

by micktaiwan, January 06, 2009 00:30, 4 refactorings, tagged with ruby, metaprogramming

So here here my ugly code. ...

2f6686bd2c6bb633a1cbf7b5a73c8491 Talk
1
2
3
4
class Light
  def initialize(location)
    @location = location
...

Ruby Command Pattern from Head F...

by Rubén Dávila, January 02, 2009 14:09, 1 refactoring, tagged with ruby, patterns, design

Example in Ruby of Command ...

0e34c56054c414263e933a1b8b3d0d55 Talk
1
2
3
4
brew = "rdadadroxmocpronogomocdmqzx"
alphabet = "abcdefghijklmnopqrstuvwxyz"
word = ""
...

Ruby Newb needs some cleanup

by redpidgin, December 23, 2008 16:16, 7 refactorings, tagged with short, ruby, decode

Some code I've written for ...

5ce36f73f075f18632c284f56cedd23d Talk
1
2
3
4
  require 'rubygems'

  require 'hpricot'
...

Ruby Screen Scraping Google with...

by zigx.myopenid.com, December 18, 2008 00:48, 7 refactorings, tagged with ruby, hpricot, watir, google, scrape

Would love to see a COOLer ...

Ff9eefc6ed72560c262b0e125151ea7c Talk
1
2
3
4
# sum an an array's elements
def sum_row(a)
  sum = 0
...

Ruby Conditionally deleting colu...

by srboisvert.myopenid.com, December 18, 2008 00:18, 4 refactorings, tagged with ruby, csv, array

I needed to read in a CSV f...

12d6a2e5971e661ee2bf2994526e848d Talk
1
2
3
4
get '/:id' do
  @vent = Vent.get(params[:id])
  erb :show
...

Ruby Trying to condence 2 method...

by Jason Calleiro, December 10, 2008 21:53, 5 refactorings, tagged with ruby, sinatra, rails, rest, xml

Currently using sinatra fra...

A4e2fea57f511d697f1de55198996f23 Talk
1
2
3
4
#!/usr/bin/env ruby -wKU
require 'rubygems'
require 'net/http'
...

Ruby Web2.0 Domain Name Generator

by dw, December 08, 2008 10:13, 3 refactorings, tagged with ruby, domain, name, generator

This generates a text file ...

Ed8cd6f26fffbe2b783df3b12508dfd0 Talk
1
2
3
4
array_with_blank_strings.compact.reject(&:blank?)

>> array_with_blank_strings = ["Item 1", "Item 2", " ", "Item 3", nil]
...

Ruby Strip blank Strings and Nil...

by Ivan Vanderbyl, December 07, 2008 21:36, 1 refactoring, tagged with ruby, array, strip, blank

This code will firstly remo...

8991cd8e29cf99d2aebb2301c762e5bd Talk
1
2
3
4
# camera related
def frame_diagonal(frame_horizontal, frame_vertical)
	@frame_diagonal = Math.sqrt((frame_horizontal**2) + (frame_vertical**2))
...

Ruby Photograhy methods

by sfusion.myopenid.com, December 05, 2008 11:42, 1 refactoring, tagged with photography, camera, lens, ruby, math

Any comments, corrections, ...

4f5d54213efb6502baab202f3fb2f09e Talk
1
2
3
4
def factorial( n )
  if !(n.is_a? Integer)
    raise ArgumentError, "argument must be a positive integer"
...

Ruby A simple factorial program.

by lordzoner.myopenid.com, November 12, 2008 02:16, 7 refactorings, tagged with short, ruby, factorial

I'm quite new to Ruby, and ...

88f4aad84b5441c255cbe96a0fcc6319 Talk
1
2
3
4
    for directory in @directories
      xml.item do
        xml.title "#{directory.name} (PR #{directory.pagerank})"
...

Ruby xml rss feed

by chovy.myopenid.com, November 05, 2008 07:13, 2 refactorings, tagged with Ruby on Rails, proc, xml, ruby

Looking for a better way to...

035687df00d162cec025302373ebc076 Talk
1
2
3
4
def compress(source)
    source.gsub!(/\s+/, " ") # collapse space
    source.gsub!(/\/\*(.*?)\*\//, "") # remove comments - caution, might want to remove this if using css hacks
...

Ruby Gsubing

by marko.z, October 31, 2008 09:44, 2 refactorings, tagged with ruby, string, css, gsub

There is a lot of repetitio...

Bd9893bfd15fa7b443d112607b937734 Talk
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 pootcode, 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, 7 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