Skip to content

Instantly share code, notes, and snippets.

@etaque
etaque / .bashrc
Created July 8, 2009 21:53 — forked from defunkt/.bashrc
# $ tweet Hi mom!
#
# Put this in ~/.bashrc or wherever.
# If it doesn't work, make sure your ~/.netrc is right
#
# (Thanks to @anildigital and @grundprinzip for curl-fu)
function tweet {
curl -n -d status="$*" https://twitter.com/statuses/update.xml --insecure &> /dev/null
echo "tweet'd"
sudo usermod -g wanalab emilien
umask 002
git --bare --shared init
#!/usr/bin/env ruby
def output_config
puts <<-END
graph_category App
graph_title passenger status
graph_vlabel count
sessions.label sessions
max.label max processes
rescue_from ActionController::RoutingError,
ActionController::UnknownAction,
ActiveRecord::RecordNotFound,
ActionView::MissingTemplate,
ActionController::MethodNotAllowed,
WillPaginate::InvalidPage, :with => :route_not_found
protected
# 404
class Post < ActiveRecord::Base
# ...
def to_param
"#{id}-#{title.parameterize}"
end
end
"123".to_i #=> 123
"123-my-permalink".to_i #=> 123
Post.find("123-my-permalink") #=> success!
class ApplicationController < ActionController::Base
protected
def redirect_if_moved(record, param_key = :id)
redirect_to record, :status => 301 if record.to_param != params[param_key]
end
end
def redirect_if_moved(record, param_key = :id)
canonical = record.to_param
if canonical != params[param_key]
redirect_to(:overwrite_params => { param_key => canonical }, :status => 301)
end
end