Skip to content

Instantly share code, notes, and snippets.

View mdboom's full-sized avatar

Michael Droettboom mdboom

View GitHub Profile
We couldn’t find that file to show.
@mdboom
mdboom / pth_list_init.diff
Created June 21, 2011 22:07
Initialize pth_list pointer to prevent AttributeError in imp.reload
diff -r 2c353e4e2488 Python/import.c
--- a/Python/import.c Sun Jun 12 22:18:12 2011 +0200
+++ b/Python/import.c Tue Jun 21 18:03:42 2011 -0400
@@ -3763,7 +3763,7 @@
PyObject *modules_reloading = interp->modules_reloading;
PyObject *modules = PyImport_GetModuleDict();
PyObject *path_list = NULL, *loader = NULL, *existing_m = NULL;
- PyObject *nameobj, *bufobj, *subnameobj, *pth_list;
+ PyObject *nameobj, *bufobj, *subnameobj, *pth_list = NULL;
Py_UNICODE *name, *subname;
@mdboom
mdboom / font_styles.py
Created March 22, 2012 15:30
Test font styling support in matplotlib (#788)
import matplotlib
matplotlib.use("Agg")
from matplotlib import _get_data_path
data_path = _get_data_path()
def find_matplotlib_font(**kw):
prop = FontProperties(**kw)
path = findfont(prop, directory=data_path)
return FontProperties(fname=path)
@mdboom
mdboom / pre_transform_data.svg
Created August 23, 2012 16:56
pre_transform_data.svg failure
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mdboom
mdboom / serve_figure.py
Created October 11, 2012 19:05
Proof of concept code for serving interactive matplotlib figures to the webbrowser
import json
import tornado.web
import tornado.ioloop
import numpy as np
import matplotlib
matplotlib.use('Agg')
@mdboom
mdboom / gist:4111227
Created November 19, 2012 15:19
SVG inheritance diagram
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="576pt" height="149pt" viewBox="0 0 576 149" version="1.1">
<defs>
<g>
<symbol overflow="visible" id="glyph0-0">
<path style="stroke:none;" d="M 0 2 L 0 -6 L 5 -6 L 5 2 Z M 1 1 L 4 1 L 4 -5 L 1 -5 Z "/>
</symbol>
<symbol overflow="visible" id="glyph0-1">
<path style="stroke:none;" d="M 3.359375 -2 C 2.847656 -2 2.492188 -1.957031 2.296875 -1.875 C 2.097656 -1.800781 2 -1.671875 2 -1.484375 C 2 -1.335938 2.070312 -1.21875 2.21875 -1.125 C 2.375 -1.039062 2.578125 -1 2.828125 -1 C 3.179688 -1 3.460938 -1.078125 3.671875 -1.234375 C 3.890625 -1.398438 4 -1.617188 4 -1.890625 L 4 -2 Z M 5 -2.53125 L 5 0 L 4 0 L 4 -1 C 3.832031 -0.65625 3.625 -0.398438 3.375 -0.234375 C 3.132812 -0.078125 2.832031 0 2.46875 0 C 2.019531 0 1.660156 -0.128906 1.390625 -0.390625 C 1.128906 -0.648438 1 -1.003906 1 -1.453125 C 1 -1.960938 1.175781 -2.347656 1.53125 -2.609375 C 1.882812 -2.867188 2.410156 -3 3.
@mdboom
mdboom / gist:4112950
Created November 19, 2012 19:09
Patch against Agg-2.4 so overly-complex paths can be handled gracefully by matplotlib
--- agg-2.4/include/agg_rasterizer_cells_aa.h 2006-06-23 16:35:22.000000000 -0400
+++ matplotlib/agg24/include/agg_rasterizer_cells_aa.h 2012-11-19 14:02:54.755434558 -0500
@@ -29,15 +29,14 @@
#ifndef AGG_RASTERIZER_CELLS_AA_INCLUDED
#define AGG_RASTERIZER_CELLS_AA_INCLUDED
+#include <stdexcept>
#include <string.h>
#include <math.h>
#include "agg_math.h"
@mdboom
mdboom / np_filter.py
Created January 7, 2013 21:23
Filter an IPython notebook so that lines of console output that were written over by carriage return characters (\\r) are removed.
"""
Filter an IPython notebook so that lines of console output that were
written over by carriage return characters (\\r) are removed.
This is a UNIX filter, so use as::
cat my_notebook.ipynb | nb_filter.py > my_notebook.filtered.ipynb
"""
import json
@mdboom
mdboom / gist:5109600
Created March 7, 2013 16:52
glxinfo on my machine
name of display: :1.0
display: :1 screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
GLX_ARB_create_context, GLX_ARB_create_context_profile,
GLX_ARB_multisample, GLX_EXT_create_context_es2_profile,
GLX_EXT_import_context, GLX_EXT_texture_from_pixmap, GLX_EXT_visual_info,
GLX_EXT_visual_rating, GLX_INTEL_swap_event, GLX_MESA_copy_sub_buffer,
@mdboom
mdboom / alignment.py
Created April 15, 2013 22:27
Test script for vertical text alignment
from matplotlib.pyplot import *
import matplotlib
matplotlib.use("agg")
text(0.1, 0.5, "Top Tj", verticalalignment="top")
text(0.2, 0.5, "Bottom Tj", verticalalignment="bottom")
text(0.3, 0.5, "Base Tj", verticalalignment="baseline")
text(0.4, 0.5, "Center Tj", verticalalignment="center")
text(0.5, 0.5, "Top Tj", rotation=30, verticalalignment="top")
text(0.6, 0.5, "Bottom Tj", rotation=30, verticalalignment="bottom")