Skip to content

Instantly share code, notes, and snippets.

View jamiew's full-sized avatar

Jamie Dubs jamiew

View GitHub Profile
@jamiew
jamiew / devise_http_rememberable.rb
Created April 30, 2011 04:54
Devise HTTP auth + rememberable monkeypatching attempts...
# Monkeypatch Devise so HTTP Basic auth remembers you!
# config/initializers/devise_http_rememberable.rb
# Try 1...
module Devise
module Hooks
module Rememberable
def remember_me?
STDERR.puts "******* Devise::Hooks::Rememberable.remember_me?"
true
@jamiew
jamiew / textmate_bundler_updater.sh
Created April 10, 2011 17:00
Updates the system-wide TextMate bundles + all your user bundles, with some notes for additions I want to make (e.g. subversion support in user bundles -- I have one that still uses svn)
#!/bin/bash
CORE_PATH="/Library/Application Support/TextMate/Bundles/"
USER_PATH="/Users/$(whoami)/Library/Application Support/TextMate/Bundles/"
echo "Updating core TextMate bundles..."
cd "${CORE_PATH}"
#svn up *.tmbundle
svn up
@jamiew
jamiew / config.ru
Created March 30, 2011 14:35
rails2.3 config.ru using rack_proctitle -- kept in lib/rack_proctitle.rb and loaded in config/environment.rb
ENV['RAILS_ENV'] = ENV['RACK_ENV']
require "config/environment"
use Rails::Rack::LogTailer
use Rails::Rack::Static
use Rack::ProcTitle
run ActionController::Dispatcher.new
@jamiew
jamiew / car_shopping.rb
Created March 8, 2011 05:09
Generate a CSV from a cars.com search result page
require 'rubygems'
require 'mechanize'
$agent = Mechanize.new
$agent.user_agent = "car_shopping.rb 001"
cars = []
def cars_from_url(url)
page = $agent.get(url)
(page/'.vehicleInfoColumn').map{|x|
@jamiew
jamiew / pimp_prompt.sh
Created January 21, 2011 17:55
put this in your .bashrc/.bash_profile... works with both git and svn
parse_git_branch() {
ref=$(git symbolic-ref -q HEAD 2> /dev/null) || return
printf "${1:-(%s)}" "${ref#refs/heads/}"
}
parse_svn_revision() {
local DIRTY REV=$(svn info 2>/dev/null | grep Revision | sed -e 's/Revision: //')
[ "$REV" ] || return
[ "$(svn st)" ] && DIRTY=' *'
echo "(r$REV$DIRTY)"
[user]
name = Jamie Wilkinson
email = [email protected]
[github]
user = jamiew
token = <REDACTED>
[apply]
whitespace = nowarn
[branch]
autosetuprebase = always
@jamiew
jamiew / branch.sh
Created October 25, 2010 20:02
Create a remote git branch & checkout locally (with tracking)
if [ -z $1 ]; then
echo STDERR "Usage: $0 [branchname]"
exit 1
fi
echo "Creating local+remote git branch: $1"
git push origin origin:refs/heads/$1
git fetch origin
git checkout -b $1 --track origin/$1
@jamiew
jamiew / unicorn.rb
Created October 14, 2010 17:58 — forked from jimmysoho/gist:534668
Unicorn config for use with bundler and capistrano - fixes issues with environment pollution.rb
# My pimped out unicorn config, with incremental killof
# and all the latest capistrano & bundler-proofing
# @jamiew :: http://github.com/jamiew
application = "000000book.com"
environment = ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'production'
app_path = "/srv/#{application}"
bundle_path = "#{app_path}/shared/bundle"
timeout 30
# *replaces* the deploy user's crontab with config/crontab.txt
# only does this on the *primary* :app server
role :app, "website.com", :primary => true
after "deploy:symlink", "deploy:crontab"
namespace :deploy do
desc "Install crontab"
task :crontab, :roles => :app, :only=>{:primary => true} do
@jamiew
jamiew / Unicorn capistrano deploy.rb
Created October 6, 2010 07:36
bundler, memcached, chef, log tailing and delayed job workers
# capistrano deployment
require "bundler/capistrano"
require "capistrano/ext/multistage"
set :stages, %w(canary production)
set :default_stage, "canary"
set :application, "lolcats"
set :deploy_to, "/srv/#{application}"