Skip to content

Instantly share code, notes, and snippets.

View jnewland's full-sized avatar

Jesse Newland jnewland

View GitHub Profile
# 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 => '.'
require 'sinatra/metal'
class SinatraMetal < Sinatra::Base
include Sinatra::Metal
get '/sinatra' do
'hello sinatra!'
end
end
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'))
@jnewland
jnewland / god.rb
Created June 9, 2009 17:44 — forked from defunkt/god.rb
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'
#! /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 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)
#!/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'
@jnewland
jnewland / gist:180570
Created September 3, 2009 22:16 — forked from mtodd/gist:180398
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:
task :ssh do
exec "ssh #{user}@#{roles[:app].servers.first}"
end
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