Skip to content

Instantly share code, notes, and snippets.

View markburns's full-sized avatar
💭
👋

Mark Burns markburns

💭
👋
View GitHub Profile
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
@markburns
markburns / config_environments_test.rb
Created November 3, 2011 21:10
Using spork and reloading classes in rspec, but defaulting to cached_classes
config.cache_classes = ENV['RELOAD_CLASSES'].blank?
@markburns
markburns / frequency_counter.rb
Created November 11, 2011 10:04
When navigating vim with t/f it's useful to think about frequency of characters (choose rare ones to navigate to)
#frequency counter
#adds each character in ruby files to a hash incrementing a counter
#outputs list in reverse order. least frequent first
#Usage
#ruby frequency_counter.rb FILE1 [FILE2 FILE3... etc]
characters = Hash.new(0)
ARGV.each do |file|
content = File.read file
twitter = Hateoas.site "api.twitter.com"
twitter.actions
# => [sign_in: {method: :get}]
twitter.sign_in user: "mark@example.com", password: "password"
twitter.actions
# => [read_messages: {method: :get}, tweet: {method: :post}]
#encoding: utf-8
あけまして =
class A
class << self
alias おめでとう instance_eval
def ございます e; puts e; end
end
self
end