Skip to content

Instantly share code, notes, and snippets.

@thattommyhall
thattommyhall / john.rb
Created February 10, 2011 15:25
The AI for the ScroobyDoll
class John
def like_your_work
puts 'I like your work'
end
def x_your_face x
puts "I'll #{x} your face"
end
end
@thattommyhall
thattommyhall / create_contact.rb
Created February 16, 2011 23:27
Create a contact in FreeAgent using freeagent_api from https://github.com/aaronrussell/freeagent_api
require 'freeagent_api'
include Freeagent
Freeagent.authenticate({
:domain => 'tthuk.freeagentcentral.com',
:username => '[email protected]',
:password => 'NotMyRealPassword'})
Contact.new({ :first_name => 'Tom',
:last_name => 'Hall',
@thattommyhall
thattommyhall / sinatraHTML5
Created February 18, 2011 17:11
Getting Sinatra to output nice HTML5
configure do
set :haml, { :attr_wrapper => '"', :format => :html5 }
end
@thattommyhall
thattommyhall / sig-rescue-E.rb
Created February 24, 2011 16:37
Playing with signals in Ruby
puts "I have PID #{Process.pid}"
Signal.trap("USR1") {puts "prodded me"}
loop do
begin
puts "doing stuff"
sleep 10
rescue Exception => e
puts e.inspect
@thattommyhall
thattommyhall / hive.conf
Created March 9, 2011 18:22
Upstart script for hive
start on runlevel [2345]
stop on runlevel [06]
respawn
expect fork
script
export HOME="/home/deploy"
export JAVA_HOME="/usr/lib/jvm/java-6-sun"
export HIVE_HOME="/usr/lib/hive"
@thattommyhall
thattommyhall / deploy.rb
Created April 1, 2011 11:29
Testing before/after in Cap
def method_in_deploy
puts "METHOD IN DEPLOY"
end
task :task_in_deploy do
puts "TASK IN DEPLOY"
end
task :do_before do
puts "BEFORE"
@thattommyhall
thattommyhall / Output.txt
Created April 1, 2011 11:31
Why do the tasks in deploy get executed before the before stuff?
Tom-Halls-MacBook-Pro:hen-night-hq-facebook-app tomh$ cap deploy
METHOD IN DEPLOY
* executing `task_in_deploy'
TASK IN DEPLOY
* executing `deploy'
triggering before callbacks for `deploy'
* executing `do_before'
BEFORE
* executing `deploy:update'
** transaction: start
@thattommyhall
thattommyhall / fog_ELB.rb
Created April 1, 2011 12:09
lb_add and lb_remove take a list of dns_names and remove them from ELB
require 'fog'
ELB = Fog::AWS::ELB.new
COMPUTE = Fog::Compute.new( :provider => 'AWS')
def server_from_dns_name dns_name
COMPUTE.servers.all.find {|server| server.dns_name == dns_name}
end
def id_from_dns_name dns_name
@thattommyhall
thattommyhall / gist:953400
Created May 3, 2011 14:14 — forked from andykent/gist:925458
Nginx Upstart
description "nginx http daemon"
start on runlevel [2345]
stop on runlevel [!2345]
exec /opt/nginx/sbin/nginx -g "daemon off;"
respawn
@thattommyhall
thattommyhall / mongodb upstart.sh
Last active January 12, 2017 22:04
Automatically run --repair if necessary when starting MongoDB via Upstart
limit nofile 20000 20000
kill timeout 300
env MONGO_DATA=/var/lib/mongodb/
env MONGO_LOGS=/var/log/mongodb/
env MONGO_EXE=/usr/bin/mongod
env MONGO_CONF=/etc/mongodb.conf
pre-start script