This file contains 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
import os | |
from datetime import datetime | |
from multiprocessing.util import register_after_fork | |
from sqlalchemy import create_engine, MetaData, Table | |
from sqlalchemy.orm import sessionmaker | |
from sqlalchemy.ext.declarative import declarative_base | |
from psycopg2.extras import RealDictConnection, register_hstore |
This file contains 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
#!/usr/bin/env php | |
<?php | |
set_time_limit(0); | |
$nDays = 300; // How many days of backups to keep? | |
// MySQL variables | |
$bBackupMySQL = true; // Do you want to backup MySQL databases? | |
$mysql = '/usr/bin/mysql'; | |
$mysqldump = '/usr/bin/mysqldump'; | |
$mysql_server = 'xxxx.com'; | |
$mysql_username = 'xxxx'; |
This file contains 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
Hardware: | |
Hardware Overview: | |
Model Name: MacBook Pro | |
Model Identifier: MacBookPro6,2 | |
Processor Name: Intel Core i7 | |
Processor Speed: 2.66 GHz | |
Number Of Processors: 1 | |
Total Number Of Cores: 2 |
This file contains 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
#!/usr/bin/env python | |
"""xml2json.py Convert XML to JSON | |
Relies on ElementTree for the XML parsing. This is based on | |
pesterfish.py but uses a different XML->JSON mapping. | |
The XML->JSON mapping is described at | |
http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html |
This file contains 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
merge.tool=chdiff | |
mergetool.chdiff.cmd=/usr/bin/env chdiff --wait $LOCAL $REMOTE | |
mergetool.chdiff.keepbackup=false | |
mergetool.chdiff.trustexitcode=false | |
diff.tool=Kaleidoscope | |
difftool.Kaleidoscope.cmd=ksdiff-wrapper git "$LOCAL" "$REMOTE" | |
difftool.prompt=false |
This file contains 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
## Roll your own python from source: | |
wget http://www.python.org/ftp/python/2.6.5/Python-2.6.5.tgz | |
tar -xzvf Python-2.6.5.tgz && cd Python-2.6.* | |
./configure --enable-framework=/Library/Frameworks --with-universal-archs=intel --enable-universalsdk=/ | |
make | |
sudo make install | |
# Update the symlink for `python` (and check others) |
This file contains 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
[alias] | |
# install t first: http://github.com/sjl/t | |
todo = !python ~/path/to/t.py --task-dir "$(git rev-parse --show-toplevel)" --list TODO | |
bug = !python ~/path/to/t.py --task-dir "$(git rev-parse --show-toplevel)" --list BUGS |
This file contains 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
from StringIO import StringIO | |
tree1 = ("Root", ("Child 1", ("Child 2", None))) | |
get_label1 = lambda x: x[0] | |
def get_children1(node): | |
if node[1] is not None: | |
yield node[1] | |
class Node(object): | |
This file contains 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
local g="$(git rev-parse --git-dir 2>/dev/null)" | |
if [ -n "$g" ]; then | |
local r | |
local b | |
if [ -d "$g/../.dotest" ] | |
then | |
if test -f "$g/../.dotest/rebasing" | |
then | |
r="|REBASE" | |
elif test -f "$g/../.dotest/applying" |
This file contains 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
# credit: http://news.ycombinator.com/item?id=1543915 | |
# in ipythonrc: | |
# execfile copy_and_paste.py | |
def copy(data): | |
from subprocess import Popen, PIPE | |
Popen(["xclip", "-selection", "clipboard"], stdin=PIPE).communicate(str(data)) | |
def paste(): |
OlderNewer