Skip to content

Instantly share code, notes, and snippets.

View takluyver's full-sized avatar

Thomas Kluyver takluyver

View GitHub Profile
@takluyver
takluyver / Equation tables.ipynb
Created February 27, 2017 15:46
Test Jupyter mathjax in tables issue
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@takluyver
takluyver / debug_namespace_pkg.py
Last active February 22, 2017 12:06
Debug Python namespace packages
"""Script to debug problems with namespace packages.
Set the PACKAGE variable below and run this script with the same Python you're having problems with.
"""
from __future__ import print_function
# Set this to the name of the namespace package you're having problems with
PACKAGE = "backports"
@takluyver
takluyver / gist:b21327677f70dfa6a6d7ccc016134841
Created December 13, 2016 10:59
Memory map - pygame test crash
======= Memory map: ========
00400000-007a8000 r-xp 00000000 08:02 1179705 /usr/bin/python3.5
009a8000-009aa000 r--p 003a8000 08:02 1179705 /usr/bin/python3.5
009aa000-00a41000 rw-p 003aa000 08:02 1179705 /usr/bin/python3.5
00a41000-00a72000 rw-p 00000000 00:00 0
00d0f000-01339000 rw-p 00000000 00:00 0 [heap]
7f3818000000-7f3818021000 rw-p 00000000 00:00 0
7f3818021000-7f381c000000 ---p 00000000 00:00 0
7f3820000000-7f3820021000 rw-p 00000000 00:00 0
7f3820021000-7f3824000000 ---p 00000000 00:00 0
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@takluyver
takluyver / prompts-startup.py
Created August 21, 2016 16:09
My custom IPython prompts
# encoding: utf-8
from IPython.terminal.prompts import Prompts, Token
import os
class MyPrompts(Prompts):
def in_prompt_tokens(self, cli=None):
return [
(Token, ' '),
(Token.PromptNum, str(self.shell.execution_count)),
(Token.Prompt, u'│ '),
@takluyver
takluyver / make_nb.py
Created July 21, 2016 13:09
Make a notebook from a script
"""Create a notebook containing code from a script.
Run as: python make_nb.py my_script.py
"""
import sys
import nbformat
from nbformat.v4 import new_notebook, new_code_cell
nb = new_notebook()
import numpy
def f():
a = numpy.random.random(1e8)
raise Exception
@takluyver
takluyver / example
Created May 13, 2016 19:17
Debug on interrupt
$ python3 interrupt-debug.py
0
1
2
3
^C--Return--
> /home/takluyver/scratch/interrupt-debug.py(6)handle_sigint()->None
-> pdb.set_trace()
(Pdb) p a
4
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.