This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def path_to_attachment_image(attachment) | |
image_path("attachments/#{attachment.filename}") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If your workers are inactive for a long period of time, they'll lose | |
# their MySQL connection. | |
# | |
# This hack ensures we re-connect whenever a connection is | |
# lost. Because, really. why not? | |
# | |
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar) | |
# | |
# From: | |
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Continuously watch for changes and rebuild files" | |
task :livereload do | |
pids = `ps ax|grep ruby|grep livereload|awk '{ print $1 }'`.split | |
other_pids = pids.reject { |pid| Process.pid == pid.to_i } | |
system "kill #{other_pids.join(' ')} &> /dev/null" | |
system "nohup livereload &> /dev/null &" | |
require 'rubygems' | |
require 'fssm' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install script for Apache+REE+Passenger 3 on Ubuntu 10.04 64bit | |
# BEFORE: | |
# - Make sure you are logged as a non-root user that can sudo. | |
# - Add your key here: | |
SSH_KEY="ssh-rsa ..." | |
# Add key to admin user | |
mkdir -p .ssh && echo "$SSH_KEY" >> .ssh/authorized_keys || exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# blog post: http://blog.slashpoundbang.com/post/2613268281/changing-from-tz-database-identifiers-to-rails-friendly | |
{ | |
"Australia/Adelaide" => "Adelaide", | |
"Australia/Broken_Hill" => "Adelaide", | |
"America/Anchorage" => "Alaska", | |
"America/Juneau" => "Alaska", | |
"America/Nome" => "Alaska", | |
"America/Yakutat" => "Alaska", | |
"Pacific/Gambier" => "Alaska", | |
"Asia/Almaty" => "Almaty", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
// Change `silent` to true to invoke the promptless, self-closing | |
// version of the bookmarklet. | |
var silent = false; | |
var url = location.href; | |
var title = document.title; | |
// Look for a single hAtom entry on the page, and iff one is found, extract | |
// the entry-title in place of the document title: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Disable Google Maps scroll zoom in Google Chrome | |
// @namespace http://henrik.nyh.se | |
// @description Disables Google Maps scroll zoom because it's unusable with Apple's Magic Mouse. Confirmed to work in Google Chrome. | |
// @include http://maps.google.com/* | |
// ==/UserScript== | |
// Adapted from the Safari extension by Mario Tausch/Tiago Rodrigues (https://public.me.com/ix/mariotausch/dev/index.html) | |
// via http://www.leancrew.com/all-this/2011/05/the-google-maps-scrollzoom-confusion/. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# source iterm2.zsh | |
# iTerm2 tab color commands | |
# https://iterm2.com/documentation-escape-codes.html | |
if [[ -n "$ITERM_SESSION_ID" ]]; then | |
tab-color() { | |
echo -ne "\033]6;1;bg;red;brightness;$1\a" | |
echo -ne "\033]6;1;bg;green;brightness;$2\a" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rake deploy | |
> Executing deploy | |
> Executing deploy:update | |
> Executing deploy:update_code | |
> Executing deploy:finalize_update | |
> Executing bundle:install | |
> Executing link_config | |
> Executing link_files | |
> Executing build_assets | |
> Executing deploy:symlink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Used with: | |
# gem 'annotate', :git => 'git://github.com/ctran/annotate_models.git' | |
if Rails.env.development? | |
def after_task(task_name, &new_task) | |
old_task = Rake.application.instance_variable_get('@tasks').delete(task_name.to_s) | |
desc old_task.full_comment | |
task task_name do | |
old_task.invoke | |
new_task.call |
OlderNewer