Created
August 21, 2008 20:05
-
-
Save jashmenn/6626 to your computer and use it in GitHub Desktop.
nate murray's .irbrc
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
# Nate Murray's ~/.irbrc | |
# | |
# Can be found at: | |
# http://gist.github.com/6626 | |
# git clone git://gist.github.com/6626.git gist-6626 | |
# | |
# Include colorization | |
require 'rubygems' | |
require 'wirble' | |
Wirble.init | |
Wirble.colorize | |
# Pretty Print | |
require 'pp' | |
# Auto Indentation | |
IRB.conf[:AUTO_INDENT]=true | |
# Readline-enable prompts. | |
require 'irb/ext/save-history' | |
IRB.conf[:USE_READLINE] = true | |
IRB.conf[:SAVE_HISTORY] = 1000 | |
IRB.conf[:HISTORY_PATH] = File::expand_path("~/.irb.history") | |
def enable_trace( event_regex = /^(call|return)/, class_regex = /IRB|Wirble|RubyLex|RubyToken/ ) | |
puts "Enabling method tracing with event regex #{event_regex.inspect} and class exclusion regex #{class_regex.inspect}" | |
set_trace_func Proc.new{|event, file, line, id, binding, classname| | |
printf "[%8s] %30s %30s (%s:%-2d)\n", event, id, classname, file, line if | |
event =~ event_regex and | |
classname.to_s !~ class_regex | |
} | |
return | |
end | |
def disable_trace | |
puts "Disabling method tracing" | |
set_trace_func nil | |
end | |
# clipboard code: http://project.ioni.st/post/1334#snippet_1334 | |
class MacClipboard | |
class << self | |
def read | |
IO.popen('pbpaste') {|clipboard| clipboard.read} | |
end | |
def write(stuff) | |
IO.popen('pbcopy', 'w+') {|clipboard| clipboard.write(stuff)} | |
end | |
end | |
end | |
# automate creating pasties | |
require 'net/http' | |
def pastie | |
url = | |
pastie_url = Net::HTTP.post_form(URI.parse("http://pastie.caboo.se/pastes/create"), | |
{"paste_parser" => "ruby", | |
"paste[authorization]" => "burger", | |
"paste[body]" => MacClipboard.read}).body.match(/href="([^\"]+)"/)[1] | |
MacClipboard.write(pastie_url) | |
system("open #{pastie_url}") | |
pastie_url | |
end | |
alias :pst :pastie | |
def products(sku, opts={}) | |
Product.find_by_sku(sku.to_s, opts) | |
end | |
def sites(short_name, opts={}) | |
Site.find_by_short_name(short_name.to_s, opts) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment