Skip to content

Instantly share code, notes, and snippets.

@pengwynn
pengwynn / vim7.3_mac_install.rb
Created July 27, 2011 17:41 — forked from mattsacks/install.rb
Script to install Vim 7.3 with ruby support for Mac OS X Lion
# requires root permissions in /usr/bin/
star = String.new
8.times { star += "*" }
Star = "\n#{star * 3}\n"
def newblock string
puts "\n#{Star}#{string}#{Star}\n"
end
@otobrglez
otobrglez / Article.rb
Created July 12, 2011 20:51
Finding related articles using Jaccard index and tags
# This method finds related articles using Jaccard index (optimized for PostgreSQL).
# More info: http://en.wikipedia.org/wiki/Jaccard_index
class Article < ActiveRecord::Base
def related(limit=10)
Article.find_by_sql(%Q{
SELECT
a.*,
( SELECT array_agg(t.name) FROM taggings tg, tags t
@carljm
carljm / postactivate
Created July 12, 2011 18:21
Yo dawg, I heard you like Ruby...
#!/bin/bash
# This hook is run after every virtualenv is activated.
export OLD_GEM_HOME=$GEM_HOME
export GEM_HOME=$VIRTUAL_ENV/gems/
export GEM_PATH=
export PATH=$VIRTUAL_ENV/gems/bin:$PATH
@jordansissel
jordansissel / README.md
Created July 6, 2011 05:04
Sorting windows in tmux by hostname.

For this to work, it requires my tmux fork that includes what I use as the hostname in the window list.

At any rate, it'll sort my tmux sessions alphabetically by the host I'm using.

my tmux fork: https://github.com/jordansissel/tmux

Starts with:

(0) -    nightfall: zsh - /home/jls/projects/tmux/trunk                                                            

(1) carrera: screen -x irc

@mikehale
mikehale / a-screenshot.md
Created July 1, 2011 20:57 — forked from akahn/a-screenshot.md
Embed gravatars in Propane chat

@j2labs
j2labs / gist:1046726
Created June 25, 2011 18:15
Stream API example in Python using PyCurl
#!/usr/bin/env python
# Example for reading from the Twitter streaming API using pycurl
#
# PyCurl is not installed by default so install it like this:
#
# pip install pycurl
#
# The streaming api methods are documented here:
anonymous
anonymous / bootstrap.sh
Created June 2, 2011 17:19
Django on Heroku with Celery and Sentry
virtualenv --no-site-packages .
source bin/activate
bin/pip install Django psycopg2 django-sentry
bin/pip freeze > requirements.txt
bin/django-admin.py startproject mysite
cat >.gitignore <<EOF
bin/
include/
lib/
EOF
INI_HEADER = '''[tox]
setupdir = {toxinidir}/upstream
'''
ENV_TEMPLATE = '''[testenv:%(envname)s]
basepython = %(pyver)s
deps = %(deps)s
setenv =
PYTHONPATH={toxinidir}
commands =
@piranha
piranha / mixin-vs-dec.py
Created May 28, 2011 09:30
Mixin vs class decorator
import logging, timeit
class LoggedSetItemMixin(object):
def __setitem__(self, index, value):
logging.info('Setting %r to %r' % (index, value))
super(LoggedSetItemMixin, self).__setitem__(index,value)
class LoggingDict(LoggedSetItemMixin, dict):
pass
import eventlet
from eventlet import GreenPool
from eventlet.green import urllib2
import logging
log = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
class Reader(object):
def __init__(self, i):