Skip to content

Instantly share code, notes, and snippets.

@leeky
leeky / rules.md
Created January 27, 2014 14:59 — forked from henrik/rules.md
  1. Your class can be no longer than 100 lines of code.
  2. Your methods can be no longer than five lines of code.
  3. You can pass no more than four parameters and you can’t just make it one big hash.
  4. When a call comes into your Rails controller, you can only instantiate one object to do whatever it is that needs to be done.

You can break these rules if you can talk your pair into agreeing with you.

@leeky
leeky / gist:6714325
Last active December 24, 2015 00:08 — forked from rafaelss/gist:3700977
Upgrading PostgreSQL with Homebrew on OS X
Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. pg_ctl -D /usr/local/var/postgres stop -s -m fast
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. curl https://raw.github.com/fragility/homebrew/737af01178590950749cf5e841f2d086c57c5a80/Library/Formula/postgresql.rb > /usr/local/Library/Formula/postgresql.rb
4. brew upgrade postgresql
5. initdb /usr/local/var/postgres -E utf8
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
7. pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@leeky
leeky / pre-commit
Created April 26, 2013 14:14 — forked from Simbul/pre-commit
#!/usr/bin/env ruby
# This pre-commit hook will prevent any commit to forbidden branches
# (by default, "staging" and "production").
# Put this file in your local repo, in the .git/hooks folder
# and make sure it is executable.
# The name of the file *must* be "pre-commit" for Git to pick it up.
FORBIDDEN_BRANCHES = ["staging", "production"]
@leeky
leeky / chef_solo_bootstrap.sh
Created May 23, 2012 13:54 — forked from ryanb/chef_solo_bootstrap.sh
Bootstrap Chef Solo - Ubuntu 12.04 LTS
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar -xvzf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194/
./configure --prefix=/usr/local
make
make install
@leeky
leeky / gist:1212750
Created September 12, 2011 23:23 — forked from kevinprince/gist:1212725
badges in ruby
# Requires the following gems: prawn, barby and rqrcode
require "prawn"
require "prawn/measurement_extensions"
require "barby"
require "barby/barcode/code_128"
require "barby/outputter/prawn_outputter"
barcode = Barby::Code128.new('12345','A')
badge = Prawn::Document.new(:page_size => "A5", :page_layout => :landscape, :margin => 0) do |pdf|
#!/usr/bin/env ruby
def output_config
puts <<-END
graph_category App
graph_title passenger status
graph_vlabel count
sessions.label sessions
max.label max processes
@leeky
leeky / ghkey.rb
Created May 12, 2009 10:07 — forked from fcoury/ghkey.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'octopi'
require 'choice'
include Octopi
Choice.options do
header ''
@leeky
leeky / gist:61922
Created February 11, 2009 08:47 — forked from rails/gist:58761
var DateHelper = {
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time
// Ruby strftime: %b %d, %Y %H:%M:%S GMT
time_ago_in_words_with_parsing: function(from) {
var date = new Date;
date.setTime(Date.parse(from));
return this.time_ago_in_words(date);
},
time_ago_in_words: function(from) {