This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# def initialize(attributes = {}) | |
Pirate.new :name => "Greenbeard", :ship => "The Queen Anne's Renegotiation" | |
# def has_many(of_what, options = {}) | |
has_many :crew_members, :class_name => "Pirate", :foreign_key => "captain_id" | |
# def validates_presence_of(*arrrrrgs) | |
validates_presence_of :parrot, :peg_leg, :blank => false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gem idea, extracted from ResourceFull. Thoughts on the API? | |
class User < ActiveRecord::Base | |
named_scope :born_after, lambda {|date| | |
{ :conditions => ["birthdate >= ?", Date.parse(date)] } | |
} | |
query_set :filter do | |
filter_with_scope :active | |
queryable_with :email |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Found on the ZshWiki | |
# http://zshwiki.org/home/config/prompt | |
# | |
# As lifted from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/ | |
function collapse_pwd { | |
echo $(pwd | sed -e "s,^$HOME,~,") | |
} | |
function prompt_char { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package proovy; | |
import groovy.xml.dom.DOMCategory | |
import org.lobobrowser.html.parser.* | |
import org.lobobrowser.html.test.* | |
import javax.xml.parsers.DocumentBuilderFactory | |
import javax.xml.xpath.XPathFactory | |
import javax.xml.xpath.XPathConstants | |
import css2xpath.* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
if ARGV.empty? | |
puts "Usage: gemmate <name-of-gem>" | |
else | |
src = `gem which #{ARGV[0]}`.split.last | |
lib_dir = src.slice 0, src.rindex("lib") | |
`mate -a '#{lib_dir}'` | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'nokogiri' | |
require 'open-uri' | |
UPS_URL = "http://wwwapps.ups.com/WebTracking/processRequest?AgreeToTermsAndConditions=yes&loc=en_US&tracknum=" | |
if ARGV.empty? | |
puts "Usage: ups_tracker tracking_number" and exit | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BlankHelper | |
include ActionView::Helpers::UrlHelper | |
include ActionView::Helpers::TagHelper | |
include ActionView::Helpers::TextHelper | |
include ActionView::Helpers::FormTagHelper | |
include ActionView::Helpers::CaptureHelper | |
include ActionView::Helpers::AssetTagHelper | |
attr_accessor_with_default :output_buffer, "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Give the stack a name, and describe its members. | |
stack = Awsymandias::EC2::ApplicationStack.new("test") do |s| | |
s.role "db", :instance_type => "m1.large", ... | |
s.role "app", :instance_type => "c1.xlarge", ... | |
end | |
# Check if we're running by pulling stack description from SDB; if not, launch asynchronously. | |
stack.launch unless stack.running? | |
until stack.running? | |
sleep(5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user should receive(username, name, firstName) andReturn("guybrush") | |
; is equivalent to | |
user should receive(username: "guybrush", name: "guybrush", firstName: "guybrush") | |
user should receive(reload, save) anyNumberOfTimes | |
; is equivalent to | |
user should receive(reload anyNumberOfTimes, save anyNumberOfTimes) | |
; is equivalent to | |
user should receive reload anyNumberOfTimes | |
user should receive save anyNumberOfTimes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user = mock! name andReturn("Guybrush", "Elaine", "LeChuck") | |
user name should == "Guybrush" | |
user name should == "Elaine" | |
user name should == "LeChuck" |