Skip to content

Instantly share code, notes, and snippets.

View jasonrudolph's full-sized avatar

Jason Rudolph jasonrudolph

View GitHub Profile
namespace :db do
namespace :data do
desc "Load data into current environment"
task :load => [:environment, 'db:drop', 'db:create'] do
db = ActiveRecord::Base.configurations[RAILS_ENV]
%x( mysql -u #{db['username']} --password=#{db['password']} #{db['database']} < "#{RAILS_ROOT}/db/dump/data.sql" )
desc "Dump current database schema and data to file"
task :dump => :environment do
# Adapted from
# Grab a password out of the 1Password keychain...finding it by "name"
def password_for_hostname(name)
password_info = `security 2>&1 >/dev/null find-generic-password -gs passwords.Password:#{name} 1Password.keychain`
password = password_info.match(/\"\:\"(.+)\"\}\"/)[1] rescue nil
-- Separate your work email from your home email in
-- Sure, you can use separate mailboxes or smart mailboxes to separate
-- your mail, but sometimes you don’t even want to know that you have
-- new “home” mail while you’re at work (or vice versa). Sometimes you
-- want to work exclusively in one context, free from the distractions
-- of the other context: you don’t want to hear that "new mail" chime
-- for mail that belongs to other (non-active) contexts, and you don’t
-- want to see the "unread" count for mail in other (non-active)
-- contexts. Cue Jonathan Wise's "Mail Account Chooser" script.
after "deploy:restart", "deploy:tag_last_deploy"
namespace :deploy do
# see
task :tag_last_deploy do
set :tag_name, "deployed_to_#{rails_env}_#{timestamp_string_without_seconds}"
`git tag -a -m "Tagging deploy to #{rails_env} at #{timestamp_string_without_seconds}" #{tag_name} #{branch}`
`git push --tags`
puts "Tagged release with #{tag_name}."
# Put this in your .irbrc, and then type
# "some_object.my_methods" in an IRB session
# for less noisy exploration of what objects
# can do.
class Object
def my_methods
base_object = case self
when Class then
when Module then
#vim: ruby
# This script will import all your Mephisto comments into Disqus (http:/
# parts of it came from
# but instead of a blog-engine independent sinatra app we needed a mephisto-specific script that
# will just do the job :)
unless defined?(RAILS_ROOT)
puts "This is a Rails 'runner' script. Please run './script/runner path/to/disqus_import' inside your Mephisto directory"
# git
alias gl='git pull'
alias gp='git push'
alias gd='git diff | mate'
alias gdh='git diff HEAD | mate'
alias gc='git commit -v'
alias gca='git commit -v -a'
alias gcap='git commit -v -a && git push'
alias gb='git branch'
alias gba='git branch -a'
jasonrudolph /
Created October 23, 2011 13:56
"SOLID Object-Oriented Design" - Sandi Metz @ GoRuCo 2009

"SOLID Object-Oriented Design" by Sandi Metz @ GoRuCo 2009

Date: May 30, 2009

Video on


  • Design is all about dependencies
  • If you refer to something, you depend on it.
jasonrudolph / gist:1732424
Created February 3, 2012 20:48
Delete trailing whitespace from all files in current directory tree
find . -type f -print0 | xargs -0 sed -i '' -E "s/[[:space:]]*$//"