Skip to content

Instantly share code, notes, and snippets.

@collinschaafsma
collinschaafsma / gist:2324360
Created April 7, 2012 01:11
Adding middleware with Railtie
module Foo
class Railtie < Rails::Railtie
initializer "foo.insert_middleware" do |app|
app.config.middleware.use "Foo::Middleware"
end
end
end
require "foo/railtie" if defined? Rails
@collinschaafsma
collinschaafsma / gist:2323523
Created April 6, 2012 22:22
Autoload an .env file in your zshell
# Put this in ~/.zshrc
chpwd() {
if [ -f ".env" ]; then source .env; fi
}
# Then make .env files in your project directories that look like this.
export S3_SECRET="<s3_secret>"
export S3_KEY="<s3_key>"
# Then add .env to ~/.gitignore
188 cd
189 sudo apt-get remove ffmpeg x264 libx264-dev yasm
190 sudo apt-get update
191 sudo apt-get install build-essential git-core checkinstall texi2html libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libvorbis-dev libx11-dev libxfixes-dev zlib1g-dev
192 cd
193 wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
194 tar xzvf yasm-1.2.0.tar.gz
195 cd yasm-1.2.0
196 ./configure
197 make
@collinschaafsma
collinschaafsma / gist:2308101
Created April 5, 2012 04:59
FFMPEG Setup
# Add speex, for Red5
brew edit ffmpeg
args << "--enable-libspeex" if Formula.factory('speex').installed?
brew install --use-gcc ffmpeg
# H.264 / ACC
ffmpeg -i video.flv -acodec libfaac -ab 19k -ar 16000 -vsync 1 -async 1 -r 25.0 -b 193k -vcodec libx264 -s 420x340 video.mp4
# VP8 / Vorbis
@collinschaafsma
collinschaafsma / gist:2279511
Last active October 2, 2015 16:49
Capistrano user setup for an EC2 ami
# On server
addgroup admin
adduser deployer --ingroup admin
# Locally
cat ~/.ssh/id_dsa.pub | ssh [email protected] 'mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys'
@collinschaafsma
collinschaafsma / gist:2270250
Created April 1, 2012 01:09
Red5 Ubunut 10.04 LTS Setup
sudo vim /etc/apt/sources.list
#add the following
deb http://us.archive.ubuntu.com/ubuntu/ lucid multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ lucid multiverse
deb http://us.archive.ubuntu.com/ubuntu/ lucid-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ lucid-updates multiverse
deb http://archive.canonical.com/ lucid partner
sudo apt-get update
sudo apt-get install java-package
@collinschaafsma
collinschaafsma / gist:2270221
Created April 1, 2012 01:03
Red5 init.d script
#!/bin/sh
#
# /etc/init.d/red5 -- startup script for the red5 server
#
# Based on the tomcat6 init script.
# Written by Miquel van Smoorenburg <[email protected]>.
# Modified for Ubuntu red5 by Fred Dixon <[email protected]>
# Modified for Debian GNU/Linux by Ian Murdock <[email protected]>.
# Modified for Tomcat by Stefan Gybas <[email protected]>.
# Modified for Tomcat6 by Thierry Carrez <[email protected]>.
@collinschaafsma
collinschaafsma / Resources for talk
Created February 28, 2012 18:24
Talk resources for: Stop putting every class in the models directory.
Example Rails app
https://github.com/collinschaafsma/loyd
Example Sinatra app
https://github.com/collinschaafsma/slimfit
Awesome talk by Uncle Bob.
http://confreaks.com/videos/759-rubymidwest2011-keynote-architecture-the-lost-years
Clean Code Book
@collinschaafsma
collinschaafsma / vim.rb
Created August 26, 2011 21:33 — forked from uasi/vim.rb
Vim formula for Homebrew
require 'formula'
class Vim < Formula
homepage 'http://www.vim.org/'
url 'ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2'
head 'https://vim.googlecode.com/hg/'
sha256 '5c5d5d6e07f1bbc49b6fe3906ff8a7e39b049928b68195b38e3e3d347100221d'
version '7.3.206'
def features; %w(tiny small normal big huge) end
class User < ActiveRecord::Base
has_and_belongs_to_many :employers
has_and_belongs_to_many :roles
end