Skip to content

Instantly share code, notes, and snippets.

View brianhempel's full-sized avatar

Brian Hempel brianhempel

View GitHub Profile
@brianhempel
brianhempel / production.rb
Created June 22, 2012 19:10
Production deploy checks
# config/deploy/production.rb
# okay, this is to make sure I don't miss another deploy.
def abort_deploy
puts "Deploy aborted."
exit 1
end
unless `git show-ref heads/stable`.split[0] == `git show-ref heads/master`.split[0]
@brianhempel
brianhempel / retina_rails_benchmarks.txt
Created June 18, 2012 19:33
Retina MacBook Pro Rails Benchmarks (Mid-2012, 15-Inch)
$ time bundle exec cucumber features/admin/authentication.feature
MID-2007 15-INCH MACBOOK PRO
2.2 GHz Core 2 Duo 6GB 320GB 7200rpm HD
# Hot
startup 24.7s
total 28.4s
# Cold
startup 38.3s
total 43.3s
@brianhempel
brianhempel / id_rsa.pub
Created May 22, 2012 14:27
Brian Hempel's Public Key
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA1VmCogSSRe2/OWkNI1Be5IxLcr5iX2hlArqCqHPXqzqLP9DQeU93g1Ml0HpdLq2FRqIbWNDLMmULu9zzFqAQIqPfqwonLqjnH3TiiUv0gh9Dg+ePFkGU7FYGtD3EEvFoZEmlEoZC61HLYY0AcItDM2mRVWi4gWw9nJm7E0iZYUylaLxpQVxFDuqWg6CCgHj6GxMQ8IoQp5feuPCe9a70B9w8zqhhNOlKfIddxx2pcBU2gjHyVfslWr4WuRziuZ3nHmnleCawirLi4GyoWhEsGeKw0pDRfazZyVmLgOSF3gB1qxJddFmRHYZ6a9s4oMOdxf54C6j7hb9dKvoihMde2Q== brian@wads-3-229-75.resnet.mtu.edu
@brianhempel
brianhempel / mass_rename.rb
Created April 23, 2012 15:16
Script for mass renaming of files via Regexp
#!/usr/bin/env ruby
require 'fileutils'
if ARGV.size < 3
puts <<-USAGE
mass_rename [file1 file2 ...] <regexp> <replacement>
USAGE
end
@brianhempel
brianhempel / all_s3_objects.rb
Created March 21, 2012 15:21
List/fetch all objects in a bucket with AWS::S3 Ruby gem
# by default you only get 1000 objects at a time
# so you have to roll your own cursor
S3.connect!
objects = []
last_key = nil
begin
new_objects = AWS::S3::Bucket.objects(bucket_name, :marker => last_key)
objects += new_objects
@brianhempel
brianhempel / jumpstart.rb
Created January 30, 2012 14:44
Pseudo-shell with Rails application.rb and environment.rb already loaded--like spork but no DRB and speeds up rake commands and rails console in addition to tests
#!/usr/bin/env ruby
require 'benchmark'
if ARGV[0]
ENV['RAILS_ENV'] = %w{development test production staging}.find { |e| e[0] == ARGV[0][0] } || ARGV[0]
else
ENV['RAILS_ENV'] ='test'
end
@brianhempel
brianhempel / pivotal_stories.rb
Created January 18, 2012 00:38
Quick script to get recent story names/urls for easy pasting into time tracking
#!/usr/bin/env ruby
require 'rubygems'
# auto-install pivotal-tracker gem if not present
if Gem::Specification.find_all_by_name('pivotal-tracker').empty?
puts 'Installing pivotal-tracker gem...'
puts `gem install pivotal-tracker --no-ri --no-rdoc`
Gem.refresh
end
@brianhempel
brianhempel / 1.9.2-p290_require_speedup_easy_install.sh
Created January 6, 2012 16:04
Easy RVM install of Ruby 1.9.2-p290 with the require performance patch
#!/usr/bin/env bash
# from http://ihswebdesign.com/knowledge-base/installing-a-patched-ruby-192-for-faster-rails-startup/
echo "Downloading require performance patch from Stefan Kaes' rvm-patchsets repository..."
curl https://raw.github.com/skaes/rvm-patchsets/671f0e4e6487af7a252d86b59d645ee7beb849dd/patches/ruby/1.9.2/p290/railsexpress/05-load-performance-fix.patch > 1.9.2-p290_require_speedup.patch
echo "Installing ruby-1.9.2-p290-patched..."
rvm install 1.9.2-p290 --patch 1.9.2-p290_require_speedup.patch -n patched
class User
include MongoMapper::Document
def profile
person.profile
end
one :person, :class_name => 'Person', :foreign_key => :owner_id
end
@brianhempel
brianhempel / Gem List
Created February 25, 2011 22:29
gem list after running bundle
$ gem list
*** LOCAL GEMS ***
activemodel (3.0.4)
activesupport (3.0.4)
ansi (1.2.2)
bson (1.2.4)
bson_ext (1.2.3)
builder (2.1.2)