Skip to content

Instantly share code, notes, and snippets.

View fearoffish's full-sized avatar

Jamie van Dyke fearoffish

View GitHub Profile
require "rubygems"
require "mongo_mapper"
require 'benchmark'
count = 1000000
MongoMapper.connection = Mongo::Connection.new('localhost')
MongoMapper.database = 'benchmark'
class Person
require "rubygems"
require "benchmark"
require "dm-core"
count = 1000000
class Person
include DataMapper::Resource
property :id, Serial
ruby-1.8.7-p249 (master)✕ % rake -T
/Users/fearoffish/.rvm/gems/ruby-1.8.7-p249@retailjuice/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/core_ext/object/try.rb:29: [BUG] rb_add_method: unsupported method type (8)
ruby 1.9.2dev (2009-07-18 trunk 24186) [i386-darwin10.3.0]
-- control frame ----------
c:0057 p:---- s:0159 b:0159 l:000158 d:000158 CFUNC :alias_method
c:0056 p:0044 s:0154 b:0154 l:000153 d:000153 CLASS /Users/fearoffish/.rvm/gems/ruby-1.8.7-p249@retailjuice/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/acti
c:0055 p:0009 s:0152 b:0152 l:000151 d:000151 TOP /Users/fearoffish/.rvm/gems/ruby-1.8.7-p249@retailjuice/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/acti
c:0054 p:---- s:0150 b:0150 l
# AWESOME backtrace. Thank you!
NoMethodError (undefined method `object' for #<ArticlesController:0x1030abfa0>):
# The two lines above are the backtrace. Empty! :(
@fearoffish
fearoffish / see-all-oh-my-zsh-themes.sh
Created July 12, 2010 11:22
Open a new terminal for every oh-my-zsh theme
#!/usr/bin/env ruby
ZSHRC_FILENAME = File.expand_path("~/.zshrc")
ZSHRC_CONTENTS = File.read(ZSHRC_FILENAME)
THEMES = %x{ls ~/.oh-my-zsh/themes}.split(" ").collect {|t| t.gsub(".zsh-theme", "")}
ORIGINAL_THEME = ZSHRC_CONTENTS.scan(/export ZSH_THEME="(.*?)"/)[0].to_s
def change_theme_to(theme)
File.open(ZSHRC_FILENAME, 'w') {|f| f.write(ZSHRC_CONTENTS.gsub(/export ZSH_THEME="(.*?)"/, %[export ZSH_THEME="#{theme}"])) }
end
class Chef
class Recipe
def run_for_instance_role(*roles, &block)
roles.map! {|a| a.to_s }
if roles.include?(node[:instance_role])
block.call
end
end
end
end
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'
url = "http://bensbargains.net/rss.xml/0"
rss = Hpricot.XML(open(url))
links = rss.search("link")
task :env_1 do
role :web, '127.0.0.1'
role :app, '127.0.0.1'
role :db, '127.0.0.1', :primary => true
set :rails_env, 'production'
end
task :env_2 do
role :web, '127.0.0.1'
@fearoffish
fearoffish / open_ssh_terminals.rb
Created January 27, 2011 17:09
Used in conjunction with Opscode's knife, we can open new terminal tabs for every instance in a cluster of machines
# Requires Mac OS X and Opscode's Chef Platform
#
# So you use Opscode's knife tool (with Chef) and you use a naming convention for your instance node names:
# app1.testing.your-domain.com, db1.testing.your-domain.com etc.
#
# Then you can use this script with 'knife exec' to open a new terminal tab for each instance of that cluster,
# each of these tabs will open an ssh session to the machine.
#
# Run with:
# CLUSTER=testing knife open_ssh_terminals.rb

Start a feature branch based off the develop branch and do your changes.

git flow feature start some_new_things

Bump the version number of each cookbook you work on, major numbers are for api changes, minor numbers are for new features and release numbers are for bugfixes.

Environment files are where we control the version of cookbooks that run