Skip to content

Instantly share code, notes, and snippets.

View esmarkowski's full-sized avatar

Spencer Markowski esmarkowski

View GitHub Profile
@esmarkowski
esmarkowski / gitlab
Created July 28, 2012 02:23
Launch Gitlab Diff
#!/usr/bin/env sh
function gitlab {
if [ -z "$1" ]
then
echo "compare\nrepo\n"
else
case "$1" in
compare)
gitlab-compare "${@:2}"
git diff --name-status master..feature/distributed_redis | grep -E "^M"
def run_if_present( path )
puts "if [ -d #{path} ]; then #{yield self}; fi"
end
my_pid_file = "/somewhere/secret"
run_if_present my_pid_file do
"ls #{my_pid_file}"
end
@esmarkowski
esmarkowski / deploy.rb
Created November 11, 2011 03:02
Multi-Stage Capistrano Config with Gitflow and Tampon
set :keep_releases, 3
set :stages, %w(production staging)
require 'rainbow'
require 'capistrano/ext/multistage'
require 'capistrano/tampon'
require 'bundler/capistrano'
require 'thinking_sphinx/deploy/capistrano'
set :user, 'deploy'
# addressable.rb
module Schemata
module Schema
def addressable
apply_schema :street_address_1, String
apply_schema :street_address_2, String
apply_schema :city, String
apply_schema :state, String
apply_schema :zip_code, String
apply_schema :country, String
@esmarkowski
esmarkowski / Colorized Logger
Created January 24, 2011 21:27
beautiful colorized messages.
module ActiveSupport
class BufferedLogger
module Severity
COLORIZE = 10
end
include Severity
def add(severity, message = nil, progname = nil, &block)
return if @level > severity
message = (message || (block && block.call) || progname).to_s
message = "\e[0;45m#{message}\e[0;0m\n" if severity == 10
#seed.rb
plant :admin_users
#block syntax
plant :about_us do |seed|
seed.path = "db/seeds/some_folder"
end