Skip to content

Instantly share code, notes, and snippets.

View brentkirby's full-sized avatar

Brent Kirby brentkirby

View GitHub Profile
@brentkirby
brentkirby / to_bool.rb
Created August 22, 2014 20:26
Boolean Coercion
class Fixnum
def to_bool
self == 1
end
end
def Float
def to_bool
self.to_i.to_bool
end
@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$})