Skip to content

Instantly share code, notes, and snippets.

@weavenet
weavenet / gist:1524036
Created December 27, 2011 15:35
Disable DNS lookup when starting WEBrick
#!/bin/bash
if [ `whoami` != "root" ]; then
echo "$0 must be run as root."
exit 1
fi
for i in $(locate webrick/config.rb); do
echo "Processing $i"
sed -e 's/^.*:DoNotReverseLookup => nil,$/:DoNotReverseLookup => true,/' $i > /tmp/config.rb
@weavenet
weavenet / gist:1524092
Created December 27, 2011 15:50
Quick github repo backup script
#!/bin/bash
# Script to backup git repo to S3
# Set bucket, dir, password and account to use for the backup. I keep mine in local env vars
# These are set by localrc which lives on an encrypted home directory and is executed by my bashrc
bucket=$GITHUB_BACKUP_BUCKET
dir=$GITHUB_BACKUP_DIR
password=$GITHUB_BACKUP_PASSWORD
account=$GITHUB_ACCOUNT
@weavenet
weavenet / gist:1540224
Created December 30, 2011 15:02
Convert M4A files across multiple directories to MP3s using faad & lame
#!/bin/bash
find /tmp -name '* *' | while read filename; do
echo "Converting:$filename"
faad -o - "$filename" | lame - "${filename%.m4a}.mp3"
done
@weavenet
weavenet / gist:1543197
Created December 31, 2011 07:07
Configure Rails 3.1.X to use HAML, rspec andfactory girl
Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.1.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
@weavenet
weavenet / metadata -> ec2
Created January 6, 2012 15:51
Posting Metadata for Asynchronous EC2 Instance Bootstrapping Consumption
Start an instance and specify the metadata with -d.
# ec2-run-instances --region us-east-1 -key 'key' --instance-type 'm1.large' ami-1927f370 -d 'this is the data I need'
RESERVATION r-67bdc406 608324328795 default
INSTANCE i-5ad9aa38 ami-1927f370 pending weaver 0 m1.large 2012-01-06T15:44:47+0000 us-east-1b aki-08ed0761 monitoring-disabled ebs paravirtual xen sg-357c745c default
Retrieve the instance hostname.
# ec2-describe-instances --region us-east-1 i-5ad9aa38 | grep ^INSTANCE | awk {'print $4'}
@weavenet
weavenet / rc.local
Created January 6, 2012 20:58
Custom rc.local for RHEL5 to create ec2-user, enable full sudo and execute user-data on first boot
#!/bin/sh
#
# Modified by bweaver to add root key to ea user
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
@weavenet
weavenet / gist:1572391
Created January 6, 2012 21:03
Script to cleanup RHEL5 instance before creating AMI
#!/bin/bash
USER=ec2-user
echo 'Removing host keys'
sudo /bin/rm -rf /etc/ssh/ssh_host*_key*
echo 'Removing ec2-user'
userdel -f $USER ; /bin/rm -rf /home/$USER
@weavenet
weavenet / gist:1595238
Created January 11, 2012 15:42
Script To Remove Non Whitelists RPMs
#!/bin/bash
whitelist=ami_rpm_whitelist.txt
# List rpms to installed rpmts
rpm -q -a > /tmp/installed_rpms
# create white list file of rpms installed on the given whitelist
for i in `cat $whitelist |tr -d '\r'`; do
egrep ^$i /tmp/installed_rpms
@weavenet
weavenet / gist:1597127
Created January 11, 2012 22:20
Build Ruby 1.8.7p174 RPM on RHEL5u6 using FPM
#!/bin/bash
# Fucking umask!!!
umask 022
# Install epel yum repo
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
# Install deps for ruby build
yum install -y gcc rpm-build readline-devel.x86_64 libffi-devel.x86_64 libyaml-devel.x86_64 zlib-devel.x86_64 openssl-devel.x86_64 wget
@weavenet
weavenet / gist:1601349
Created January 12, 2012 16:09
Build Image Magick RPM on RHEL5 using FPM
#!/bin/bash
# Fucking umask!!!
umask 022
# Get image magic source
cd /var/tmp
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
# Extract source