Skip to content

Instantly share code, notes, and snippets.

@baldowl
baldowl / app.rb
Created April 13, 2010 08:23
Heroku-Jekyll-Sinatra
before do
cache_control :public, :max_age => 31557600
end
get '/' do
send_file(File.join(settings.public, 'index.html'), :disposition => nil)
end
get '/*' do
send_file(File.join(settings.public, params[:splat]), :disposition => nil)
@baldowl
baldowl / .gitattributes
Created April 25, 2010 10:15
Setting up Git for Xcode
# Better to treat them as binary files.
*.pbxproj -crlf -diff -merge
*.pbxuser -crlf -diff -merge
*.xib -crlf -diff -merge
@baldowl
baldowl / thin_recipe.rb
Created June 9, 2010 06:44
Keep-alive vs. Mongrel; saved by Thin
set :thin_conf, "#{current_path}/config/thin_cluster.yml"
namespace :deploy do
%w(star stop restar).each do |action|
task action.to_sym, :roles => :app do
run "thin -c #{deploy_to}/current -C #{thin_conf} #{action}"
end
end
end
@baldowl
baldowl / Additions to rb_main.rb
Created June 17, 2010 06:17
Using Bundler08 Instead Of Standaloneify
require 'vendor/gems/environment'
Bundler.require_env
@baldowl
baldowl / god.rb
Created June 24, 2010 08:49 — forked from defunkt/god.rb
How to avoid untracked rake processes
rails_root = "/data/github/current"
20.times do |num|
God.watch do |w|
w.dir = rails_root
w.env = {'RAILS_ENV' => 'production'}
w.name = "dj-#{num}"
w.group = 'dj'
w.interval = 30.seconds
@baldowl
baldowl / Pinging Google with a POST request
Created September 17, 2010 06:22
Pinging Google With A Service Hook
curl -d "payload=testinggithubservicehooks" \
http://www.google.com/webmasters/tools/ping?sitemap=http%3A%2F%2Fwww.example.com%2Fsitemap.xml
@baldowl
baldowl / before_migrate.rb
Created November 8, 2010 08:48
Using Chef and Bundler Together
# Drop it in config/deploy/
#
# It's evaluated inside the deploy resource's context.
#
# It assumes Gemfile and Gemfile.lock are present and satisfy Bundler's
# requirements for the --deployment option.
current_release_directory = release_path
running_deploy_user = new_resource.user
bundler_depot = new_resource.shared_path + '/bundle'
@baldowl
baldowl / rack-test-default-host.rb
Created December 6, 2010 07:52
Coercing Cucumber And Webrat To Cooperate
Scenario: Deleting a user
When I go to the users page
And follow "Delete" for the 2nd user
Then I should be on the users page
And should not see "user2"
@baldowl
baldowl / gist:771629
Created January 9, 2011 12:05
Using OS X's Directory Service instead of /etc/hosts
# Adding a host record.
sudo dscl . -create /Hosts/www.example.com ip_address 10.1.2.3
# Removing that same host record.
sudo dscl . -delete /Hosts/www.example.com
@baldowl
baldowl / gist:796353
Created January 26, 2011 07:04
Interactive fog session: how to get a bunch of signed URLs for European buckets with fog 0.4.1
require 'active_support/time'
bucket = AWS.directories.select {|d| d.key == 'my_bucket'}
files = bucket.files.select {|f| f.content_length > 0 &&
f.key =~ %r{client-name.*\.zip}}
expiration = Time.now.next_month.end_of_month
signed_urls = files.map {|f| f.url(expiration)}
fixed_signed_url = signed_urls.map do |su|
su.sub(%r{s3\.(.*)/my_bucket}, "my_bucket.s3.#{$1}")
end