gem install rails --pre
rails new my_app -T
# load a gem/lib into irb in a way that is durable to bundler LOAD_PATH | |
# hackery | |
# | |
# inspired by | |
# https://github.com/aniero/dotfiles/blob/master/irbrc#L4-35 | |
# | |
# IRB.gem('irbcp') | |
# IRB.gem('awesome_print', :lib => 'ap') | |
# |
# https://www.varnish-cache.org/docs/2.1/tutorial/vcl.html | |
# https://www.varnish-cache.org/trac/wiki/VCLExamples | |
# Summary | |
# 1. Varnish will poll the backend at /health_check to make sure it is | |
# healthy. If the backend goes down, varnish will server stale content | |
# from the cache for up to 1 hour. | |
# 2. Varnish will pass X-Forwarded-For headers through to the backend | |
# 3. Varnish will remove cookies from urls that match static content file | |
# extensions (jpg, gif, ...) |
cat /dev/null > /var/www/api/shared/log/god.log | |
cat /dev/null > /var/www/api/shared/log/nginx_access.log | |
cat /dev/null > /var/www/api/shared/log/unicorn.stderr.log | |
cat /dev/null > /var/www/api/shared/log/unicorn.stdout.log | |
cat /dev/null > /var/www/api/shared/log/resque.log | |
cat /dev/null > /var/www/api/shared/log/production.log | |
# resync logs | |
kill -s USR1 `ps -ef | sed -n '/unicorn_rails master/{/grep/!p;}' | awk '{print$2}'` | |
kill -s HUP `ps -ef | sed -n '/resque:scheduler/{/grep/!p;}' | awk '{print$2}'` |
" tmux will only forward escape sequences to the terminal if surrounded by a DCS sequence | |
" http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinkbdoZ8eNR1X2UobLTeww1jFrvfJxTMfKSq-L%2B%40mail.gmail.com&forum_name=tmux-users | |
if exists('$TMUX') | |
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\" | |
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\" | |
else | |
let &t_SI = "\<Esc>]50;CursorShape=1\x7" | |
let &t_EI = "\<Esc>]50;CursorShape=0\x7" | |
endif |
By default, Rails applications build URLs based on the primary key -- the id
column from the database. Imagine we have a Person
model and associated controller. We have a person record for Bob Martin
that has id
number 6
. The URL for his show page would be:
/people/6
But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6
here, is called the "slug". Let's look at a few ways to implement better slugs.
#!/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 |
#!/bin/bash | |
#################################### | |
# BASIC REQUIREMENTS | |
# http://graphite.wikidot.com/installation | |
# Forked from: http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/ | |
# Ubuntu 11.10 Oneiric Ocelot | |
# Forked from https://gist.github.com/1287170 | |
# Modified to use NGinx + uwsgi instead of Apache, as well as memcached and supervisord, incorporating ideas from | |
# http://blog.adku.com/2011/10/scalable-realtime-stats-with-graphite.html |
#!/bin/sh | |
export PATH=/bin:/usr/bin:/sbin:/usr/sbin | |
usage=$( | |
cat <<EOF | |
$0 [OPTIONS] start/stop | |
-s set speed default 256Kbit/s | |
-p set port default 3000 | |
-d set delay default 350ms |
#!/bin/sh | |
# | |
# Redirect stdin, stdout, stderr of a daemon to /dev/pts/# | |
# | |
################################################################################################################# | |
# Ref: stdio buffering: http://www.pixelbeat.org/programming/stdio_buffering/ | |
# Default Buffering modes: | |
# stdin -> is always buffered | |
# stderr -> is always unbuffered | |
# if stdout is a terminal then buffering is automatically set to line buffered, else it is set to buffered |