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, No refactoring, tagged with photography, camera, lens, ruby, math

Any comments, corrections, ...

4f5d54213efb6502baab202f3fb2f09e Talk
1
2
3
4
module Verbal
  module English
 
...

Ruby Displaying numbers to words.

by ytse.myopenid.com, November 27, 2008 13:45, 4 refactorings

Is it possible to refactore...

Ea0b4e0dce47a1d4bba05b1bdffdc2d7 Talk
1
named_scope :with_description, :conditions => "description IS NOT NULL and trim(description) != ''"

Ruby Doing a 'blank?' in named_s...

by Jo, November 26, 2008 19:01, 1 refactoring, tagged with rails activerecord

Can you do a .blank? in a n...

8aed7215b394d7fb97357951c733fa18 Talk
1
2
3
4
/* sample input
h1. Introduction
* s5 is way cool, but I think in textile
...

Ruby Converting Textile to S5

by MattK, November 25, 2008 14:08, No refactoring, tagged with redcloth, textile, loops, regular regular expression

I'd like to take a bunch of...

Dd9c3fd0786a478b7cbf33eff5c841e4 Talk
1
2
3
4
def field_row(options={}, &block)
  concat("<div class="field_row">", block.binding)
  concat(capture(&block), block.binding)
...

Ruby Cheap ruby block templating

by Alistair, November 22, 2008 15:50, 5 refactorings, tagged with rails, blocks

Hello all. I've got the fol...

95d8510ef03567cd7d014d4790116b0d Talk
1
2
3
4
def test(a, b)
  capitalize_args
  puts a   # => Hello
...

Ruby Bindings on caller

by Tj Holowaychuk, November 22, 2008 06:16, 2 refactorings, tagged with binding

I dont really have a need f...

F1e3ab214a976a39cfd713bc93deb10f Talk
1
2
3
4
def monitor(uri)
  Thread.new(uri) do |uri|
    begin
...

Ruby Initial script execution ve...

by Tj Holowaychuk, November 22, 2008 02:27, No refactoring

Below is a little snippit o...

F1e3ab214a976a39cfd713bc93deb10f Talk
1
2
3
4
  NAME:
  
...

Ruby suppress ERB newlines

by Tj Holowaychuk, November 22, 2008 02:16, No refactoring, tagged with erb

Just plain-jane ERB. What d...

F1e3ab214a976a39cfd713bc93deb10f Talk
1
2
3
4
select = []
joins = []
%w[first second third forth].each{ |semester| joins << ":pdp_#{semester}_semester"; (1..5).each{ |n| select << "pdp_#{semester}_semesters.objetive_#{n} AS #{semester}_objetive_#{n}" }}
...

Ruby Arrays, loops, strings...

by Ceritium, November 20, 2008 22:09, 3 refactorings, tagged with array string loop each

Can this be done in one line?

7841fbf022cfe78bff34942b50c483e1 Talk
1
2
3
4
class Publication < ActiveRecord::Base

  def publisher_name
...

Ruby Similar virtual attributes ...

by foxdemon, November 20, 2008 13:42, 4 refactorings, tagged with getter, setter, virtual attributes

My Publication class has a ...

8fa97b9513b66cccc2db021782863b3b Talk
1
/(?<part>(w(?!ww)|w(?=www)|w(?=[a-z0-9]+ww)|ww(?=[a-z0-9]+w)|www[a-z0-9]+|[a-vx-z0-9])[a-z0-9]*)\.example\.com/

Ruby Shortest regular expression...

by troethom, November 19, 2008 18:48, 3 refactorings, tagged with regex

I have written this regular...

628b75cc5fce9ab14d9e8584a0b3681c Talk
1
2
3
4
class Something
  
...

Ruby Caching Methods

by Tj Holowaychuk, November 19, 2008 05:23, 6 refactorings, tagged with cache

Is it possible to cache met...

F1e3ab214a976a39cfd713bc93deb10f Talk
1
2
3
4
describe Stock do

  it "should be valid when new" do
...

Ruby repeated code in rspec mode...

by scottmotte.myopenid.com, November 15, 2008 08:51, No refactoring, tagged with rspec, merb, model

how do i clean up this repe...

2fb54bca5a55a7a16f8f9c20c05ce7c2 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
class PropertiesController < ApplicationController
  before_filter :authorise_action
...

Ruby Condensing nested conditionals

by Nick, November 11, 2008 21:28, 4 refactorings, tagged with ruby rails condense conditions

The code below works, but f...

49de4cd2f26705785cbef2b15a9df7aa Talk
1
2
3
4
# Suppose I have San::Languages::JavaScript as the 'lang' local var below
# I want a string of 'JavaScript' from this example
...

Ruby Retrieve class name only

by Tj Holowaychuk, November 07, 2008 04:41, 1 refactoring

Im sure there is a better w...

F1e3ab214a976a39cfd713bc93deb10f Talk
1
2
3
4
# [user@host ~]$ ls -l blah
# -rwxr--r-- 1 user users 0 2008-11-06 15:20 foo

...

Ruby Pretty output of permission...

by ScriptFu, November 06, 2008 22:29, 3 refactorings, tagged with shell ruby permissions

This snippet is designed to...

097df7a744da527a58b40d21260f1f8d Talk
1
2
3
<ul>			  
...

Ruby View refactoring

by DG, November 06, 2008 07:01, 1 refactoring

In following code ul gettin...

51224bdd17878b3b19e8987e9bb336a2 Talk
1
2
3
class PeopleController < ApplicationController

...

Ruby Re-use code for new and cre...

by Dave, November 05, 2008 09:30, 4 refactorings, tagged with rails, dry, controller

Hello,

I have a 'people'...

997adc3b63a05bf75f833c48fa246e19 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
# GET /neighbourhoods/map_filter
def map_filter
  @map_filter_errors  = nil # Stores errors related to a filter request.
...

Ruby DRY up a controller action

by Nick, October 31, 2008 20:52, 5 refactorings, tagged with rails fat controller

My Neighbourhood "map_filte...

49de4cd2f26705785cbef2b15a9df7aa Talk
1
2
3
4
/^(?:(\d)[ \-\.]?)?(?:\(?(\d{3})\)?[ \-\.])?(\d{3})[ \-\.](\d{4})(?: ?x?(\d+))?$/

# expanded version w/ comments
...

Ruby Phone number regex

by Lex, October 31, 2008 16:00, 3 refactorings, tagged with phone number, regex, regexp, regular expression

I wrote this regex for pars...

Aca17ffad5faa4b9f2ea9090b56a1c59 Talk
1
2
3
   id
...

Ruby Inserting dynamic string in...

by DG, October 31, 2008 10:21, 1 refactoring

Let me explain the scenario...

51224bdd17878b3b19e8987e9bb336a2 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
Event.find(:all, :conditions =>
                    "((strftime('%m%d', ends_at) <= strftime('%m%d', starts_at)) AND (strftime('%m%d', 'now') <= strftime('%m%d', ends_at)))
                    OR
...

Ruby Yearly recurring event

by Harry Jr., October 30, 2008 12:17, 1 refactoring, tagged with sqlite3

Users can add yearly recurr...

218e262d73d0c38480a087b19f916b09 Talk