Skip to content

Instantly share code, notes, and snippets.

@mipearson
mipearson / gist:1124371
Created August 4, 2011 02:24
Knock Knock!
"Knock Knock!"
Who's there?
...
...
...
"Ruby."
@mipearson
mipearson / linode_to_aws.md
Created August 7, 2011 14:10
Migration off of linode to AWS for thebonscotts.com

So, linode bailed (http://yfrog.com/kkrk4p) while I was in the middle of working on the band website (http://www.thebonscotts.com)

That annoyed me somewhat.

Here's what I did to move it off linode in under one hour (except for DNS TTLs, obvs):

  • logged in to my (already extant) AWS account
  • created an elastic IP
@mipearson
mipearson / nginx_status_codes.rb
Created August 15, 2011 12:44
Very simple munin plugin to graph nginx HTTP error codes
#!/usr/bin/env ruby
CODES = {
'400' => 'Bad Request',
'401' => 'Unauthorized',
'403' => 'Forbidden',
'404' => 'Not Found',
'405' => 'Method Not Allowed',
'406' => 'Not Acceptable',
'408' => 'Request Timeout',
@mipearson
mipearson / to_be_pushed.rb
Created August 18, 2011 00:31
find git repositories that are behind their current remote tracking branch
#!/usr/bin/env ruby
pwd = ARGV[0] || '.'
debug = ARGV[1] == '-d'
Dir[File.join(pwd, '**', '.git')].each do |repo|
repo.gsub!(/\.git$/, '')
$stderr.puts "in #{repo}" if debug
if `cd #{repo}; git status`.include?("Your branch is ahead of")
puts repo
@mipearson
mipearson / bootstrap_ubuntu_with_chef_solo.sh
Created August 20, 2011 14:34
After uploading chef cookbooks, install REE / Chef and run it on a virgin Ubuntu 10.04 instance
#!/bin/bash
set -e
set -v
wget http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise_1.8.7-2011.03_amd64_ubuntu10.04.deb
sudo dpkg -i ruby-enterprise_1.8.7-2011.03_amd64_ubuntu10.04.deb
sudo gem install rubygems-update -v 1.3.7
sudo update_rubygems
sudo apt-get install build-essential
@mipearson
mipearson / gist:1213178
Created September 13, 2011 05:20
File.exist? benchmark of existing / non existing file
ubuntu@localtest:~$ cat stat.rb
require 'benchmark'
puts Benchmark.measure {
1000000.times do
File.exist?(ARGV[0])
end
}
ubuntu@localtest:~$ ls -l foo
ls: cannot access foo: No such file or directory
@mipearson
mipearson / oops.sh
Created October 10, 2011 06:42
Oops! I committed this to the wrong branch in git!
# Oops! I committed this to the wrong branch.
# Here's how to fix without needing to do a messy git revert.
# Assumptions:
# * you have no uncommitted changes
# * you haven't pushed or pulled yet
# * you haven't made any further commits
DEST = bar # branch you intended to commit to
SRC = foo # branch you actually committed to
#!/usr/bin/env ruby
ROOT = '...'
EXTENSIONS = %w{html rb erb js css}
ignore = File.read(ROOT + '/.gitignore').split("\n").map {|a| "-not -path '#{a}'"}.join(' ')
if ARGV[0] == 'config'
puts "graph_title Code Metric - Line Count"
@mipearson
mipearson / debra.sh
Created November 3, 2011 05:07
A condensed example of using Debra to build sphinxsearch
# A condensed example of using Debra (http://rcrowley.org/articles/packaging.html)
# to build sphinx-2.0.1-beta1
# First, Install debra as at http://rcrowley.github.com/debra/
wget http://sphinxsearch.com/files/sphinx-2.0.1-beta.tar.gz
debra sourceinstall sphinxsearch sphinx-2.0.1-beta.tar.gz -p /usr
debra create sphinxsearch control
vim sphinxsearch/DEBIAN/control # set package name, version, architecture
debra build sphinxsearch sphinxsearch_2.0.1-beta1_x64_86.deb
@mipearson
mipearson / contracting.md
Created November 9, 2011 06:05 — forked from mwotton/gist:1350517
Nicholas F on Contracting Rates

How to calculate an hourly rate.

Hi,

I've been watching job boards for Ruby related contracts lately and have noticed some low rates being offered with high expectations. It's happening frequently enough that I wanted to post my understanding of how to calculate an hourly rate. Setting reasonable standards of pay for the appropriate level of expertise is vital. There's a lot to say on the matter, so I've tried to be brief.

For some reason it's very easy for software developers to match their experience and knowledge to a full-time rate, but for contracting there is less awareness.

The difference between full-time employment and self employment.