Skip to content

Instantly share code, notes, and snippets.

@cmaitchison
cmaitchison / seqeul.rake
Created May 13, 2011 12:42 — forked from tommeier/seqeul.rake
Close postgres open connections before running test suite
task 'db:test:prepare' => :close_postgres_connections
task :close_postgres_connections => :environment do
#Kill any other open connections on the test db
db_adapter = defined?(::ActiveRecord::Base) ? ActiveRecord::Base.connection : nil
db_adapter ||= defined?(::Sequel::Model) ? ::Sequel::Model.db : nil
if Rails.env.test? && db_adapter
db_config = Rails.configuration.database_configuration[Rails.env].symbolize_keys
begin
@cmaitchison
cmaitchison / chef_solo_bootstrap.sh
Created May 7, 2012 22:34
Ubuntu 12.04 Chef-Solo bootstrap
#!/bin/bash -xe
#THIS SCRIPT MUST BE RUN AS ROOT
#Set locale
echo "export LANGUAGE=en_AU.UTF-8" > /tmp/locale
echo "export LANG=en_AU.UTF-8" >> /tmp/locale
echo "export LC_ALL=en_AU.UTF-8" >> /tmp/locale
cat /etc/bash.bashrc >> /tmp/locale
cp /tmp/locale /etc/bash.bashrc
@cmaitchison
cmaitchison / git-fetch-all.sh
Created June 15, 2012 00:23
git-fetch all repos beneath current directory
for repo in $(find . -name .git -type d)
do
echo $repo
GIT_DIR=$repo git fetch --all --quiet;
done
@cmaitchison
cmaitchison / chef_solo_bootstrap.sh
Created July 21, 2012 08:31
Ubuntu 12.04 Chef-Solo bootstrap (AWS)
#!/bin/bash -xe
#THIS SCRIPT MUST BE RUN AS ROOT
#configure SSH
SSH_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuwaDITgrsmxVvSJ+HEir4iW2eBb8XqB3wIxCWJwmhiB2S6MkdX1CFcj8boHL2RIYgKN0yiTCVlOdQFjhyRpnd8NbS0RW7753SE1hzkgOg+2e1B15lf1PCSD5OPWAtpb1eYlLcs6hns+yFhYCFeQrKLBL2/si8D8OcQcTR7BjjFQEWdhjl4cYiT68cr57yFT+c/f32ZTynEWukC2YIGMjJ1nACUOYF8CSp6RUrD2kY3C1Pb1Q5V3jwi0lhay4aF5AWp28hPVtYASBe2BrYXp8uErhnmWxgXNV19P0NSHE7TBXd9nXz/njI2SDP/p2N/vHquz/Ybxs4F+kGGXknUFitQ== cmaitchison@gmail.com"
echo $SSH_KEY >> /home/ubuntu/.ssh/authorized_keys
#configure locale
echo "export LANGUAGE=en_AU.UTF-8" > /tmp/locale
@cmaitchison
cmaitchison / chef_solo_bootstrap.sh
Created August 11, 2012 06:22
Ubuntu 12.04 Chef-Solo bootstrap (VPSBlocks)
#!/bin/bash -xe
#THIS SCRIPT MUST BE RUN AS ROOT
ADMIN_USER=admin
ADMIN_GROUP=admin
#add admin group
(cat /etc/group | grep -E '\b$ADMIN_GROUP\b') || sudo groupadd $ADMIN_GROUP
#add admin user
@cmaitchison
cmaitchison / chef_solo_bootstrap.sh
Created August 17, 2012 09:45
CentOS 6.3 Chef-Solo bootstrap (RackSpace)
#!/bin/bash -xe
#THIS SCRIPT MUST BE RUN AS ROOT
ADMIN_USER=admin
ADMIN_GROUP=admin
#add admin group
(cat /etc/group | grep -E '\b$ADMIN_GROUP\b') || sudo groupadd $ADMIN_GROUP
@cmaitchison
cmaitchison / chef_solo_bootstrap.sh
Created September 19, 2012 11:38
Ubuntu 12.04 Chef-solo bootstrap (Ninefold)
#!/bin/bash -xe
#THIS SCRIPT MUST BE RUN AS ROOT
ADMIN_USER=admin
ADMIN_GROUP=admin
#add admin group
(cat /etc/group | grep -E '\b$ADMIN_GROUP\b') || sudo groupadd $ADMIN_GROUP
#add admin user
@cmaitchison
cmaitchison / valid.rb
Created October 11, 2012 13:10 — forked from notahat/valid.rb
Testing fail?
# By leaning hard on the declarative nature of let(), you get to use
# a pattern where there is a single shared example whose
# expected result is defined at a lower level in the code.
# It is not really a pattern that is intuitive to everyone when
# they read this sort of code for the first time, so I am not about
# to claim it is better than other approaches, only different.
# There is no need for explicit tests to assert that the correct
# arguments are passed to the validators in this example, because
# if the arguments are not correct the doubles will not return the
@cmaitchison
cmaitchison / chef_server_bootstrap.sh
Created November 15, 2012 05:16
ubuntu 13.04 chef-server bootstrap (aws)
#!/bin/bash -xe
#THIS SCRIPT MUST BE RUN AS ROOT
#configure SSH
SSH_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuwaDITgrsmxVvSJ+HEir4iW2eBb8XqB3wIxCWJwmhiB2S6MkdX1CFcj8boHL2RIYgKN0yiTCVlOdQFjhyRpnd8NbS0RW7753SE1hzkgOg+2e1B15lf1PCSD5OPWAtpb1eYlLcs6hns+yFhYCFeQrKLBL2/si8D8OcQcTR7BjjFQEWdhjl4cYiT68cr57yFT+c/f32ZTynEWukC2YIGMjJ1nACUOYF8CSp6RUrD2kY3C1Pb1Q5V3jwi0lhay4aF5AWp28hPVtYASBe2BrYXp8uErhnmWxgXNV19P0NSHE7TBXd9nXz/njI2SDP/p2N/vHquz/Ybxs4F+kGGXknUFitQ== cmaitchison@gmail.com"
echo $SSH_KEY >> /home/ubuntu/.ssh/authorized_keys
#configure locale
echo "export LANGUAGE=en_AU.UTF-8" > /tmp/locale
@cmaitchison
cmaitchison / chef_client_baseline.sh
Last active October 12, 2015 20:29
Ubuntu 12.04 Chef-client baseline (AWS)
#!/bin/bash -xe
#THIS SCRIPT MUST BE RUN AS ROOT
#configure locale
echo "export LANGUAGE=en_AU.UTF-8" > /tmp/locale
echo "export LANG=en_AU.UTF-8" >> /tmp/locale
echo "export LC_ALL=en_AU.UTF-8" >> /tmp/locale
cat /etc/bash.bashrc >> /tmp/locale
cp /tmp/locale /etc/bash.bashrc