Skip to content

Instantly share code, notes, and snippets.

@whophil
whophil / git-latexdiff.sh
Last active March 14, 2016 09:07
Shell script to run latexdiff against a TeX file (with specified commit hash) from the current repository.
#!/usr/bin/env bash
# Shell script to run latexdiff against the same file from a specified commit hash.
# Example:
# ./git-latexdiff.sh main.tex 12dfa1a
# $1 is the name of the old tex file (relative to the remote repo)
# $2 is the hash of the commit that we'd like to compare against
@whophil
whophil / latex.sublime-project
Last active March 24, 2016 22:42
Sublime Text: Barebones LaTeX .sublime-project file (with file_exclude_patterns for LaTeX projects)
{
"folders":
[
{
"path": "path/to/your/project",
"file_exclude_patterns" :
[
"*.aux",
"*.bbl",
"*.blg",
@whophil
whophil / module-docstring.py
Last active April 7, 2016 23:02
Docstring for Python method (NumPy-style, for Sphinx compatibility)
"""One line description of a module level function.
The longer, optionally multi-line description goes here. This may have multiple
sentences and multiple lines.
Parameters
----------
param1 : int
The first parameter.
param2 : Optional[str]
@whophil
whophil / conf.py
Last active April 11, 2016 15:51
Sphinx extensions: autodoc, napoleon
sys.path.insert(0, os.path.abspath('.'))
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
'nbsphinx'
]
@whophil
whophil / conf.py
Last active April 11, 2016 15:52
Configuration for Sphinx readthedocs html theme.
# requires sphinx_rtd_theme to be installed on the build machine
# $ pip install sphinx_rtd_theme
import sphinx_rtd_theme
html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
@whophil
whophil / git-latexdiff.sh
Last active April 17, 2016 02:27 — forked from arthurd2/git-latexdiff.sh
Produces a diff PDF of a LaTeX repo against a specified hash using latexdiff.
#!/usr/bin/env bash
# Shell script to run latexdiff against the same file from a specified commit hash.
# Example:
# ./git-latexdiff.sh main.tex 12dfa1a
# $1 is the name of the old tex file (relative to the remote repo)
# $2 is the hash of the commit that we'd like to compare against
@whophil
whophil / create-docker-openvpn.sh
Created December 5, 2015 02:15
Complete setup of a containerized OpenVPN server based on kylemanna/openvpn.
#!/bin/sh
#
# This script creates the configuration for an OpenVPN server (in Docker)
# and runs it. A client configuration file is saved OVPN_CLIENT_FILENAME.
# The OpenVPN docker container creates a volume container with the name
# given by OVPN_DATA_NAME. The OpenVPN server docker is exposed on the port
# OVPN_EXTERNAL_PORT.
OVPN_DATA_NAME="ovpn-data"
OVPN_SERVER_HOSTNAME="udp://pups.ddns.net"
@whophil
whophil / recursive_glob.py
Last active August 2, 2018 02:55
Recursive glob in Python: Find all files matching a glob-style pattern. Adapted from http://stackoverflow.com/a/2186565/6191541
import os
import fnmatch
def recursive_glob(rootdir='.', pattern='*'):
"""Search recursively for files matching a specified pattern.
Adapted from http://stackoverflow.com/questions/2186525/use-a-glob-to-find-files-recursively-in-python
"""
matches = []
@whophil
whophil / ipython-notebook.conf
Last active August 18, 2018 05:15
Upstart file (Ubuntu) for Jupyter / IPython notebook
start on filesystem or runlevel [2345]
stop on shutdown
description "Jupyter / IPython Notebook Upstart script"
script
export HOME="/home/phil/Notebooks"; cd $HOME
echo $$ > /var/run/ipython_start.pid
exec su -s /bin/sh -c 'exec "$0" "$@"' phil -- /home/phil/Enthought/Canopy_64bit/User/bin/jupyter-notebook --config='/home/phil/.jupyter/jupyter_notebook_config.py'
end script
@whophil
whophil / .gitignore
Last active January 16, 2019 09:53
.gitignore for LaTeX projects (ignoring *.sublime-workspace files)
## SublimeText Workspace
*.sublime-workspace
## Main PDF file
main.pdf
## Core latex/pdflatex auxiliary files:
*.aux
*.lof
*.log