Skip to content

Instantly share code, notes, and snippets.

@uasi
uasi / vim.rb
Created November 30, 2010 16:46
Vim formula for Homebrew (EDIT: recent versions of official Homebrew distribution includes one)
require 'formula'
class Vim < Formula
homepage 'http://www.vim.org/'
url 'ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2'
head 'https://vim.googlecode.com/hg/'
sha256 '5c5d5d6e07f1bbc49b6fe3906ff8a7e39b049928b68195b38e3e3d347100221d'
version '7.3.682'
def features; %w(tiny small normal big huge) end
@dound
dound / postgresql_upsert.py
Created January 10, 2011 00:19
Python implementation of UPSERT for use with postgresql.
def upsert(db_cur, table, pk_fields, schema=None, **kwargs):
"""Updates the specified relation with the key-value pairs in kwargs if a
row matching the primary key value(s) already exists. Otherwise, a new row
is inserted. Returns True if a new row was inserted.
schema the schema to use, if any (not sanitized)
table the table to use (not sanitized)
pk_fields tuple of field names which are part of the primary key
kwargs all key-value pairs which should be set in the row
"""
@wting
wting / dreamhost_python_setup.sh
Created May 31, 2012 00:16
Dreamhost Python Setup script
#!/usr/bin/env bash
# Written by William Ting for the following blog post:
# http://williamting.com/posts/2012/04/18/set-up-python-and-django-on-dreamhost/
rcfile="${HOME}/.bashrc"
version="2.7.3"
setuptools_version="2.7"
tmp_dir="${HOME}/tmp-${RANDOM}"
if [[ ${#} == 0 ]]; then