Skip to content

Instantly share code, notes, and snippets.

@georgel
georgel / comet_client.coffee
Created June 17, 2011 10:51 — forked from emk/comet_client.coffee
Real-time Comet with Faye, Node.js and Coffee
# Client-side Comet code. See comet_server.coffee for instructions.
client = new Faye.Client '/faye', timeout: 90
# Attach a security key to all our subscription messages.
client.addExtension
outgoing: (msg, callback) ->
return callback(msg) unless msg.channel is '/meta/subscribe'
(msg.ext ?= {}).authToken = 'secret'
callback(msg)
# Build Notes
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
https://github.com/mxcl/homebrew/issues/issue/2510
To build plpython against a specific Python, set PYTHON prior to brewing:
PYTHON=/usr/local/bin/python brew install postgresql
See:
http://www.postgresql.org/docs/9.1/static/install-procedure.html
@georgel
georgel / gist:2199359
Created March 25, 2012 19:55 — forked from pithyless/gist:1208841
Install Python 2.7 (homebrew + pip + virtualenv) on Mac OS X Lion

Install Python

$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7

Symlinks...

@georgel
georgel / gist:2338514
Created April 8, 2012 17:05 — forked from mikeyk/gist:1329319
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@georgel
georgel / gist:2341397
Created April 9, 2012 04:18
Calculate distance between 2 cllocation
#define DEG_TO_RAD 0.017453292519943295769236907684886
#define EARTH_RADIUS 6372797.560856
// return distance between two lat/lon points, in meters
double DistanceBetweenCoords(double fromLat, double fromLong, double toLat,
double toLong)
{
double latitudeArc = (fromLat - toLat) * DEG_TO_RAD;
double longitudeArc = (fromLong - toLong) * DEG_TO_RAD;
double latitudeH = sin(latitudeArc * 0.5);
@georgel
georgel / setup-statsd.sh
Created April 26, 2012 08:58 — forked from jasonroelofs/setup-statsd.sh
Turn an Ubuntu 10.10 EC2 into a StatsD/Graphite server
# install git
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
# download the Node source, compile and install it
git clone https://github.com/joyent/node.git
cd node
./configure
make
sudo make install
# install the Node package manager for later use
@georgel
georgel / setup-statsd.sh
Created April 26, 2012 09:28 — forked from rw/setup-statsd.sh
Turn an Ubuntu 11.10 EC2 into a StatsD/Graphite server
# install git
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
sudo apt-get install nodejs
# install the Node package manager for later use
curl http://npmjs.org/install.sh | sudo sh
sudo npm install express
# clone the statsd project
git clone https://github.com/etsy/statsd.git
# download everything for graphite
@georgel
georgel / gist:2533961
Created April 29, 2012 06:12 — forked from henrygarner/gist:1123179
Resources for setting up RVM and Passenger on Chef
http://www.agileweboperations.com/chef-rvm-ruby-enterprise-edition-as-default-ruby
http://www.christophersamuelson.com/2010/10/22/chef-rvm-capistrano-bundler/
http://blog.ninjahideout.com/posts/a-guide-to-a-nginx-passenger-and-rvm-server
http://brandontilley.com/2011/01/29/serving-rails-apps-with-rvm-nginx-unicorn-and-upstart.html
http://brandontilley.com/2011/01/29/rvm-unicorn-and-upstart.html
Chef workflow
# Install cookbook from opscode community site. (Automatically commits to local repo)
knife cookbook site install <COOKBOOK_NAME>
@georgel
georgel / gist:2550017
Created April 29, 2012 12:14 — forked from botchagalupe/gist:666110
General Chef Notes

Chef Demo One

Prep Work

knife cookbook site vendor -d ntp

Use chef-solo to launch ntp...

Chef Demo Two

@georgel
georgel / mongoid.rb
Created June 15, 2012 04:45 — forked from durran/mongoid.rb
Custom database persistence.
module CustomDatabase
extend ActiveSupport::Concern
included do
store_in database: custom_database
end
module ClassMethods
def custom_database