This file contains 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
# Program output: | |
# | |
# Chord: [0, 4, 7] | |
# [:major, [[0, :unison], [4, :third], [7, :fifth]]] | |
# [:minor, [[0, :unison], [3, :third], [8, :sixth]]] | |
# [:major, [[0, :unison], [5, :fourth], [9, :sixth]]] | |
# Chord: [0, 4, 7, 11] | |
# [:major, [[0, :unison], [4, :third], [7, :fifth], [11, :seventh]]] | |
# [:minor, [[0, :unison], [3, :third], [7, :fifth], [8, :sixth]]] | |
# [:major, [[0, :unison], [4, :third], [5, :fourth], [9, :sixth]]] |
This file contains 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 IRB::Irb | |
alias :original_prompt :prompt | |
def prompt(prompt, ltype, indent, line_no) | |
prompt = prompt.call if prompt.respond_to?(:call) | |
original_prompt(prompt, ltype, indent, line_no) | |
end | |
end | |
IRB.conf[:PROMPT_MODE] = :RAILS_ENV | |
IRB.conf[:PROMPT][:RAILS_ENV] = IRB.conf[:PROMPT][:CLASSIC].merge(:PROMPT_I => lambda { (defined?(Rails) ? "#{Rails.env} " : "") + "%N(%m):%03n:%i> " }) |
This file contains 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
#!/usr/bin/env ruby | |
require 'iconv' | |
require 'open-uri' | |
class String | |
COLORS = [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white] | |
def colorize(color) | |
value = case color | |
when Symbol |
This file contains 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
#!/usr/bin/env ruby | |
# Usage: | |
# runonupdate "spec spec/models/cat_spec.rb -O spec/spec.opts" app/models/cat.rb app/models/dog.rb | |
# | |
# This will run cat-specs whenever cat.rb or dog.rb is updated. | |
class RunOnUpdate | |
attr_reader :cmd | |
attr_reader :files |
This file contains 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 Multibench | |
def initialize | |
@benches = Hash.new { 0 } | |
end | |
def bench(title) | |
start = Time.now | |
yield.tap do | |
@benches[title] += Time.now - start | |
end |
This file contains 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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'pivotal-tracker' | |
class String | |
ANSI_COLORS = [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white] | |
def colorize(color) | |
num = ANSI_COLORS.index(color) or raise("Bad color #{ color }") | |
"\e[3#{ num }m" + self + "\e[0m" |
This file contains 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
#!/usr/bin/env ruby | |
if match = `git symbolic-ref HEAD 2> /dev/null`.split('/').last.to_s.match(/^(?:t|s)-?(\d+)$/) | |
message = File.read(ARGV.first) | |
message.gsub!("STORYID", "[##{ match[1] }]") | |
File.open(ARGV.first, 'w') do |f| | |
f.puts(message) | |
end | |
end |
This file contains 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 'rspec-expectations' | |
class RSpec::Expectations::Differ | |
def diff_as_object(a, b) | |
if a.is_a?(Time) && b.is_a?(Time) | |
minutes, seconds = (b - a).divmod(60) | |
hours, minutes = minutes.divmod(60) | |
Kernel.format(" %dh %dm %ds \nactual: %s\nexpected: %s", hours, minutes, seconds % 60, b.utc.to_s, a.utc.to_s) | |
else | |
super |
This file contains 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
ZSH_THEME_GIT_PROMPT_PREFIX=" %F{208}❨%F{220}" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%F{208}❩%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_DIRTY="%F{196}✻%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_CLEAN="" | |
PROMPT=$'%F{196}%M %F{202}%~%{$reset_color%}$(git_prompt_info)%{\e[%(?.32.31);1m%} ➔%{$reset_color%} ' |
This file contains 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 'formula' | |
class Vim < Formula | |
homepage 'http://www.vim.org/' | |
url 'ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2' | |
head 'https://vim.googlecode.com/hg/' | |
sha256 '5c5d5d6e07f1bbc49b6fe3906ff8a7e39b049928b68195b38e3e3d347100221d' | |
version '7.3.294' | |
def features; %w(tiny small normal big huge) end |