brew install git bash-completion
Configure things:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
#!/usr/bin/env python | |
"""Find height, width of the largest rectangle containing all 0's in the matrix. | |
The algorithm for `max_size()` is suggested by @j_random_hacker [1]. | |
The algorithm for `max_rectangle_size()` is from [2]. | |
The Python implementation [3] is dual licensed under CC BY-SA 3.0 | |
and ISC license. | |
[1]: http://stackoverflow.com/questions/2478447/find-largest-rectangle-containing-only-zeros-in-an-nn-binary-matrix#comment5169734_4671342 |
brew install git bash-completion
Configure things:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
import urllib2, json, pprint, re, datetime | |
import mwparserfromhell | |
def _parseDate(wikiDate): | |
''' Parse a mediawiki date template -- assumes years, month, day | |
Input: | |
a mwparser object containing just the date to be parsed | |
Returns: | |
datetime.date object of the date | |
''' |
Roll your own iPython Notebook server with Amazon Web Services (EC2) using their Free Tier.
Install Package Control for easy package management.
Ctrl+`
# By Jake VanderPlas | |
# License: BSD-style | |
import matplotlib.pyplot as plt | |
import numpy as np | |
def discrete_cmap(N, base_cmap=None): | |
"""Create an N-bin discrete colormap from the specified input map""" |
height: 750 |
# calculate and visualize silhouette score from k-means clustering. | |
# plots first two features in 2D and first three features in 3D. | |
# from: http://scikit-learn.org/stable/auto_examples/cluster/plot_kmeans_silhouette_analysis.html | |
from sklearn.cluster import KMeans | |
from sklearn.metrics import silhouette_score, silhouette_samples | |
from mpl_toolkits.mplot3d import Axes3D | |
##### cluster data into K=1..K_MAX clusters ##### | |
K_MAX = 10 |
from sklearn.base import BaseEstimator,TransformerMixin | |
class LogTransformer(BaseEstimator,TransformerMixin): | |
def __init__(self, constant=1, base='e'): | |
from numpy import log,log10 | |
if base == 'e' or base == np.e: | |
self.log = log | |
elif base == '10' or base == 10: | |
self.log = log10 | |
else: |