Skip to content

Instantly share code, notes, and snippets.

View mikehale's full-sized avatar

Michael Hale mikehale

  • Heroku
  • Holly Springs, NC
View GitHub Profile
@mikehale
mikehale / dna.rb
Created May 9, 2009 02:37
dna.rb generates json, gets handed to chef-solo, makes box happy
require 'rubygems'
require 'json'
my_ssh_keys = [
'ssh-rsa blah1',
'ssh-rsa blah1'
]
other_guy_ssh_keys = [
'ssh-rsa blah1'
@mikehale
mikehale / Portfile
Created May 18, 2009 16:59
ruby-enterprise portfile
# $Id$
PortSystem 1.0
name ruby-enterprise
version 1.8.6-20090421
categories lang
maintainers Hongli Lai & Ninh Bui
description Ruby Enterprise Edition is a server-oriented friendly branch of Ruby.
homepage http://www.rubyenterpriseedition.com/
@mikehale
mikehale / slicehost.thor .rb
Created June 3, 2009 00:11
Thor file for working with slicehost
require 'activeresource'
class Slicehost < Thor
desc "list_zones", "list all the zones you have access to"
def list_zones
Zone.find(:all).each do |zone|
puts zone.origin
end
end
@mikehale
mikehale / database.rb
Created June 5, 2009 15:40
db:clone_to_local Thanks engineyard!
# require this file from your deploy.rb and you'll be able to db:clone_to_local
require 'eycap'
namespace :db do
task :yml do
set :database_yml, YAML.load(capture("cat #{shared_path}/config/database.yml"))[rails_env]
end
end
before "db:backup_name", "db:yml"
Feature: Setup my server
As an awesome rails coder
In order to host my rails application
I would like to have chef setup my server
Background
Given an ubuntu 9.04 server at slicehost
And my applications directory is /var/www/apps
Scenario: Setting up the server
require 'radiant/extension'
require 'method_observer'
module Radiant
class ExtensionLoader
class DependenciesObserver < MethodObserver
attr_accessor :config
def initialize(rails_config)

HOWTO: iPhone AT&T Tethering

In 10 steps:

  • Update iTunes to 8.2 via Software Update
  • Update your iPhone to the 3.0 release (out today - June 17th)
  • Download this dmg and mount it: tethering file
  • Enable hidden carrier testing option (in Terminal.app): defaults write com.apple.iTunes carrier-testing -bool TRUE
  • Start up iTunes
#!/bin/sh
# Print out what changed in a nice format.
git log @{1}.. --pretty=format:"%Cblue%an%Creset %ar: %Cred\"%s%b\"%Creset (%h)" --reverse
@mikehale
mikehale / passenger.rb
Created June 26, 2009 20:28
Passenger capistrano tasks
namespace :deploy do
[:start, :restart].each do |action|
task(action, :roles => :app) do
run "touch #{current_release}/tmp/restart.txt"
end
end
task(:stop, :roles => :app) {}
end
@mikehale
mikehale / database.yml.thor.rb
Created June 30, 2009 14:18
Generate your database.yml file with thor
class DatabaseYml < Thor
FILE = 'config/database.yml'
desc "mysql db_name", "create a database.yml for the named mysql database"
method_options :force => :boolean
def mysql(name)
yml = %(
env: &env
adapter: mysql
encoding: utf8