Skip to content

Instantly share code, notes, and snippets.

View revans's full-sized avatar
🤠
Building Businesses

Robert Evans revans

🤠
Building Businesses
View GitHub Profile
@revans
revans / gist:1406
Created July 23, 2008 00:23
Merb Show Routes Task
desc "Show merb routes"
task :merb_routes => :merb_env do
require 'merb-core/rack/adapter/irb'
Merb::Rack::Console.new.show_routes
end
in environments/development.rb
Merb::BootLoader.before_app_loads do
DataMapper.setup(:default, 'mysql://user:demo@localhost/my_cool_app')
end
Merb::BootLoader.before_app_loads do
DataMapper.setup(:default, 'mysql://user:demo@localhost/app_db')
end
%w[net/http net/https uri ostruct rubygems json].each { |gem| require gem }
module HTTP
class UnSupportedFormat < StandardError; end
class UnAuthenticated < StandardError; end
MimeTypes = { :xml => "text/xml", :json => "application/json" }
def self.included(klass)
klass.extend ClassMethods
end
@revans
revans / submodules.rake
Created January 2, 2009 19:30
Managing Git Submodules in Rails
# This is used for updating all of our Submodules
# PLUGINS
#
# ==== Description
#
# Define your rails plugins here to be managed by git submodules.
#
#
@plugins = {
@revans
revans / Version Control API.rb
Created September 14, 2009 17:22
version control api for web frameworks
# VersionControl.rb
#
# This is version control agnostic. You can use git,
# mercurial, subversion, bazaar
class VersionControl
class << self
# Run a command with any version control
require 'rubygems'
require 'redis'
r = Redis.new
p 'set foo to "bar"'
r['foo'] = 'bar'
p 'value of foo'
p r['foo']
# Just drop this little diddy in your app to get some (not perfect) information on query times and such
# This will eventually become an official plugin but for those who can't wait, enjoy.
if defined?(NewRelic)
module MMNewRelicTracing
def self.included(model)
meths = %w[find find! paginate first last all count create create! update delete delete_all destroy destroy_all exists? find_by_id increment decrement set push push_all push_uniq pull pull_all]
model.metaclass.class_eval do
meths.each do |meth|
module Project
class Version
##
# The location of the version number file
# VERSION_FILE = File.join(Rails.root, 'config/build.version')
VERSION_FILE = File.join(File.dirname(__FILE__), 'build.version')
@@releases = %w[major minor point].freeze
##
@revans
revans / gemify_by_branch.rake
Created January 28, 2010 17:43
Build a gem, using jeweler, based on a branch.
desc "Install Gem based on a branch (e.g. rake gemify[master] or rake gemify)."
task :gemify, :branch do |task, args|
branch = args[:branch].nil? || args[:branch] == '' ? 'master' : args[:branch]
puts "Going to checkout the #{branch} branch and build the gem for it."
# run commands
`rm -rf package`
`git checkout master`
`git pull origin #{branch}`