Skip to content

Instantly share code, notes, and snippets.

View andrewgiessel's full-sized avatar
🧬
hackhackhack

andrew giessel andrewgiessel

🧬
hackhackhack
View GitHub Profile
@jgomezdans
jgomezdans / random.py
Created May 15, 2010 23:24
Random colormap for matplotli
import matplotlib,numpy
import pylab
# A random colormap for matplotlib
cmap = matplotlib.colors.ListedColormap ( numpy.random.rand ( 256,3))
pylab.imshow ( Z, cmap = cmap)
pylab.show()
@alexbw
alexbw / PythonInstallwithMacports
Created September 1, 2011 02:03
Python installation w/ MacPorts
# Install Macports
# We'll install a relatively high-level package first, with a lot of dependencies,
# so that we pick up everything along the way
# Chaco is an enthought plotting package that'll
sudo port install py26-chaco
sudo port select python python26
sudo port install py26-ipython
@potch
potch / gist_line_numbers.css
Created September 26, 2011 18:53
CSS to add line numbers to embedded gists
.gist-highlight {
border-left: 3ex solid #eee;
position: relative;
}
.gist-highlight pre {
counter-reset: linenumbers;
}
.gist-highlight pre div:before {
@liuyxpp
liuyxpp / flaskplotlib.py
Created September 29, 2011 09:33 — forked from wilsaj/flaskplotlib.py
Example of rendering a matplotlib image directly to Flask view
from flask import Flask, make_response, render_template
app = Flask(__name__)
@app.route("/")
def index():
render_template("index.html")
@app.route("/simple.png")
def simple():
import datetime
<style>.gist{color:#000;}.gist div{padding:0;margin:0;}.gist .gist-file{border:1px solid #dedede;font-family:Monaco,'Courier New','DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;margin-bottom:1em;}.gist .gist-file .gist-meta{overflow:hidden;font-size:85%;padding:.5em;color:#666;background-color:#eaeaea;}.gist .gist-file .gist-meta a{color:#369;}.gist .gist-file .gist-meta a:visited{color:#737;}.gist .gist-file .gist-data{overflow:auto;word-wrap:normal;background-color:#f8f8ff;border-bottom:1px solid #ddd;font-size:100%;}.gist .gist-file .gist-data pre{font-family:'Bitstream Vera Sans Mono','Courier',monospace;background:transparent !important;margin:0 !important;border:none !important;padding:.25em .5em .5em .5em !important;}.gist .gist-file .gist-data .gist-highlight{background:transparent !important;}.gist .gist-file .gist-data .gist-line-numbers{background-color:#ececec;color:#aaa;border-right:1px solid #ddd;text-align:right;}.gist .gist-file .gist-data .gist-line-numbers span{clear:right;display:b
@kgaughan
kgaughan / gist:2491663
Created April 25, 2012 17:54
Parsing a comma-separated list of numbers and range specifications in Python
from itertools import chain
def parse_range(rng):
parts = rng.split('-')
if 1 > len(parts) > 2:
raise ValueError("Bad range: '%s'" % (rng,))
parts = [int(i) for i in parts]
start = parts[0]
end = start if len(parts) == 1 else parts[1]
if start > end:
@jasonrudolph
jasonrudolph / 00-about.md
Created September 21, 2012 18:42
Rough Notes from Strange Loop 2012
@andreas-h
andreas-h / test_gridded_array.py
Created September 26, 2012 13:49
Design of a n-dimensional array-like object with dimension variables
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
*****************************************************************************
Design document for a ``gridded_array`` class
*****************************************************************************
:Author: Andreas Hilboll <andreas@hilboll.de>
:Date: Wed Sep 26 14:48:57 2012
@pprett
pprett / grid_search.py
Created October 31, 2012 19:42
Parallel grid search for sklearn Gradient Boosting
"""Parallel grid search for sklearn's GradientBoosting.
This script uses IPython.parallel to run cross-validated
grid search on an IPython cluster. Each cell on the parameter grid
will be evaluated ``K`` times - results are stored in MongoDB.
The procedure tunes the number of trees ``n_estimators`` by averaging
the staged scores of the GBRT model averaged over all K folds.
You need an IPython ipcluster to connect to - for local use simply
@damianavila
damianavila / remove_output.py
Created April 3, 2013 22:05
Remove output from IPython notebook from the command line (dev version 1.0)
"""
Usage: python remove_output.py notebook.ipynb [ > without_output.ipynb ]
Modified from remove_output by Minrk
"""
import sys
import io
import os
from IPython.nbformat.current import read, write