Skip to content

Instantly share code, notes, and snippets.

@jiffyclub
jiffyclub / mock_demo.ipynb
Created September 11, 2012 20:49
A short demo of the mock library in an IPython notebook.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiffyclub
jiffyclub / game_of_life.ipynb
Created September 24, 2012 21:15
Conway's Game of Life in an IPython Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiffyclub
jiffyclub / Decode.ipynb
Created October 4, 2012 03:41
Counting the number of ways to decode a string of numbers such as '123456' with a standard a = 1, b = 2, c = 3 encoding.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiffyclub
jiffyclub / nbviewer_bookmarklet.js
Created October 17, 2012 00:56
A bookmarklet that tries to open the current page in nbviewer. White space has been trimmed for brevity. To use make a new bookmark and copy the code below into the URL field.
javascript:date=new Date();
url_root='http://nbviewer.ipython.org/';
url=null;
if (location.href.search(/^https?:\/\/gist\.github\.com\/[0-9]+$/) !== -1) {
gist = location.href.match(/^https?:\/\/gist\.github\.com\/([0-9]+)$/);
url = url_root + gist[1];
} else if (location.href.search(/^https:\/\/.*\.ipynb$/) !== -1) {
path = location.href.match(/^https:\/\/(.*\.ipynb)$/);
url = url_root + 'urls/' + path[1];
} else if (location.href.search(/^http:\/\/.*\.ipynb$/) !== -1) {
@jiffyclub
jiffyclub / goodbad.py
Created October 20, 2012 01:04
Print the contents of two files to a two column HTML table with headings 'Good' and 'Bad'. Files need not have the same length.
#!/usr/bin/env python
"""
Print the contents of two files to a two column HTML table
with headings 'Good' and 'Bad'. Files need not have the same length.
"""
import argparse
import itertools
import sys
@jiffyclub
jiffyclub / gist:3967522
Created October 28, 2012 04:32
A demo of IPython's HTML and Javascript display functions to create a table and modify the color of its cells.
{
"metadata": {
"name": "TableFormatterDemo"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@jiffyclub
jiffyclub / runtests-magic.ipynb
Created November 3, 2012 02:06
A proof of concept idea for a test runner magic in IPython.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiffyclub
jiffyclub / ArrayMath.ipynb
Created November 4, 2012 17:42
Examples of NumPy array arithmetic with binary operators.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiffyclub
jiffyclub / runtests.py
Created November 4, 2012 20:28
An IPython %runtests magic that does some very basic test function discovery, running, and reporting within IPython.
from IPython.core.magic import register_line_magic
@register_line_magic
def runtests(line):
"""
The %runtests magic searches your IPython namespace for functions
with names that begin with 'test'. It will attempt to run these
functions (calling them with no arguments), and report whether they
pass, fail (raise an AssertionError), or error (raise any other
@jiffyclub
jiffyclub / runtests-demo.ipynb
Created November 5, 2012 00:22
Demo of installing and using the %runtests magic.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.