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 Nav | |
def self.padded_selector(sel, max_len) | |
sel.ljust(max_len) | |
end | |
attr_accessor :id, :height, :items, :image | |
def initialize(attrs={}) | |
attrs.each { |k,v| send("#{k}=", v) } | |
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
# haml + liquid example | |
# | |
# James MacAulay 2009 | |
require 'rubygems' | |
require 'liquid' | |
require 'haml' | |
template = <<EOF |
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
# This is a mechanism we use often in our migrations. When we have a migration | |
# that hits every record of a large table, this looping mechanism takes the | |
# bite away from the migration. This allows us to be transactional in our | |
# migration while avoiding aggressive locking of the table. Ultimately | |
# allowing us to do migratory deployments even more frequently during high | |
# usage areas of the day. | |
# | |
# Further, some long migrations that we'd run over a weekend may exceed the | |
# max transaction time set on our MySQL server. Running smaller transactions | |
# avoids this sensible restriction. |
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
cd ~/Library/Application\ Support/Firefox | |
git init | |
git add . | |
git commit -m "Saving FF3 Profile." | |
git checkout -b ff3.5 | |
open /Applications/Firefox3.5 | |
(close Firefox3.5) | |
git commit -m "Saving FF3.5 Profile." | |
git checkout master | |
open /Applications/Firefox |
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
# Typical way of handling the email in the controller | |
class UsersController < ApplicationController | |
def create | |
@user = User.new params[:user] | |
UserMailer.deliver_welcome(@user) if @user.save | |
end | |
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 'fileutils' | |
def fail!(msg = "Failure!") | |
puts(msg) | |
exit(1) | |
end | |
REPOSITORY_URL = 'git://github.com/mxcl/homebrew.git' | |
PACKAGE_URL = 'http://github.com/mxcl/homebrew/tarball/master' |
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
- any character you use it will literally match it except special characters | |
^ $ ? . / \ [ ] { } ( ) + * - all the special characters that will need escaping if you don't want them to be special | |
// - regexp ruby class | |
Common Patterns (I authored) | |
/[\w+\.~-]+@[\w~-]+.[\w\.]+/ - match emails, conforms to RFC 3986 section 3.3 | |
/\+?(\d)?[-|\.|\s]?\(?(\d{3})\)?[-|\.|\s]?(\d{3})[-|\.|\s]?(\d{4})/ - match phone numbers, https://gist.github.com/1009331 | |
Strategies |
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
require 'spec_helper' | |
describe Candidate do | |
subject { Fabricate(:candidate, first_name: "Joe", last_name: "Doe") } | |
describe "#full_name" do | |
its(:full_name) { should == "Joe Doe" } | |
end | |
describe "#search" do |
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
{ | |
"name": "workshop-setup", | |
"version": "1.0.0", | |
"description": "This is the common setup script for most of my workshops", | |
"bin": "./setup.js" | |
} |