Skip to content

Instantly share code, notes, and snippets.

View bscott's full-sized avatar
🏠
Working from home

Brian Scott bscott

🏠
Working from home
View GitHub Profile
heroku config --long | ruby -pe "\$_ = \$_.gsub(/(\w+)\s+=> (.+)/, 'export \1=\2')" > /tmp/$$ && source /tmp/$$; rm /tmp/$$
@bscott
bscott / Redis-Installer.sh
Created April 28, 2011 19:38
Redis Installer Script
curl http://redis.googlecode.com/files/redis-2.0.4.tar.gz | tar zx
cd redis-2.0.4
make
sudo cp redis-server /usr/local/sbin
sudo cp redis-cli /usr/local/bin
sudo mkdir /var/lib/redis /etc/redis
sudo sed -e "s/^daemonize no$/daemonize yes/" -e "s/^dir \.\//dir \/var\/lib\/redis\//" -e "s/^loglevel debug$/loglevel notice/" -e "s/^logfile stdout$/logfile \/var\/log\/redis.log/" redis.conf > /etc/redis/redis.conf
curl -G https://gist.github.com/gists/257849/download | tar -zxO > redis-server
chmod u+x redis-server
mv redis-server /etc/init.d
@bscott
bscott / Redis-Installer.sh
Created November 9, 2011 18:38
Redis Installer Script
curl http://redis.googlecode.com/files/redis-2.4.2.tar.gz | tar zx
cd redis-2.4.2
make
sudo cp redis-server /usr/local/sbin
sudo cp redis-cli /usr/local/bin
sudo mkdir /var/lib/redis /etc/redis
sudo sed -e "s/^daemonize no$/daemonize yes/" -e "s/^dir \.\//dir \/var\/lib\/redis\//" -e "s/^loglevel debug$/loglevel notice/" -e "s/^logfile stdout$/logfile \/var\/log\/redis.log/" redis.conf > /etc/redis/redis.conf
curl -G https://gist.github.com/gists/257849/download | tar -zxO > redis-server
chmod u+x redis-server
mv redis-server /etc/init.d
@bscott
bscott / nagios stage
Created December 28, 2011 21:16
nagios_stage
class nagios {
include nagios::install, nagios::config, nagios::service
}
class cleanup {
tidy { "/etc/nagios3/hosts.d/"
}
}
import "definitions/*.pp"
class munin {}
class cleanup {
exec { "rm -rf /etc/munin/munin-conf.d/*" }
}
import "definitions/*.pp"
@bscott
bscott / storage.rb
Created January 13, 2012 17:06
def_items
def items
@lists.collect(&:items).flatten
end
def run_pg_fouine():
info = host_info[env.host_string]
db_name = info.tags.get('Name')
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 0/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
time.sleep(30)
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 500/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
run('tail -n 100000 /var/log/postgresql/postgresql-9.*-main.log > /tmp/pgfouine.txt')
run('gzip -f /tmp/pgfouine.txt')
@bscott
bscott / audible_test.rb
Created June 30, 2012 04:03
Chef minitest example
#!/usr/bin/ruby
require 'minitest/spec'
describe_recipe 'audible_magic::default' do
include MiniTest::Chef::Assertions
include MiniTest::Chef::Context
include MiniTest::Chef::Resources
@bscott
bscott / heroku_style_baby.rb
Created July 13, 2012 18:32 — forked from gilesbowkett/heroku_style_baby.rb
Heroku-style dev on EC2 || Slicehost || whatev
require 'rubygems'
require 'sinatra'
require 'json'
class GitHubUpdater
def self.update?(json)
(JSON.parse(json)["ref"] == "refs/heads/master")
end
@bscott
bscott / gist:4242705
Created December 9, 2012 00:24
Chef Testing Part 2.1 - validate-repository.
echo "Checking for Ruby syntax errors..."
find . \( -name *.rb -or -name Vagrantfile \) -exec echo "Checking syntax of {}" \; -exec ruby -c {} \;