Skip to content

Instantly share code, notes, and snippets.

View ben-biddington's full-sized avatar

Ben Biddington ben-biddington

View GitHub Profile
@ben-biddington
ben-biddington / star_wars_cast.patch
Created September 23, 2010 04:58
Star Wars cast patch
--- star_wars_original_cast_list.txt 2010-09-23 16:55:05.880472400 +1200
+++ star_wars_actual_cast_list.txt 2010-09-23 16:55:08.513527400 +1200
@@ -8,10 +8,10 @@
Cast (in credits order) verified as complete
Mark Hamill Luke Skywalker
-Al Pacino Han Solo
+Harrison Ford Han Solo
def record_and_send(object, method, args, &block)
begin
result = object.send("__unlogged_#{method}", *args, &block)
ensure
@calls << { :object => object, :method => method, :args => args.clone, :result => result }
end
result
end
@ben-biddington
ben-biddington / git_mark.rb
Created October 15, 2010 03:04
Generates html from markdown that looks like it does on github
require 'rake'
desc 'Generates github-styled html from a markdown file and writes it to stdout'
task :preview_github_readme, :file do |_, args|
fail("Missing file argument") if args.file.nil?
fail("Missing file #{args.file}") unless File.exists?(args.file)
puts inject_github to_html(args.file)
end
def inject_github(html_text)
@ben-biddington
ben-biddington / the_matrix_cast.patch
Created October 17, 2010 21:07
The Matrix (1999) cast patch
--- the_matrix_original_cast_list.txt 2010-10-18 10:05:35.734461800 +1300
+++ the_matrix_actual_cast_list.txt 2010-10-18 10:05:38.670519100 +1300
@@ -1,22 +1,22 @@
The Matrix (1999)
Directed by
Andy Wachowski (as The Wachowski Brothers)
Lana Wachowski (as The Wachowski Brothers)
Writing credits
@ben-biddington
ben-biddington / man_to_html.sh
Created October 19, 2010 09:11
Convert a man page to HTML document
gzip -dc $(man -w grep) | man2html > man/grep.html
@ben-biddington
ben-biddington / how_to_manage_virtual_box_from_command_line.rb
Created October 22, 2010 09:01
Rake file for managing Virtual Box VMs
require 'rake'
InstallDir = 'C:/Program Files/Oracle/VirtualBox'
VBoxManage = File.join(InstallDir, '/VBoxManage.exe')
VBoxHeadless = File.join(InstallDir, '/VBoxHeadless.exe')
task :default do; puts %x{rake -f #{__FILE__} -sT}; end
desc "Print help"
task :help do
vbox_manage 'help'
@ben-biddington
ben-biddington / about_rake_tasks_arguments_and_env_spec.rb
Created November 10, 2010 08:29
Rake tasks may take their argument values from ENV if they're not supplied
require 'rake'
require 'spec'
describe 'About rake tasks, arguments and ENV' do
before(:each) do
ENV.delete('any_environment_variable')
Rake::Task.clear
end
it 'Argument may be satisfied from the ENV array if there is none explicitly supplied when invoked' do
@ben-biddington
ben-biddington / how_to_inherit_rspec_before_and_after_blocks.rb
Created December 2, 2010 01:23
How to implement common setup and teardown
module AcceptanceTest
def self.included(in_what)
in_what.class_eval do
before(:all) do
@something_heavy = Object.new
end
after(:all) do
@something_heavy.delete? if @something_heavy
end
@ben-biddington
ben-biddington / how_to_collect_rspec_test_run_results_all_day.rb
Created December 2, 2010 23:10
One way to collect rspec test run results all day
# spec_helper.rb
RSpec.configure do |config|
if ENV["RSPEC_WATCH_ME"]
config.after(:suite) do
time_formatter = Class.new(Object) do
include RSpec::Core::Formatters::Helpers
end.new
log_file = File.join Rails.root, 'log', "rspec-test-runs-#{Date.today.to_s}.txt"