Skip to content

Instantly share code, notes, and snippets.

View neotheicebird's full-sized avatar

prash neotheicebird

  • Chennai
View GitHub Profile
@neotheicebird
neotheicebird / virtualenv_django
Created February 15, 2014 17:33
To work on multiple versions of django - Setup virtualenv and install django in a virtual environment
export WORKON_HOME = ~/Envs
mkdir -p $WORKON_HOME
source virtualenvwrapper.sh
mkvirtualenv django
pip install django
@neotheicebird
neotheicebird / gist:9438334
Created March 8, 2014 20:24
Full screen of a matlab figure
fig = figure;
scrsz = get(0,'ScreenSize');
set(fig,'Position', [scrsz(1) scrsz(2) scrsz(3) scrsz(4)]);cla;
@neotheicebird
neotheicebird / file_dialog_open.py
Created April 28, 2014 08:59
File select dialog - Python
# 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()
@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))
@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 / 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 / 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 / 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 / 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 / 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