Skip to content

Instantly share code, notes, and snippets.

View thomasaarholt's full-sized avatar

Thomas Aarholt thomasaarholt

View GitHub Profile
@andrewjesaitis
andrewjesaitis / gist:7778867
Created December 3, 2013 22:37
Just an example of dividing a continuous matplotlib colormap into a distinct array of colors
import matplotlib as mpl
num_colors = len(values)
cm = mpl.cm.get_cmap(name='YlGnBu_r')
currentColors = [cm(1.*i/num_colors) for i in range(num_colors)]
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@zonca
zonca / rebin.py
Created November 8, 2011 19:12
IDL rebin in python
import numpy as np
def rebin(a, new_shape):
"""
Resizes a 2d array by averaging or repeating elements,
new dimensions must be integral factors of original dimensions
Parameters
----------
a : array_like