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
# Retry decorator with exponential backoff | |
def retry(tries, delay=3, backoff=2): | |
""" | |
Retries a function or method if exception is raised. | |
delay sets the initial delay in seconds, and backoff sets the factor by which | |
the delay should lengthen after each failure. backoff must be greater than 1, | |
or else it isn't really a backoff. tries must be at least 0, and delay | |
greater than 0. | |
""" |
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
#!/bin/zsh | |
# Global virtualenvwrapper postactivate, lives in $WORKON_HOME/postdeactivate | |
if [ $PRE_VENV_ACTIVATE_DIR ]; then | |
cd $PRE_VENV_ACTIVATE_DIR | |
unset PRE_VENV_ACTIVATE_DIR | |
unset CURRENT_PROJECT | |
fi |
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
#!/bin/zsh | |
# Global virtualenvwrapper postactivate, lives in $WORKON_HOME/postactivate | |
# Remove virtual env from start of PS1 as it's in RPROMPT instead | |
PS1="$_OLD_VIRTUAL_PS1" | |
PROJECT_DIR="$HOME/projects/$(basename $VIRTUAL_ENV)" | |
if [ -d $PROJECT_DIR ]; then | |
# If we aren't already within the project dir, cd into it |
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 my_error_handling(object): | |
def __enter__(self): pass | |
def __exit__(self, exc_type, exc_val, exc_tb): | |
if issubclass(exc_type, UnicodeError): | |
print "annoying" | |
elif issubclass(exc_type, ValueError): | |
print "hrmm" | |
elif issubclass(exc_type, OSError): | |
print "alert sysadmin" |
NewerOlder