Skip to content

Instantly share code, notes, and snippets.

View cbartlett's full-sized avatar

Colin Bartlett cbartlett

View GitHub Profile
View shit.rb
Shoes.setup do
gem "mime-types"
gem "open4"
source ""
gem "mojombo-grit"
require 'mojombo-grit'
repo =
View novalentine.js
var banList = ["valentine", "Valentine", "Valentine's","Valentines","valentine's","valentines","v-day","V-day","V-Day","vday","Vday","VDay","VALENTINE","VALENTINE'S"];
var allUpdates = document.getElementsByTagName('h3');
for (phrases in banList) {
for (eachUpdate in allUpdates) {
if (allUpdates[eachUpdate].innerHTML.match(banList[phrases])) {
allUpdates[eachUpdate] = "none";
View gist:799418
Given /^that ([^"]*) has (\d+) ([^"]*)$/ do |parent, count, child|
parent = parent.gsub(/\W+/,'_').downcase.sub(/^_/, '')
parent_instance = instance_variable_get("@#{parent}")
child = child.gsub(/\W+/,'_').downcase
child_class = Fabrication::Support.class_for(child.singularize)
if child_class && !"#{parent}=")
parent = parent.pluralize
parent_instance = [parent_instance]
View config-initializers-setup_mail.rb
Mail.register_interceptor(StagingMailInterceptor) if Rails.env.staging? || Rails.env.acceptance?
cbartlett / gist:3698644
Created September 11, 2012 13:51
Kill whitespace!
View gist:3698644
find . -not \( -name .svn -prune -o -name .git -prune \) -type f -print0 | xargs -0 sed -i '' -E "s/[[:space:]]*$//"
cbartlett / gist:3700171
Created September 11, 2012 17:42
Better hash match
View gist:3700171
# I want to have better messaging, diffs, etc. here
RSpec::Matchers.define :include_hash do |expected|
match do |actual|
! {|k,v| actual[k] == v }.include?(false)
failure_message_for_should do |actual|
"expected that #{actual} would include all the key/values of #{expected}"
cbartlett / gist:3997549
Created November 1, 2012 23:36
git merge strategy
View gist:3997549
Pull in the latest commits:
$ git fetch
Rebase your branch on top of the remote master:
$ get rebase origin/master
Go back to master:
$ git checkout master
Fetch pulls down commits but doesn't apply them. So you need to put those commits on master:
cbartlett / gist:4008195
Created November 3, 2012 18:27
List remote branches by last updated date
View gist:4008195
for k in `git branch -r|awk '{print $1}'`;do echo `git show --pretty=format:"%Cgreen%ci %Cblue%cr %Cred%cn %Creset" $k|head -n 1`$k;done|sort -r