Skip to content

Instantly share code, notes, and snippets.

Nathan Witmer zerowidth

Block or report user

Report or block zerowidth

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
zerowidth /
Created Sep 22, 2009
bash promptery for git + custom colored dirty flags
# assuming you have the +bash_completion variant of git installed (macports)
# and are including bash completion's setup:
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
TEXT_BLACK='\[\e[0;30m\]' # Black - Regular
TEXT_RED='\[\e[0;31m\]' # Red
TEXT_GREEN='\[\e[0;32m\]' # Green
TEXT_YELLOW='\[\e[0;33m\]' # Yellow
zerowidth / rack-streaming-proxy.rb
Created Nov 15, 2009
rack-streaming-proxy example code
View rack-streaming-proxy.rb
require "servolux"
require "net/http"
require "uri"
# see: for the latest code
# or: sudo gem install rack-streaming-proxy --source
module Rack
class StreamingProxy
View module ancestry.txt
$ irb
>> module A; end
=> nil
>> module B; end
=> nil
>> module C; end
=> nil
>> module B; include A; end
=> B
>> class X; include B; end
View embedded_basic_mongo_tree.rb
class ParentDocument
include MongoMapper::Document
# parent document has ... well, whatever.
many :nodes do
# root documents only
def roots
View super_semantics.rb
class A
def foo
class B < A
def foo
lambda { super }
# as of 2010-04-01
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/mysql/bin:$PATH:/Users/nathan/scripts
export PATH=/Users/nathan/bin:/Users/nathan/bin/gitflow:/opt/local/lib/postgresql84/bin:$PATH
export LD_LIBRARY_PATH=/opt/local/lib
# export EDITOR="/Users/nathan/bin/mate_wait"
# export EDITOR="/Users/nathan/bin/mvim -f" # -f means don't fork, wait for changes
export EDITOR="/opt/local/bin/vim -f"
# export EDITOR="/opt/local/bin/mvim -f"
zerowidth / ar_literals.rb
Created Jun 22, 2010
DEFAULT literals in AR for postgres defaults (via @copiousfreetime)
View ar_literals.rb
# Force ActiveRecord to insert the 'DEFAULT' literal for columns which
# are non-null but do not have a default that AR understands.
# MySQL is lenient in that if you insert a NULL in something with a default,
# the database will just insert the default anyway. Postgres is not so kind:
# it'll do exactly what you told it, causing an error.
# Usually AR can figure out the default for a column, but if it's a default
# value that the connection adapter can't figure out, it'll insert a NULL.
# So: allow explicit 'DEFAULT' literals (which is SQL standard) to be used instead
# where appropriate.
zerowidth /
Created Jul 16, 2010
git demo of what happens when you try to push to a working copy
# try out cloning and pushing using a working copy in git
function log() {
echo "***** $1"
zerowidth / pivotal-post-receive.rb
Created Jul 25, 2010
git post-receive hook for pivotal tracker
View pivotal-post-receive.rb
#!/usr/bin/env ruby
# git post-receive hook that posts the log messages to pivotal tracker
# for automatic updates of stories.
# See
# for more information
require "cgi"
zerowidth / client.rb
Created Jul 27, 2010
module methods and super
View client.rb
# A rough example of how I'm putting module method overrides to use.
# This allows me to add functionality to methods without having to
# do method aliasing, and it's easy to enable/disable things too.
module Search
def search(query, opts={})
request("search", :query => query).results
You can’t perform that action at this time.