Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

class EmailCollection
include Enumerable
delegate :each, :to => :email_addresses
def initialize(raw_email_addresses)
@raw_email_addresses = raw_email_addresses
end
def valid_emails
select {|e| e.match(email_regex) }
@reagent
reagent / email.rb
Created October 17, 2012 04:51 — forked from efatsi/email.rb
class Email
def initialize(address)
@address = address
end
def address
@address.strip
end
class Particpant < AR::Base
delegate :require_name?, :require_email?, :require_phone?, :to => :project, :allow_nil => true
with_options :on => :update do
validates_presence_of :name, :if => :require_name?
validates_presence_of :email, :if => :require_email?
validates_presence_of :phone, :if => :require_phone?
end
@reagent
reagent / past_orders.rb
Created September 12, 2012 20:19 — forked from efatsi/past_orders.rb
methodology comparison
def find_suggestions_for(restaurant)
past_orders = []
orders.each {|o| past_orders << o if o.restaurant == restaurant }
past_orders
end
def find_suggestions_for(restaurant)
orders.inject([]) do |result, order|
result << order if order.restaurant == restaurant
@reagent
reagent / gist:3100660
Created July 12, 2012 20:14 — forked from paulirish/gist:3098860
Open Conference Expectations

Open Conference Expectations

LOL

@reagent
reagent / gist:2645366
Created May 9, 2012 15:15
Grumble grumble...
class Breadcrumb
include ActionView::Helpers::TagHelper
def initialize
@crumbs = []
end
def append(name, link)
@crumbs << Breadcrumb::Crumb.new(name, link)
end
class Family < ActiveRecord::Base
def self.with_discontinued_accessories
joins(:products).where({
:products => {
:accessory => true,
:production_status => 'discontinued',
:active => true,
:parent_id => nil
}
@reagent
reagent / nav_link.rb
Created April 11, 2012 14:24 — forked from greypants/README.markdown
Versatile nav_link helper for adding 'selected' class to navigation elements
# module: audit2
class Audit < Thor
desc "all", "Run all audit tasks"
def all
%w(architecture database stats tests coverage flog roodi filesize queries).each do |task|
log "\n*** reviewing #{task}", true
log `thor audit:#{task}`, true
end
end
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/atom10full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:gd="http://schemas.google.com/g/2005" gd:etag="W/&quot;CkIASHw9cSp7ImA9WxdaGEg.&quot;"><id>tag:blogger.com,1999:blog-6867964</id><updated>2008-08-27T11:22:29.269-04:00</updated><title>idiosyncranomicon</title><subtitle type="html" /><link rel="alternate" type="text/html" href="http://idiosyncranomicon.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/6867964/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://idiosyncranomicon.blogspot.com/feeds/posts/default" /><author><name>Kevin</name><ema