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
export WORKON_HOME = ~/Envs | |
mkdir -p $WORKON_HOME | |
source virtualenvwrapper.sh | |
mkvirtualenv django | |
pip install django |
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
fig = figure; | |
scrsz = get(0,'ScreenSize'); | |
set(fig,'Position', [scrsz(1) scrsz(2) scrsz(3) scrsz(4)]);cla; |
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
# source: http://stackoverflow.com/questions/9319317/quick-and-easy-file-dialog-in-python | |
import Tkinter, tkFileDialog | |
root = Tkinter.Tk() | |
root.withdraw() | |
file_path = tkFileDialog.askopenfilename() |
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
# fastest, but complex | |
'%030x' % random.randrange(16**30) | |
# fast | |
binascii.b2a_hex(os.urandom(15)) | |
# beautiful | |
''.join(random.choice(string.hexdigits) for n in xrange(30)) |
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 glob | |
listing = glob.glob('C:/foo/bar/foo.log*') | |
for filename in listing: | |
# do stuff |
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
# source http://joelverhagen.com/blog/2011/02/md5-hash-of-file-in-python/ | |
import hashlib | |
def md5Checksum(filePath): | |
with open(filePath, 'rb') as fh: | |
m = hashlib.md5() | |
while True: | |
data = fh.read(8192) | |
if not data: | |
break |
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
# courtesy: http://stackoverflow.com/questions/8270092/python-remove-all-whitespace-in-a-string | |
# remove leading spaces | |
sentence = ' hello apple' | |
sentence.strip() | |
# >>> 'hello apple' | |
# remove all spaces | |
sentence = ' hello apple' | |
sentence.replace(" ", "") | |
# >>> 'helloapple' |
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
virtualenv -p /usr/bin/python3 py3env | |
source py3env/bin/activate | |
pip install package-name |
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
color_dict = {'AUDREY': 'red', | |
'CAMILLE': 'blue', | |
'CARMEN': 'green', | |
'BETSY': 'yellow', | |
'FREDERIC': 'black', | |
'ELENA': 'cyan', | |
'JUAN': 'magenta', | |
'ISIDORE': '#da70d6', | |
'IVAN': '#ff7f50', | |
'CINDY': '#cd853f', |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
OlderNewer