Skip to content

Instantly share code, notes, and snippets.

View ellisonbg's full-sized avatar

Brian E. Granger ellisonbg

View GitHub Profile
@ellisonbg
ellisonbg / xkcdify.py
Created September 23, 2013 23:50
XKCD mode for the IPython Notebook
def xkcdify(borders=True, code=True, html=True, prompts=True, output=True,
font_url='https://github.com/ipython/xkcd-font/raw/master/build/xkcd.otf'):
"""Turn on xkcd mode for the notebook.
Run this in your notebook and it will enable the xkcd regular font
from the xkcd website. This font is downloaded from the internet
so this only works if you are online.
This mode can be used with Matplotlib's new xkcd mode to great effect. However,
you will have to enable that separately by calling matplotlibs xkcd function.
@ellisonbg
ellisonbg / RandomKerningText.ipynb
Last active December 21, 2015 21:48
Text for kerning fonts
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ellisonbg
ellisonbg / 1093.csv
Last active December 19, 2015 17:39
xkcdify for IPython
By this year: The majority of Americans will be too young to remember:
2012 The seventies
2013 The Carter Presidency
2014 The Reagan shooting
2015 The Falkland Islands war
2016 Return of the Jedi release
2017 The first Apple Macintosh
2018 New Coke
2019 Challenger
2020 Chernobyl
@ellisonbg
ellisonbg / TwitterNetworkX.ipynb
Created October 5, 2012 02:47
Twitter NetworkX IPython Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ellisonbg
ellisonbg / test_basic.js
Created August 12, 2012 05:30
Simple test of IPython Notebook using phantomjs and casperjs
// Simple IPython Notebook test
// Requires PhantomJS and CasperJS.
// To run:
// 1) Start a notebook server in an empty directory.
// 2) casperjs test_basic.js
var casper = require('casper').create({
// verbose: true,
// logLevel: "debug"
});
@ellisonbg
ellisonbg / OutputArea.append_svg
Created June 8, 2012 17:45
Prototype of resizable SVG images
OutputArea.prototype.append_svg = function (svg, element) {
var toinsert = $("<div/>").addClass("box-flex1 output_subarea output_svg");
toinsert.append(svg);
element.append(toinsert);
// The <svg> tag cannot be made resizable so we wrap it in a resizable <div>.
// The problem with this is that we need to 1) set the initial size of the
// <div> based on the size of the <svg> and 2) we need to tie the size of the
// <div> and the <svg>.
var img = $('<div/>');
img.html(svg);
@ellisonbg
ellisonbg / cython_magic.ipynb
Created May 24, 2012 06:50
Cython Magic using pyximport
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ellisonbg
ellisonbg / cython_inline_magic.ipynb
Created May 24, 2012 05:54
Cython inline IPython magic
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ellisonbg
ellisonbg / d3.ipynb
Created February 16, 2012 01:32
How to use d3 with the IPython notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import networkx as nx
import matplotlib as mat
# Builds a graphene sheet with the given number of rows and columns.
# The sheet has a defected column running through the optionally passed
# arg. Otherwise it defaults to the center.
def build_defected_graph(rows, columns, defect = 0):
g = nx.Graph()
if( columns <= 2 ):