Skip to content

Instantly share code, notes, and snippets.

class Hash
# A better implementation of Hash#fetch, which will return a default
# parameter passed in, the result of the passed in block
# OR throw IndexError if the key is not in the hash
# fetch! is a version of this function that returns the name of the key that was
# not found in the hash.
# For a good detail of the Hash#fetch method see:
# <http://avdi.org/devblog/2009/03/16/go-fetch/>
def fetch!(key, default_value=nil, &block)
from __future__ import with_statement
import pdb
import sys
from contextlib import contextmanager
@contextmanager
def local_post_mortem():
"""Use this in a with statement to break into the PDB if the stament throws an exception"""
try:
# RUBY-SWITCHER AND RUBYGEMS
# ==========================================
# Thanks in part to <http://blog.thinkrelevance.com/2009/7/29/ruby-switcher-working-with-multiple-ruby-versions-has-never-been-this-easy/>
# and the other part, well, HARD WORK IS HARD!!!!
# SETUP
cd
curl -O -L http://github.com/relevance/etc/raw/26ae85c2f6c7d2640a3c75d619ad7ab8fc1cc570/bash/ruby_switcher.sh
echo "source ~/ruby_switcher.sh" >> .bash_profile
hello world from gist
hello world from gist
# setup, ignore me....
cd Temp
mkdir hg_commits_from_past_into_branch
cd hg_commits_from_past_into_branch
hg init
bbedit onefile.txt
hg status
? onefile.txt
hg add onefile.txt
hg commit -m "first commit"
# Path to your oh-my-zsh configuration.
export ZSH=$HOME/.oh-my-zsh
# Set to the name theme to load.
# Look in ~/.oh-my-zsh/themes/
export ZSH_THEME="xiong-chiamiov-plus"
# Set to this to use case-sensitive completion
# export CASE_SENSITIVE="true"
# A Sub command dispatcher for methods in Python
# Thanks to dectools: http://pypi.python.org/pypi/dectools
#
# Use Case: You have a function that takes 1 + N parameters. The first
# parameter you would use as a switch statement (in C), or as a key in
# a Dictionary (in Python) to figure out another function to send
# the other N args to.
#
# for example, command line parsers:
# def handle_commands():
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
@rwilcox
rwilcox / gist:401103
Created May 14, 2010 12:45 — forked from anonymous/gist:156623
with Fab 0.9 and hg & TG2 instead of git & Django
"""
NOTES:
* Originally from http://morethanseven.net/2009/07/27/fabric-django-git-apache-mod_wsgi-virtualenv-and-p/
* Patches for fabric 0.9/1.0 with code from <http://github.com/fiee/generic_django_project/>
Changes from the original fabfile:
* Patches for Fabric 0.9/1.0
* Use Mercurial instead of Git
* Use named mercurial branches instead of head/tip