Skip to content

Instantly share code, notes, and snippets.

View neotheicebird's full-sized avatar

prash neotheicebird

  • Chennai
View GitHub Profile
@neotheicebird
neotheicebird / realtimeplot.py
Created March 1, 2016 07:27 — forked from pklaus/realtimeplot.py
Plotting or real-time data with the Matplotlib animation API. Source: http://stackoverflow.com/a/15724978/183995
#!/usr/bin/env python
import numpy as np
import time
import matplotlib
matplotlib.use('TKAgg')
#matplotlib.use('GTKAgg')
from matplotlib import pyplot as plt
@neotheicebird
neotheicebird / realtime-plot.py
Created February 29, 2016 14:11 — forked from Uberi/realtime-plot.py
Realtime plotting with Matplotlib.
#!/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):
@neotheicebird
neotheicebird / VirtualBoxFullScreenGuest.sh
Last active February 18, 2016 07:31
Set a virtual box guest to a different screen resolution
vboxmanage setextradata "VM Name" "CustomVideoMode1" "1600x900x32"
@neotheicebird
neotheicebird / 0_reuse_code.js
Created February 18, 2016 07:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@neotheicebird
neotheicebird / plot_colors.py
Created January 14, 2015 13:26
colors for plotting
color_dict = {'AUDREY': 'red',
'CAMILLE': 'blue',
'CARMEN': 'green',
'BETSY': 'yellow',
'FREDERIC': 'black',
'ELENA': 'cyan',
'JUAN': 'magenta',
'ISIDORE': '#da70d6',
'IVAN': '#ff7f50',
'CINDY': '#cd853f',
@neotheicebird
neotheicebird / pip_python3.sh
Created October 7, 2014 12:11
I have both python2.7 and python3.2 installed in Ubuntu 12.04. The symbolic link python links to python2.7. When I type: sudo pip install package-name It will default install python2 version of package-name. Some package supports both python2 and python3. How to install python3 version of package-name via pip?
virtualenv -p /usr/bin/python3 py3env
source py3env/bin/activate
pip install package-name
@neotheicebird
neotheicebird / remove_spaces.py
Created September 9, 2014 09:45
Remove white spaces
# 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'
@neotheicebird
neotheicebird / MD5_checksum.py
Created August 22, 2014 13:46
MD5 checksum function
# 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
@neotheicebird
neotheicebird / fileext_in_dir.py
Last active August 29, 2015 14:04
find files of a specific extension from a folder
import glob
listing = glob.glob('C:/foo/bar/foo.log*')
for filename in listing:
# do stuff
@neotheicebird
neotheicebird / random_string_gen.py
Last active August 29, 2015 14:03
Random string generation
# 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))