Skip to content

Instantly share code, notes, and snippets.

@sinisterchipmunk
sinisterchipmunk / autotest.rb
Created May 23, 2011 15:04
Quick-and-dirty autotest without installing Autotest
#!/usr/bin/env ruby
class Autotester
MONITOR_MATCH_PATTERN = "**/*.rb"
TEST_COMMAND = "rspec spec"
def cache
@cache ||= {}
end
@sinisterchipmunk
sinisterchipmunk / tree
Created April 18, 2011 10:05
I found myself having to construct a series of near-identical directory structures, and wanted a quick visualization of their contents. Was too lazy to open a file manager, and was happy for the excuse to code some Ruby. This was the result.
#!/usr/bin/env ruby
TAB_STOP = 2
$directories_only = false
$use_color = true
class Tree
attr_reader :word, :branches
@sinisterchipmunk
sinisterchipmunk / line
Created April 18, 2011 09:57
Very simple script to display a specified line in a file, plus the line immediately preceding and following it. I whipped this up as a quick solution to manually following a particularly vague stack trace from Jax (github.com/sinisterchipmunk/jax).
#!/usr/bin/env ruby
def fail(msg)
puts msg
puts
exit
end
fail "Usage: line [filename] [lineno]" if !ARGV[0] || !ARGV[1] || !File.file?(ARGV[0])