Ruby On collecting attributes from ...
by danielharan,
June 17, 2008 13:47
While Fabien's solution doe...
def get_number_sequence(number)
@sequence = %w{ 24142 15151 25232 25252 14251 23252 23242 25151 24242 24252 }[number]
...
...
Ruby On Looking for comments on sty...
by danielharan,
June 16, 2008 15:13
Can you link to information...
<% if @user.carrier? %>
<li style="width:190px" id="mobile_no_div">
<%= @user.carrier.name %> <%= @user.mobile_no %>
...
def find_npa(dialed_nxx) return 819 if [ 205, 208, 210, 213, 243 ].include? dialed_nxx return 613 if [ 203, 204, 212, 216, 218 ].include? dialed_nxx ...
>> start = Time.at 0 => Wed Dec 31 19:00:00 -0500 1969 >> later = start + 60 * 60 * 2 + 60 * 3 + 1 # add 2 hours, 3 minutes and 1 second ...
# why does the alphabet include '*' anyways?
(('a'..'z').to_a << '*').each do |letter|
`curl|request somesite.com/search?q=#{letter} to /tmp/cache/searches/#{letter}`
...
Ruby On Can this scraper be simplif...
by danielharan,
May 31, 2008 17:27
You're mixing too many conc...
# Find all articles in the given date range based on the published_at field
def self.find_archived(year, month=nil)
if month.nil?
...
Ruby On Building a dynamic date range
by danielharan,
May 09, 2008 00:53
This version is a bit longe...
class Poll attr_accessor :question def initialize(question, answers=[]) ...
Ruby On Rubyize this : 6th edition
by danielharan,
May 04, 2008 00:11
System is a vile word in a ...
Ruby On Step-REST uuuuugly controller
by danielharan,
April 28, 2008 21:01
That's no longer really res...
class JobBoard < ActiveRecord::Base has_many :job_board_postings ...
Ruby Ruby has_finder on has_many ?
This smells... one of the m...
def fizz! 'fizz' end ...
Ruby On Challenge: Ugliest Ruby Fiz...
by danielharan,
December 21, 2007 15:53
No way can I compete with M...
module Wasabi
module Fizzy
def fizzy?
...
Ruby On Challenge: Ugliest Ruby Fiz...
by danielharan,
December 20, 2007 22:18
I was inspired by http://re...
create do
before { @post.user = current_user }
responds_to :html, :js do |format|
...
Ruby On resource_controller: Redesi...
by danielharan,
November 06, 2007 01:02
I prefer responds_to. Since...
class String
def postal_code?
self.strip =~ /^[a-z]\d[a-z][ -]?\d[a-z]\d$/i
...
Ruby On Is This String Postal?
by danielharan,
October 30, 2007 16:08
Now that I'm looking at tha...
class String
def postal?
self =~ /[a-zA-Z]{1}\d{1}[a-zA-Z]{1}([\x20-])*\d{1}[a-zA-Z]{1}\d{1}/
...
Ruby On Is This String Postal?
by danielharan,
October 30, 2007 15:40
That ternary operator is no...
namespace :migrations do desc 'reverts, renames and re-executes uncommitted migrations that conflict with already committed migrations' ...
Ruby Rails migration conflict re...
Explained here: http://www....
require 'erb' class ClientMigrator def self.create(fields) ...
Ruby Dynamic migrations for rails
by danielharan,
October 12, 2007 04:27,
1 refactoring
How do you create a rails p...
if self.location_type.to_s == 'point'
breaker = {'fr' => 'proximite', 'en' =>'near' }[self.lang]
else
...
def remove_insults(input)
%w{ stupid moron dumbass retard }.each {|insult| input.gsub!(Regexp.new(insult, true),'*' * insult.length) }
input
...
Ruby On Rubyize this : 3rd edition
by danielharan,
October 11, 2007 18:38
After noticing the issue wi...

Mostly straight from a tuto...