Skip to content

Instantly share code, notes, and snippets.

View newville's full-sized avatar

Matt Newville newville

View GitHub Profile
@newville
newville / build.sh
Created April 26, 2016 14:49
hyperlinks with sphinxcontrib-bibtex
sphinx-build -b html -d _build/doctrees -D latex_paper_size=letter . _build/html
sphinx-build -b html -d _build/doctrees -D latex_paper_size=letter . _build/html
@newville
newville / interp_bench.py
Last active August 29, 2015 14:16
Numpy interp() benchmark
from __future__ import print_function
import sys
import timeit
import numpy as np
np.random.seed(0)
ndata=20000
# data to ne interpolated
xp = np.linspace(0, 10, 1+ndata)
@newville
newville / gist:8c1759a295e93fef984f
Last active February 13, 2023 12:59
rendering Angstrom Symbol with Mathjax and sphinx
MathJax doesn't directly support the Angstrom symbol, TeX's \AA. This is painful in many
fields, notably those that work with X-rays.
To use mathjax with the Sphinx documentation system, one would put
extensions = ['sphinx.ext.mathjax', ...]
in conf.py. But this will not understand \AA as the Angstrom symbol.
The solution is to add a Mathjax configuration script to each HTML file produced by sphinx.
@newville
newville / pdf2png.py
Created October 20, 2013 03:08
pdf2png
#!/usr/bin/env python
"""Convert PDF to PNG with convert program
"""
import sys
import subprocess
import getopt
convert = "convert -antialias -alpha on -channel rgba -fuzz 5%"
density = 600
quality = 90
@newville
newville / isi2bibtex.py
Created October 15, 2013 16:36
Convert ISI Web of Science Plaintext to bibtex
#!/usr/bin/env python2.7
"""
translate ISI bibliography (in plaintext) to bibtex
isi2bib savedrecs.txt > savedrecs.bib
Notes:
1. this script tries very hard to make sensible lists
of author names, but the task is hard, and results
should be checked carefully.