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
| import time | |
| class Retry(object): | |
| default_exceptions = (Exception) | |
| def __init__(self, tries, exceptions=None, delay=0): | |
| """ | |
| Decorator for retrying function if exception occurs | |
| tries -- num tries | |
| exceptions -- exceptions to catch |
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
| 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 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
| [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 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
| # encoding: utf-8 | |
| """ Python General Helpers | |
| Copyright (c) 2010 Kenneth Reitz. Creative Commons Attribution 3.0 License. | |
| """ | |
| import urllib, re, time, sys | |
| import paramiko | |
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
| import sys | |
| import time | |
| def progressbar(it, prefix = "", size = 60): | |
| count = len(it) | |
| def _show(_i): | |
| x = int(size*_i/count) | |
| sys.stdout.write("%s[%s>%s] %i/%i\r" % (prefix, "="*x, "-"*(size-x), _i, count)) | |
| sys.stdout.flush() |
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
| ## 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 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
| 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 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
| #!/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 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
| 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 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
| #!/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'; |