This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Toss this in your ~/.irbrc file for a convenient way | |
# to peruse Ruby source code in TextMate. This | |
# only works in Ruby 1.9! | |
# | |
# Use it in irb like so: | |
# | |
# >> require 'active_record' | |
# >> ActiveRecord::Base.source_for_method(:create) | |
class Object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
module M | |
def f | |
# WINNING | |
self.class::CONSTANT + 1 | |
end | |
end | |
class C |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# probably a bug with latest bundler, in config/application.rb | |
# needed to symbolize the rails env with latest bundler 1.0.8 and rails 3.0.3 to ensure | |
# bundler development and test groups are actually loaded | |
Bundler.require(:default, Rails.env.to_sym) if defined?(Bundler) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://github.com/dpc/homeskel/blob/master/.tmux.conf | |
# http://blog.hawkhost.com/2010/06/28/tmux-the-terminal-multiplexer/ | |
# http://blog.hawkhost.com/2010/07/02/tmux-%E2%80%93-the-terminal-multiplexer-part-2/ | |
# http://www.linuxized.com/2010/05/switching-from-gnu-screen-to-tmux/ | |
#set -g prefix C-a | |
unbind % | |
bind | split-window -h | |
unbind - | |
bind - split-window -v |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MailReceiver < ActionMailer::Base | |
# patch ActionMailer::Base to put a ActionMailer::Base#raw_email | |
# accessor on the created instance | |
class << self | |
alias :old_receive :receive | |
def receive(raw_email) | |
send(:define_method, :raw_email) { raw_email } | |
self.old_receive(raw_email) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mike@daisy 10059 ~/projects/libs/mail(master☭)$ rake --trace spec | |
(in /home/mike/projects/libs/mail) | |
** Invoke spec (first_time) | |
** Execute spec | |
/usr/local/lib/ruby/gems/1.8/gems/diff-lcs-1.1.2/lib/diff/lcs/hunk.rb:69: warning: method redefined; discarding old flag_context= | |
/usr/local/lib/ruby/1.8/pathname.rb:263: warning: `*' interpreted as argument prefix | |
/home/mike/.bundle/ruby/1.8/gems/bundler-0.9.26/lib/bundler.rb:72: warning: instance variable @setup not initialized | |
/home/mike/.bundle/ruby/1.8/gems/bundler-0.9.26/lib/bundler/runtime.rb:145: warning: method redefined; discarding old path | |
Running Specs under Ruby Version 1.8.7 | |
/home/mike/.bundle/ruby/1.8/gems/activesupport-2.3.8/lib/active_support/vendor.rb:32: warning: redefine normalize_translation_keys |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add this file as config/initializers/will_paginate_postgresql_count.rb | |
# in a Rails application | |
module WillPaginate | |
module Finder | |
module ClassMethods | |
# add '1=1' to paginate conditions as marker such that the select from the pg_class | |
# is used to approximate simple rows count, e.g. | |
# Foo.paginate(:page => params[:page], :conditions => "1=1") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test::Unit::TestCase | |
def self.should_route_glob(method, path, options) | |
unless options[:controller] | |
options[:controller] = self.name.gsub(/ControllerTest$/, '').tableize | |
end | |
options[:controller] = options[:controller].to_s | |
options[:action] = options[:action].to_s | |
populated_path = path.dup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# shoulda validation that a partial has been rendered by a view | |
class Test::Unit::TestCase | |
def self.should_render_partial(partial) | |
should "render partial #{partial.inspect}" do | |
assert_template :partial => partial.to_s | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# origin of work http://henrik.nyh.se/2008/12/git-dirty-prompt | |
function parse_git_dirty { | |
status=`git status 2> /dev/null` | |
dirty=` echo -n "${status}" 2> /dev/null | grep -q "Changed but not updated" 2> /dev/null; echo "$?"` | |
untracked=`echo -n "${status}" 2> /dev/null | grep -q "Untracked files" 2> /dev/null; echo "$?"` | |
ahead=` echo -n "${status}" 2> /dev/null | grep -q "Your branch is ahead of" 2> /dev/null; echo "$?"` | |
newfile=` echo -n "${status}" 2> /dev/null | grep -q "new file:" 2> /dev/null; echo "$?"` | |
renamed=` echo -n "${status}" 2> /dev/null | grep -q "renamed:" 2> /dev/null; echo "$?"` | |
bits='' | |
if [ "${dirty}" == "0" ]; then |