| From | To | Expression |
|---|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Classtionary(dict): | |
| """A Class, er, dictionary, um, attributes-as-keys thingy. | |
| >>> c = Classtionary(foo="bar") | |
| >>> d = dict(foo="bar") | |
| >>> c, d | |
| ({'foo': 'bar'}, {'foo': 'bar'}) | |
| >>> c.fizz = "bang" | |
| >>> d.fizz = "bang" | |
| Traceback (most recent call last): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DEST="destination.example.com" | |
| SRC="source.example.com" | |
| TEST="testserver.example.com" | |
| DB="my_db" | |
| SSHER="mysshuser" | |
| ssh -C $SSHER@$SRC "pg_dump $DB" | ssh -C $TEST "cat > /tmp/$DB.pgdump && dropdb -h$DEST $DB ; createdb -h$DEST $DB -E UTF-8 && psql -h$DEST $DB < /tmp/$DB.pgdump && rm /tmp/$DB.pgdump" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- currency_plus(val NUMERIC, decimals INT DEFAULT 2) | |
| -- Returns a US Dollar formatted string. | |
| -- Takes one required argument, the value to be formatted | |
| -- and one optional argument, decimals, the number of decimal places to | |
| -- display (default is 2 decimal places). | |
| -- | |
| -- Example Usage: | |
| -- currency_plus(123.45678) -> '$123.46' | |
| -- currency_plus(123.45678, 0) -> '$123' | |
| -- currency_plus(123.45678, 3) -> '$123.457' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Tell virtualenvwrapper to use the python that was used to install | |
| # virtualenv. It's the full path after the shebang (#!) | |
| # This should keep us from seeing virtualenvwrapper errors re: "hooks" | |
| VIRTUALENVWRAPPER_PYTHON=`head -1 $(which virtualenv) | cut -d ! -f 2` | |
| source $(which virtualenvwrapper.sh) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function cdp(){ | |
| # Change to the directory containing the Python module passed as the first | |
| # argument. | |
| # http://chris-lamb.co.uk/2010/04/22/locating-source-any-python-module/ | |
| cd "$(python -c "import os.path as _, ${1}; \ | |
| print _.dirname(_.realpath(${1}.__file__[:-1]))" | |
| )" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function ds(){ | |
| # A script to list the 10 directories or files that are consuming the most | |
| # disk space. | |
| # Requires one argument, the top directory to search | |
| du -hs $(du --max-depth=1 $1 \ | |
| | sort -nr \ | |
| | mawk -W interactive '{printf("%s\n", $2)}' \ | |
| | head -n 10 \ | |
| | tail -n 10) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #-*- coding:utf-8 -*- | |
| """ | |
| ==================================== | |
| Utilities to help with using CSV IO | |
| ==================================== | |
| Example usage | |
| ------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gpsbabel -t -i gpx -f a.gpx -i gpx -f b.gpx -x track,merge -o gpx -F combined.gpx |