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
#! debug | |
ipdb> connections['default'].cursor().db.connection | |
<connection object at 0x10646d180; dsn: 'dbname=test_master', closed: 0> | |
ipdb> connections['prestashop'].cursor().db.connection | |
<connection object at 0x10670d3e0; dsn: 'dbname=test_master', closed: 0> | |
#! settings | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.postgresql_psycopg2', |
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 | |
# keep original thread module for later use | |
original_thread_module = sys.modules.pop('threading', None) | |
import gevent.monkey | |
gevent.monkey.patch_all() |
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 zipfile,os.path | |
def unzip(source_filename, dest_dir): | |
with zipfile.ZipFile(source_filename) as zf: | |
for member in zf.infolist(): | |
# Path traversal defense copied from | |
# http://hg.python.org/cpython/file/tip/Lib/http/server.py#l789 | |
words = member.filename.split('/') | |
path = dest_dir | |
for word in words[:-1]: | |
drive, word = os.path.splitdrive(word) |
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 | |
# This hook is sourced after every virtualenv is deactivated. | |
# remove virtualenv | |
RPROMPT="$_OLD_RPROMPT" |
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/bash | |
# This hook is sourced after every virtualenv is activated. | |
proj_name=$(basename $VIRTUAL_ENV) | |
cd ~/src/$proj_name | |
# show virtualenv | |
PS1="$_OLD_VIRTUAL_PS1" | |
_OLD_RPROMPT="$RPROMPT" | |
RPROMPT="%{${fg_bold[white]}%}(env: %{${fg[green]}%}`basename \"$VIRTUAL_ENV\"`%{${fg_bold[white]}%})%{${reset_color}%} $RPROMPT" |
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/bash | |
# This hook is sourced after a new virtualenv is activated. | |
proj_name=$(basename $VIRTUAL_ENV) | |
mkdir $HOME/src/$proj_name | |
add2virtualenv $HOME/src/$proj_name | |
cd $HOME/src/$proj_name |
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 sys import stdin | |
def up(x, y, f): | |
try: | |
return reduce(lambda u,v: int(u)*int(v), f[x][y:y+4]) | |
except IndexError: | |
return 0 | |
def down(x, y, f): | |
try: |
NewerOlder