Skip to content

Instantly share code, notes, and snippets.

View czarneckid's full-sized avatar

David Czarnecki czarneckid

View GitHub Profile
@czarneckid
czarneckid / service
Created January 18, 2013 19:28 — forked from brentkirby/service
#!/bin/bash -e
#
# Since unicorn creates a new pid on restart/reload, it needs a little extra love to
# manage with runit. Instead of managing unicorn directly, we simply trap signal calls
# to the service and redirect them to unicorn directly.
#
# To make this work properly with RVM, you should create a wrapper for the app's gemset unicorn.
#
function is_unicorn_alive {
@czarneckid
czarneckid / gist:1536207
Created December 29, 2011 21:08
Installing older or specific versions of Homebrew formulas

We first want to take a look at what versions are installed for a given formula, brew info FORMULA. Let's take a look at the versions of Redis that are installed.

@czq. ➜  Formula rvm:() git:(master) brew info redis
redis 2.4.5
http://redis.io/
/usr/local/Cellar/redis/2.4.4 (9 files, 460K)
/usr/local/Cellar/redis/2.4.5 (9 files, 460K) *
...
@czarneckid
czarneckid / gist:1287184
Created October 14, 2011 13:58
Colorizing my BASH prompt
parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ →\ \1/'
}
export PS1='\[\e[1;37m\][\[\e[1;35m\]\u\[\e[1;37m\]@\[\e[1;32m\]\h\[\e[1;37m\]:\[\e[1;36m\]\w\[\e[1;33m\]$(parse_git_branch)\[\e[1;37m\]]$ \[\e[0m\]'
@czarneckid
czarneckid / Akismet.rb
Created September 2, 2011 17:54
The first Ruby I wrote. Yikes!
# Akismet
#
# Author:: David Czarnecki
# Copyright:: Copyright (c) 2005 - David Czarnecki
# License:: BSD
class Akismet
require 'net/HTTP'
require 'uri'
@czarneckid
czarneckid / gist:1166184
Created August 23, 2011 19:12
Enable warnings in irb as well using -W
dczarnecki-agora:~ dczarnecki$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]
dczarnecki-agora:~ dczarnecki$ irb -W
ruby-1.9.2-p180 :001 > def hello
ruby-1.9.2-p180 :002?> p 'world'
ruby-1.9.2-p180 :003?> end
=> nil
ruby-1.9.2-p180 :004 > hello
"world"
=> "world"
@czarneckid
czarneckid / gist:1078395
Created July 12, 2011 16:47
Straight up gangsta bundle aliases
alias bake='bundle exec rake'
alias baller='bundle install'
alias beatup='bundle exec rake db:migrate'
alias beatdown='bundle exec rake db:rollback'
baker () { bundle exec rake $@ ; }
Feature: MySQL
In order to support Ruby on Rails development
And avoid lost data resulting from system failure or incompetence
As a responsible system administrator
I want to ensure that our MySQL databases are running as expected
And that we have good slaves of the masters
And that our snapshotted backups are up to date
@critical
Scenario Outline: Ensure a MySQL master or read slaves is running
require 'rubygems'
require 'cucumber'
require 'cucumber/rake/task'
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "features --format pretty"
end
task :default => :test_rubies
desc "Runs tests on Ruby 1.8.7 and 1.9.2"
task :test_rubies do
system "rvm 1.8.7@tasty_gem,1.9.2@tasty_gem rake test"
end
rvm --create 1.8.7@tasty_gem
rvm --create 1.9.2@tasty_gem