Skip to content

Instantly share code, notes, and snippets.

View brentkirby's full-sized avatar

Brent Kirby brentkirby

View GitHub Profile
@brentkirby
brentkirby / Guardfile
Created May 6, 2011 18:55
guardfile for speccing out a minitest guard
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
require 'guard/guard'
module ::Guard
class Minitest < ::Guard::Guard
def run_all
true
end
@brentkirby
brentkirby / runner.rb
Created May 7, 2011 17:34
minitest runner for specdoc style output
require 'rubygems'
require 'minitest/unit'
require 'colored'
module MiniTest
class SpecRunner < Unit
def before_suites
super if defined?(super)
end
@brentkirby
brentkirby / deathbob_1.rb
Created May 12, 2011 02:27
Random examples
class Bob
def self.blocky
yield
end
end
module Death
def call_blocky
Bob.blocky do
puts self
@brentkirby
brentkirby / i_like_this_but_not_facebook.rb
Created May 18, 2011 19:11
like button helper for bobbers
def facebook_like_button
"<iframe src='http://www.facebook.com/plugins/like.php?href=#{request.url}&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=35' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:450px; height:35px;' allowTransparency='true'></iframe>"
end
@brentkirby
brentkirby / _compat.scss
Created May 19, 2011 02:23
Compass/Blueprint/Sprockets Starter Files
/*
Include browser-specific css here. This file should be included in the main css file as well as ie.css.
This way PIE can apply itself to any css3 items that have been used.
add @import pie_option; to allow SASS to toggle it on for IE and off for everyone else.
*/
@brentkirby
brentkirby / includes._setup.css.scss
Created June 11, 2011 20:40
compass rails 3.1rc4
// File is in /app/stylesheets/includes/_setup.css.scss
////////////////////////////////////////////////
// Import Blueprint defaults
////////////////////////////////////////////////
@import "blueprint/grid";
@import "blueprint/typography";
@import "blueprint/form";
@import "blueprint/interaction";
@import "blueprint/debug";
@brentkirby
brentkirby / unicorn.rb
Created June 15, 2011 04:45
Unicorn / Nginx / RVM
RAILS_ROOT = ENV['RAILS_ROOT'] || File.expand_path(File.dirname(File.dirname(__FILE__)))
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! RAILS_ROOT
rescue LoadError
@brentkirby
brentkirby / service
Created June 22, 2011 08:50
Unicorn + Runit + RVM
#!/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 {
@brentkirby
brentkirby / Guardfile
Created June 23, 2011 21:25
Guard + Rspec + Spork
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'rspec', :version => 2,
:cli => '--colour --drb --format documentation --fail-fast',
:all_after_pass => false,
:all_on_start => false,
:keep_failed => false,
:notify => true do
watch(%r{^spec/.+_spec\.rb$})
@brentkirby
brentkirby / AnyMailer.rb
Created June 28, 2011 15:07
Tiny resque mail worker setup that removes Rail's stupid dependencies so we can delay messages without the whole rails env. (used w mongo fork)
require 'zlib'
class AnyMailer < ActionMailer::Base
def enqueue(method, *args)
message = self.send(method, *args)
Resque.enqueue(MailWorker, message: compressed_msg(message))
end