Skip to content

Instantly share code, notes, and snippets.

View markburns's full-sized avatar
💭
👋

Mark Burns markburns

💭
👋
View GitHub Profile
@markburns
markburns / lsm.rb
Created March 23, 2010 20:16
#A very simple script to display rails migrations in alphabetic order
#!/usr/bin/ruby
#Util to show migrations in a nice to read format
#Highlights current version of db in red
#requires term-ansicolor gem
#usage - copy to your rails root, chmod +x lsm.rb , then ./lsm or ./lsm s to sort alphabetically
require 'date'
require 'rubygems'
require 'term/ansicolor'
include Term::ANSIColor
@markburns
markburns / markdown
Created March 23, 2010 21:40
Adapted script to preview markdown in a browser
#!/usr/bin/env ruby
#Adapted from http://pragmatig.wordpress.com/2009/06/17/quick-markdown-preview-for-github-readme/
#Added --firefox or -f parameter so that it won't open firefox each time, and you can just hit refresh instead.
raise "Usage:\nmarkdown <filename> [-f|--firefox]" unless ARGV[0]
require 'rubygems'
#e.g. rdiscount, gem install rdiscount (or any other bluecloth flavour...)
require 'markdown'
Building native extensions. This could take a while...
ERROR: Error installing bloopsaphone:
ERROR: Failed to build gem native extension.
/home/mark/.rvm/rubies/ruby-1.8.7-p249/bin/ruby extconf.rb
checking for main() in -lportaudio... yes
creating Makefile
make
gcc -I. -I. -I/home/mark/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/i686-linux -I. -D_FILE_OFFSET_BITS=64 -fPIC -g -O2 -I../../c -c bloopsaphone.c
@markburns
markburns / post-commit
Created November 17, 2010 17:56
Checks the spec and features directory for any "I debug", "show me the page" or "show_me_the_page" and prevents a commit if so
#!/usr/bin/env ruby
require 'rubygems'
begin
require 'term/ansicolor'
include Term::ANSIColor
rescue LoadError
puts "To get color from this post-commit hook install term/ansicolor"
%w[red blue green].each { |color| eval "def #{color} &blk; blk.call; end" }
end
After do |scenario|
save_and_open_page if scenario.status == :failed
end
@markburns
markburns / conundrum
Created December 22, 2010 08:01
Koch Snowflake area calculator
ruby-1.9.2-p0 > require './koch_snowflake'
=> true
ruby-1.9.2-p0 > k=KochSnowflake.new 5,514
=> #<KochSnowflake:0x97222e4 @iteration=514, @size=5>
ruby-1.9.2-p0 > k.area
=> NaN
ruby-1.9.2-p0 > k=KochSnowflake.new 5,513
=> #<KochSnowflake:0x977cc80 @iteration=513, @size=5>
ruby-1.9.2-p0 > k.area
=> 16.168975852600433
@markburns
markburns / .bashrc
Created June 13, 2011 09:53
.bashrc aliases
#git aliases
alias gs='git status'
alias gl='git log '
alias ga='git add '
alias gd='git diff --ignore-space-change '
alias gpl='git pull --rebase'
alias grc='git rebase --continue'
alias gpo='git push origin '
alias gb='git branch '
alias gf='git fetch '
@markburns
markburns / gist:1040856
Created June 22, 2011 19:09
trac import
require 'rubygems'
require 'ticketmaster'
require 'ticketmaster-pivotal'
require 'ticketmaster-trac'
require 'ruby-debug/debugger'
pivotal = TicketMaster.new(:pivotal, :username => 'test@example.com',:password => 'password' )
pivotal_project = pivotal.project(some_integer)
trac = TicketMaster.new(:trac, {:username=> 'username', :password => "password", :url => "http://example.com"})
show_line() {
default_context_lines=10
usage() {
echo "show_line <file> <line number> [number of context lines]"
echo "OR:"
echo "show_line <file>:<line number>[:<number of context lines>]"
echo
echo "Usage Examples:"
@markburns
markburns / Peering into Japanese and Korean strings
Created September 16, 2011 06:49
Method to help understand encoding issues in ruby 1.9
pry(main)> debug_string "今日は"
0xE4 228 1110 0100
0xBB 187 1011 1011
0x8A 138 1000 1010
0xE6 230 1110 0110
0x97 151 1001 0111