Skip to content

Instantly share code, notes, and snippets.

@lusis
lusis / create_ebs.rb
Created December 2, 2010 06:58
Small script to setup ec2 instances and EBS volumes for my blog post series
# Create 4 volumes and attach them to hdb
%w[sdi sdj sdk sdl].each do |dev|
volume = AWS.volumes.new :device => "/dev/#{dev}", :size => 5, :availability_zone => hdb.availability_zone
volume.server = hdb
volume.save
end
class ApplicationController < ActionController::Base
...
# FORCE to implement content_for in controller
def view_context
super.tap do |view|
(@_content_for || {}).each do |name,content|
view.content_for name, content
end
end
end
@michiel
michiel / cors-nginx.conf
Created July 5, 2011 10:41
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@mattetti
mattetti / face_detector.rb
Created December 1, 2011 15:11 — forked from seanlilmateus/gist:1386468
Macruby Face Detection in Mac OS X Lion. Usage: $ macruby face_detector.rb or $ macruby face_detector.rb image_url
framework 'Cocoa'
class NSColor
def toCGColor
color_RGB = colorUsingColorSpaceName(NSCalibratedRGBColorSpace)
## approach #1
# components = Array.new(4){Pointer.new(:double)}
# color_RGB.getRed(components[0],
# green: components[1],
# blue: components[2],
@paulirish
paulirish / rAF.js
Last active March 22, 2024 00:00
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@rakhmad
rakhmad / clojure.md
Created April 17, 2012 15:55
Setting Up Clojure on OS X

Setting Up Clojure on OS X

I spent a lot of time trying to find a pretty optimal (for me) setup for Clojure… at the same time I was trying to dive in and learn it. This is never optimal; you shouldn't be fighting the environment while trying to learn something.

I feel like I went through a lot of pain searching Google, StackOverflow, blogs, and other sites for random tidbits of information and instructions.

This is a comprehensive "what I learned and what I ended up doing" that will hopefully be of use to others and act as a journal for myself if I ever have to do it again. I want to be very step-by-step and explain what's happening (and why) at each step.

Step 1: Getting Clojure (1.3)

@loopj
loopj / passenger-nginx-spdy.sh
Created August 5, 2012 20:21
Install passenger and nginx with SPDY support
#!/bin/sh
NGINX_VERSION=1.3.8
TMP_PATH=/tmp
# Fetch and extract Nginx
cd $TMP_PATH
wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz
tar xvfz nginx-$NGINX_VERSION.tar.gz
cd nginx-$NGINX_VERSION
@abeluck
abeluck / gpg-offline-master.md
Last active October 22, 2023 02:59 — forked from KenMacD/cmd.md
GPG Offline Master Key w/ smartcard
@subelsky
subelsky / puma_rails_heroku.rb
Created October 31, 2012 13:51
Setting up Puma and Rails on Heroku
# Gemfile
gem "puma"
# Procfile
web: bundle exec puma -p $PORT -e $RACK_ENV -C config/puma.rb
# add to config block config/environments/production.rb
config.threadsafe!
# get rid of NewRelic after_fork code, if you were doing this:
@bradediger
bradediger / carbon.rb
Created December 12, 2012 19:20
Homebrew formulae for graphite (carbon / whisper)
require 'formula'
class Carbon < Formula
homepage 'http://graphite.wikidot.com/'
url 'http://pypi.python.org/packages/source/c/carbon/carbon-0.9.10.tar.gz'
md5 '1d85d91fe220ec69c0db3037359b691a'
depends_on 'python'
depends_on 'twisted' => :python
depends_on 'whisper'