Skip to content

Instantly share code, notes, and snippets.

@stephenmckinney
stephenmckinney / deploy.rb
Created February 10, 2012 16:37
Capistrano task to run South migrations and collect static media
after "deploy", "deploy:migrate", "deploy:static", "deploy:restart", "custom:git:tag"
namespace :deploy do
[:stop, :start, :restart, :reload].each do |action|
desc "#{action.to_s.capitalize} Apache."
task action, :roles => :app do
run "sudo /etc/init.d/apache2 #{action.to_s}"
end
end
@stephenmckinney
stephenmckinney / osx_developer_installation.md
Created February 26, 2012 11:51 — forked from stefanfoulis/osx_developer_installation.rst
Instructions on how to setup an OSX developer machine for (python/django/ruby/rails) development

OSX Developer System Installation

This guide assumes you are upgrading from Mac OSX 10.6 Snow Leopard to 10.7 Lion.


Starting Clean

Uninstall XCode

@stephenmckinney
stephenmckinney / gist:1932021
Created February 28, 2012 11:26
Installing Ruby 1.8.7 on Lion with only Command Line Tools for Xcode non-llvm gcc 4.2

Installing older Rubies (e.g. Ruby 1.8.7) on a clean install of Lion and Xcode

The latest Xcode and Command Line Tools for Xcode changes the default compiler from gcc to the llvm compiler. Only ruby-1.9.3-p125+ is LLVM ready. So, you will have to install gcc-4.2 to compile older versions of Ruby. More detail here https://github.com/mxcl/homebrew/wiki/Custom-GCC-and-cross-compilers.

This worked for me. I hope it saves some people time:

brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb
CC=/usr/local/bin/gcc-4.2 rvm install 1.8.7
@stephenmckinney
stephenmckinney / gist:2160434
Created March 22, 2012 17:31
Getting smush.py up on Ubuntu and compiling and patching pngnq
# install libs
sudo apt-get install gifsicle
sudo apt-get install imagemagick
sudo apt-get install pngcrush
sudo apt-get install libjpeg-progs
sudo apt-get install pkg-config
sudo apt-get install libpng-dev
# get smush.py
cd /var/apps/macarthur_cms_env/bin/
@stephenmckinney
stephenmckinney / gist:2497307
Created April 26, 2012 07:54
Replace broken images with placehold.it images with JQuery
<html>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("img").error(function(){
$(this).attr("src", function(){
size = ($(this).attr("width") + "x" + $(this).attr("height")).match(/\d+x\d+|\d+/i);
return "http://placehold.it/" + size;
});
@stephenmckinney
stephenmckinney / enable New Relic instrumentation
Created May 14, 2012 20:03
Installing mod_wsgi 3.3 for Python 2.6 on Ubuntu Lucid
cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/headers.load headers.load
...
sudo vim /etc/apache2/sites-enabled/000-default
# Used for New Relic instrumentation
RequestHeader add X-Queue-Start "%t"
#!/usr/bin/ruby
require 'time'
def format_time(seconds)
hours = (seconds / 3600).to_i
minutes = ((seconds % 3600) / 60).to_i
seconds = (seconds % 60).to_i
minutes = "0#{minutes}" if minutes < 10
seconds = "0#{seconds}" if seconds < 10
@stephenmckinney
stephenmckinney / default
Created July 25, 2012 19:28
Django Nginx Conf to fw HTTPS to HTTP
# Apache server
upstream django {
server 127.0.0.1:9000;
}
# Redirect all requests on the root subdomain to the www domain.
server {
listen 80;
server_name example.com;
rewrite ^(.*) http://www.example.com$1 permanent;
@stephenmckinney
stephenmckinney / gist:3630075
Created September 5, 2012 03:50
Bypass CDN for SSL requests in Rails
config.action_controller.asset_host = Proc.new do |source, request|
asset_config = YAML::load(File.open(File.join(Rails.root, "config/amazon_s3.yml")))[Rails.env]
if request.ssl?
return "https://#{asset_config['bucket_name']}"
else
return "http://#{asset_config['cdn_host']}"
end
end
@stephenmckinney
stephenmckinney / gist:3714689
Created September 13, 2012 14:33
Using Bundler binstubs when the rest of your team uses RVM gemsets
# Ignore RVM gemsets
echo "export rvm_ignore_gemsets_flag=1" >> ~/.rvmrc
# Activate RVM Bundler binstubs integration
chmod +x $rvm_path/hooks/after_cd_bundler
# Install bundle with binstubs
cd <project>
bundle install --binstubs
echo "bin/" >> .git/info/exclude