Skip to content

Instantly share code, notes, and snippets.

View zafarali's full-sized avatar

Zafarali Ahmed zafarali

View GitHub Profile
@zafarali
zafarali / dataready.sh
Last active December 5, 2015 17:45
Bash Script to set up a data analysis VPS
apt-get update
apt-get install -y git
apt-get install -y tmux
apt-get install -y python-pip
apt-get install -y python-numpy python-scipy
apt-get install -y python-matplotlib
apt-get install -y python-pandas
pip install scikit-learn
apt-get install -y ipython
pip install -e git+https://github.com/Theano/Theano.git@15c90dd3#egg=Theano==0.8.git
@zafarali
zafarali / polarstreamplot.m
Created December 1, 2015 15:59
A mathematica snippet to turn a polar dynamical system into a stream plot.
# your polar functions dr/dt and d\[Theta]/dt here:
field = {r (1 - r^2) (4 - r^2), 2 - r^2};
# Creates the stream plot
StreamPlot[
Evaluate@TransformedField["Polar" -> "Cartesian",
field, {r, \[Theta]} -> {x, y}], {x, -3, 3}, {y, -3, 3}]
# Load the data streamer:
ds = IOutils.data_streamer(num_sets='all')
# obtains the unique rows in a dataset
def unique_rows(data):
uniq = np.unique(data.view(data.dtype.descr * data.shape[1]))
return uniq.view(data.dtype).reshape(-1, data.shape[1])
X, Y = ds.next()
Y = np.array(Y)
@zafarali
zafarali / preferences.sublime-keymap
Created July 22, 2015 20:18
Preferences in Sublime Text 2/3
[
//makes go to lines easier
{ "keys": ["super+;"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
// makes bookmarking easier
{ "keys": ["f5"], "command": "toggle_bookmark" },
{ "keys": ["f6"], "command": "next_bookmark" },
{ "keys": ["super+f6"], "command": "prev_bookmark" }
]
@zafarali
zafarali / plot_polygon.py
Last active August 29, 2015 14:24
draw a polygon using vertices
import matplotlib.pyplot as plt
def plot_polygon(vertices):
plt.figure()
for i in range(len(vertices)-1):
vertex_set = [ vertices[i] ] + [ vertices[i+1] ]
x, y = zip(*vertex_set)
plt.plot(x,y)
vertex_set = [ vertices[0] ] + [ vertices[-1] ]