This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rails foo_name -m http://gist.github.com/93545.txt | |
# rake rails:template LOCATION=http://gist.github.com/93545.txt | |
# Delete unnecessary files | |
run "rm README" | |
run "rm public/index.html" | |
# Set up git repository | |
git :init | |
git :add => '.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra/metal' | |
class SinatraMetal < Sinatra::Base | |
include Sinatra::Metal | |
get '/sinatra' do | |
'hello sinatra!' | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ipd (dev)> Host.scoped(:conditions => { :enabled => true }).scoped(:conditions => ['free_ram > ?', 1024] ) | |
Host Load (0.3ms) SELECT * FROM "hosts" WHERE ((free_ram > 1024) AND ("hosts"."enabled" = 't')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rails_root = "/data/github/current" | |
20.times do |num| | |
God.watch do |w| | |
w.name = "dj-#{num}" | |
w.group = 'dj' | |
w.interval = 30.seconds | |
w.start = "rake -f #{rails_root}/Rakefile production jobs:work" | |
w.uid = 'git' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
# Lighter -- Campfire from the command line | |
# usage: ruby lighter.rb subdomain "Main Room" macournoyer@gmail ssl | |
require "rubygems" | |
require "tinder" | |
require "readline" | |
require "highline/import" | |
class Lighter | |
def initialize(room) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this script will migrate and reorganize a Paperclip attachments directory to utilize :id_partition | |
# Quickly put together by [email protected] | |
# Assumes that your images to migrate < 1 000 000 | |
# | |
# Usage: ruby paperclip_partition_id_migrate.rb TARGET_DIR=/path/to/attachments/:class/:style | |
require '/opt/ruby-enterprise/lib/ruby/1.8/fileutils.rb' | |
def add_leading_zeros(i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/ree/bin/ruby | |
# originally from http://griffin.oobleyboo.com/archive/ruby-enterprise-edition-gem-install-script/ | |
# | |
# Usage: | |
# | |
# $ sudo -s | |
# # OLD_GEM=/usr/bin/gem NEW_GEM=/opt/ree-whatever/bin/gem /opt/ree/bin/ruby ree_gem_reinstall.rb | |
# The command to run for your vanila Ruby 'gem' command | |
ENV['OLD_GEM'] ||= '/usr/bin/gem' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Surround a heredoc with quotes and you can continue the code on the same line: | |
render :status => 404, :text => <<-'EOH' and return unless setup | |
article not found<br/> | |
I, as a server, have failed<br/> | |
https? | |
EOH | |
Quotes also give you more freedom/creativity with the terminal ID: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task :ssh do | |
exec "ssh #{user}@#{roles[:app].servers.first}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
after "deploy:setup", "thinking_sphinx:shared_sphinx_folder" | |
after 'deploy:finalize_update', 'thinking_sphinx:symlink_indexes' | |
after 'deploy:restart', 'thinking_sphinx:restart' | |
namespace :thinking_sphinx do | |
task :symlink_indexes, :roles => [:app] do | |
run "ln -nfs #{shared_path}/db/sphinx #{latest_release}/db/sphinx" | |
end | |
task :restart do | |
configure |