Skip to content

Instantly share code, notes, and snippets.

View monde's full-sized avatar
🐲

Mike Mondragon monde

🐲
  • Okta
View GitHub Profile
@monde
monde / gist:1134657
Created August 9, 2011 17:29 — forked from clarkware/gist:1046693
View Source for Ruby
# 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
require 'test/unit'
module M
def f
# WINNING
self.class::CONSTANT + 1
end
end
class C
# 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)
@monde
monde / .tmux.conf
Created November 1, 2010 19:06
my .tmux.conf
# 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
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
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
# 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")
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
# 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
@monde
monde / dirtygitprompt.sh
Created October 23, 2009 19:30
verbose dirty git prompt
# 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