Skip to content

Instantly share code, notes, and snippets.

View kenn's full-sized avatar

Kenn Ejima kenn

View GitHub Profile
@mrrooijen
mrrooijen / Capistrano-Deployment-Recipe.rb
Created July 29, 2009 09:34
a "base" Capistrano Rails Deployment Recipe. Use it to deploy your Rails application. It is also easily expandable. So feel free to grab this Recipe and add your own tasks/customization!
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
# Drop this file in config/initializers to run your Rails project on Ruby 1.9.
# This is three separate monkey patches -- see comments in code below for the source of each.
# None of them are original to me, I just put them in one file for easily dropping into my Rails projects.
# Also see original sources for pros and cons of each patch. Most notably, the MySQL patch just assumes
# that everything in your database is stored as UTF-8. This was true for me, and there's a good chance it's
# true for you too, in which case this is a quick, practical solution to get you up and running on Ruby 1.9.
#
# Andre Lewis 1/2010
# encoding: utf-8
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
# You have to define Gemspec files for Rails 2.3 libraries. A commit bellow will help it:
# http://github.com/jpzwarte/rails/commit/55ede36d8907f481b18fcefa21d099f69ae9965b
# Load rails from github
git 'git://github.com/reallyenglish/rails.git', :branch => '2-3-re', :ref => '1760b049f43ba2ab32eb47fdc42f5638115aeb8a' do
%w(active_support active_record action_pack action_mailer active_resource).each { |lib| gem lib.sub(/_/,''), '2.3.8', :require=>lib}
gem 'rails', '2.3.8'
end
# Load rails from your local
# compl1.rb - Redis autocomplete example
# download female-names.txt from http://antirez.com/misc/female-names.txt
require 'rubygems'
require 'redis'
r = Redis.new
# Create the completion sorted set
if !r.exists(:compl)
@mhorbul
mhorbul / vagrant-centos-5.5.-postinstall.sh
Created March 29, 2011 22:55
postinstall.sh script for building CentOS 5.5 vagrant box with RVM
rpm -Uvh --force --nosignature --nodigest http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh --force --nosignature --nodigest http://download.elff.bravenet.com/5/i386/elff-release-5-3.noarch.rpm
yum install -y curl ftp rsync sudo time wget which git-core
yum install -y gcc bzip2 make kernel-devel-`uname -r`
yum install -y gcc-c++ zlib-devel openssl-devel readline-devel
yum erase -y wireless-tools gtk2 libX11 hicolor-icon-theme avahi freetype bitstream-vera-fonts
service vboxadd status 2>&1 >> /dev/null
if [ $? -eq 1 ]; then
:+1:
:-1:
:airplane:
:art:
:bear:
:beer:
:bike:
:bomb:
:book:
:bulb:
@jeremyroman
jeremyroman / sass_http.rb
Created July 28, 2011 15:54
An HTTP importer for Sass
# Additional caching and such might be helpful for performance.
# Sass's regeneration only on changed files should work as long as the server provides the Last-Modified header
require 'net/http'
require 'time'
require 'sass'
module Sass
module Importers
# Importer which issues HTTP requests
@shapeshed
shapeshed / unicorn
Created September 16, 2011 10:12
Unicorn / Monit setup
#!/bin/sh
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals
# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/path/to/your/app/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
ENVIRONMENT=production
@copiousfreetime
copiousfreetime / memstats.rb
Created November 15, 2011 03:06
useful info from /proc/[pid]/smaps
#!/usr/bin/env ruby
#------------------------------------------------------------------------------
# Aggregate Print useful information from /proc/[pid]/smaps
#
# pss - Roughly the amount of memory that is "really" being used by the pid
# swap - Amount of swap this process is currently using
#
# Reference:
# http://www.mjmwired.net/kernel/Documentation/filesystems/proc.txt#361