Skip to content

Instantly share code, notes, and snippets.

View markburns's full-sized avatar
💭
👋

Mark Burns markburns

💭
👋
View GitHub Profile
@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: "[email protected]", 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
Failure/Error: Unable to find matching line from backtrace
NoMethodError:
undefined method `original_path_set' for nil:NilClass
# /Users/macmacmacmacmacmac/.rvm/gems/ruby-1.9.3-p0/gems/rspec-rails-2.8.1/lib/rspec/rails/view_rendering.rb:113:in `block (2 levels) in <module:ViewRendering>'
# /Users/mark/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:435:in `instance_eval'
# /Users/mark/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:435:in `instance_eval_with_rescue'
# /Users/mark/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:45:in `run_in'
# /Users/mark/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:80:in `block in run_all'
# /Users/mark/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:80:in `each'
# /Users/mark/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/hooks.rb:80:in `run_all'
@markburns
markburns / gist:2057236
Created March 17, 2012 09:57
railslove
curl -d "mike=why-you-no-fix-your-jobs-page-yet&check-this-out=\"curl -i http://railslove.com/jobs.json -H \"Accepts:application/json\"&from-mark=kthxbai" http://join-railslove.herokuapp.com/join
curl: (52) Empty reply from server
@markburns
markburns / integration_spec.rb
Created March 27, 2012 21:19
DCI and abstracting persistence
shop = Fabricate(:shop, business_hours: shop_hours)
shop_factory = Fabricate(:shop_factory)
def shop_factory.get id
Fabricate(:shop, id: id)
end
data_store = Fabricate(:data_store) do
shop_fetcher shop_factory
class RacistException < StandardError; end
class BeingADickException < StandardError; end
def say thing
raise RacistException if thing =~ /^I'm not racist but/
raise BeingADickException if thing =~ /^I don't mean to be a dick but/
puts thing
end
class Array
alias_method :old_first, :first
def first &block
if block_given?
detect &block
else
old_first
end
end
require 'rbconfig'
HOST_OS = RbConfig::CONFIG['host_os']
source 'http://rubygems.org'
gem 'split', :require => 'split/dashboard'
gem "rake"
gem 'mysql2', '~> 0.3'
gem 'rails', '3.2.2'
gem 'sqlite3'