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 | |
import numpy as np | |
import time | |
import matplotlib | |
matplotlib.use('TKAgg') | |
#matplotlib.use('GTKAgg') | |
from matplotlib import pyplot as plt | |
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 python3 | |
import time, random | |
import math | |
from collections import deque | |
start = time.time() | |
class RealtimePlot: | |
def __init__(self, axes, max_entries = 100): |
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
vboxmanage setextradata "VM Name" "CustomVideoMode1" "1600x900x32" |
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 |
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
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
# 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
# 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
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
# 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)) |