Skip to content

Instantly share code, notes, and snippets.

View portertech's full-sized avatar

Sean Porter portertech

View GitHub Profile
#!/bin/bash -xe
EBS_DEVICE='/dev/sdh'
INSTANCE_ID=$1
AKI=${2:-'aki-5f15f636'}
ARI=${3:-'ari-0915f660'}
ARCH=${4:-'i386'}
SIZE=${5:-10}
AZ=${6:-'us-east-1d'}
NAME=${7:-"ami-from-$INSTANCE_ID"}
require 'net/ftp'
load 'aws.rb'
def execute_ffmpeg(command)
progress = nil
IO.popen(command) do |pipe|
pipe.each("r") do |line|
if line =~ /Duration: (d{2}):(d{2}):(d{2}).(d{1})/
duration = (($1.to_i * 60 + $2.to_i) * 60 + $3.to_i) * 10 + $4.to_i
# Genenerate random passwords for beta users, save the results in a csv
require 'rubygems'
require 'digest'
require "mysql"
require 'fastercsv'
def generate_hash(string)
Digest::SHA1.hexdigest(string)
end
# Generate random password
def generate_passwd(len)
@portertech
portertech / tailable.rb
Created November 7, 2010 05:46
tailable cursor (MongoDB)
#!/usr/bin/ruby -w
require 'rubygems'
require 'mongo'
require 'thread'
include Mongo
db = Connection.new('localhost',27017,:slave_ok => true).db('test')
coll = db['cappedCollection']
sudo mkdir /usr/local
sudo chown -R $USER /usr/local
curl -Lsf http://github.com/mxcl/homebrew/tarball/master | tar xvz -C /usr/local --strip 1
brew install git
brew update
brew install wget
brew install mysql
brew install memcached
brew install postgres
brew install redis
brew install mongodb
mkdir -p ~/.rvm/src/ && cd ~/.rvm/src && rm -rf ./rvm/ && git clone --depth 1 git://github.com/wayneeseguin/rvm.git && cd rvm && ./install
if [[ -s /Users/YOUR_USERNAME/.rvm/scripts/rvm ]] ; then source /Users/YOUR_USERNAME/.rvm/scripts/rvm ; fi
rvm install 1.8.7
rvm install 1.9.2
rvm --default 1.9.2
ruby -v
which ruby
gem install rails
gzip on;
gzip_http_version 1.0;
gzip_proxied any;
gzip_buffers 16 8k;