Skip to content

Instantly share code, notes, and snippets.

db_params = {
"adapter"=>"mysql",
"database"=>"#{application}_#{rails_env}",
"username"=>"root",
"password"=>"",
"host"=>"localhost",
"socket"=>""
}
db_params.each do |param, default_val|
@crofty
crofty / tag.rb
Created January 4, 2009 10:34
Script to tag mp3 releases using the discogs webservice.
require 'rubygems'
require 'id3lib'
require File.join(File.dirname(__FILE__),'discogs/lib/discogs.rb')
# Script to tag mp3 releases using the discogs webservice.
# It requires the discogs gem: git://github.com/crofty/discogs.git
# Usage:
# ruby tag release_folder
# Then, when prompted, give the discogs release number
# Installing Tokyo Cabinet on a slicehost slice
cd ~/src
wget http://tokyocabinet.sourceforge.net/tokyocabinet-1.4.23.tar.gz
tar xvzf tokyocabinet-1.4.23.tar.gz
cd tokyocabinet-1.4.23
./configure
make
sudo make install
wget http://tokyocabinet.sourceforge.net/rubypkg/tokyocabinet-ruby-1.25.tar.gz
# Capistrano task for importing database from production
require 'yaml'
desc "Copy the remote production database to the local development database"
task :backup, :roles => :db, :only => { :primary => true } do
filename = "#{application}.dump.#{Time.now.to_i}.sql.bz2"
file = "/tmp/#{filename}"
on_rollback { delete file }
get "#{current_path}/config/database.yml", "tmp/prod_database.yml"
@crofty
crofty / # Capistrano task for refreshing local db
Created July 8, 2009 19:48
Capistrano task for mysql refresh
# Capistrano task for refreshing local db
require 'yaml'
desc "Copy the remote production database to the local development database"
task :backup, :roles => :db, :only => { :primary => true } do
filename = "#{application}.dump.#{Time.now.to_i}.sql.bz2"
file = "/tmp/#{filename}"
on_rollback { delete file }
get "#{current_path}/config/database.yml", "tmp/prod_database.yml"
@crofty
crofty / Setting up munin
Created September 9, 2009 07:39
Munin setup on Slicehost
sudo apt-get install munin munin-node
# Edit the config file: sudo vim /etc/munin/munin.conf
dbdir /var/lib/munin/
htmldir /var/www/munin/
logdir /var/log/munin
rundir /var/run/munin/
[localhost.localdomain]
address 127.0.0.1
use_node_name yes
@crofty
crofty / Monit installation and config on slicehost
Created September 9, 2009 11:35
Monit installation and config on Slicehost
sudo apt-get install monit
# Edit config file, example below
sudo vim /etc/monit/monitrc
# Check config syntax
sudo monit -t
# When no syntax errors edit the /etc/default/monit file to startup=1
sudo vim /etc/default/monit
# Start the service with:
sudo /etc/init.d/monit start
@crofty
crofty / Apache mod rewrite
Created September 9, 2009 07:24
Apache URL rewrite
# Enabling URL rewriting with apache
sudo a2enmod rewrite
# Edit /etc/apache2/apache2.conf
RewriteEngine On
# Edit the vhosts in /etc/apache2/sites-available. e.g.
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule (.*) http://www.domain.com$1 [R=301,L]
@crofty
crofty / CouchDB setup on slicehost
Created September 9, 2009 15:22
CouchDB setup on Slicehost
sudo apt-get update
sudo aptitude install build-essential
sudo apt-get install libmozjs-dev libicu-dev libcurl4-openssl-dev erlang
mkdir ~/src
cd ~/src
wget http://apache.mirror.anlx.net/couchdb/0.9.1/apache-couchdb-0.9.1.tar.gz
tar zxvf apache-couchdb-0.9.1.tar.gz
cd apache-couchdb-0.9.1
./configure && make && sudo make install
@crofty
crofty / Postfix installation on slicehost
Created September 9, 2009 11:29
Postfix installation on slicehost
# check the hostname, needed as part of install
hostname -f
sudo apt-get install postfix telnet mailx
# test with
mail james@james.com