Skip to content

Instantly share code, notes, and snippets.

@stephenmckinney
stephenmckinney / .tmux.conf
Created December 3, 2012 20:47
Vim + Tmux + Mac OS X Clipboard (pbcopy) integration
# Mac OS X clipboard integration
set-option -g default-command "reattach-to-user-namespace -l zsh"
bind y run "tmux save-buffer - | reattach-to-user-namespace pbcopy"
# Optional keybindings: Enter Copy-mode and Copy and Paste sorta like Vim.
unbind [
bind Escape copy-mode
unbind p
bind p paste-buffer
bind -t vi-copy 'v' begin-selection
@stephenmckinney
stephenmckinney / github-markdown.css
Created November 25, 2012 22:24 — forked from theconektd/github.css
Github Markdown CSS - for Marked.app or similar
body {
color: #333333;
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px;
}
@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
@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 / 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;
#!/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 / 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"
@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 / 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: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