Skip to content

Instantly share code, notes, and snippets.

@drewsberry
drewsberry / dollars-to-html.py
Created September 18, 2014 15:16
Replace equations $ ... $ or $$ ... $$ with KaTeX HTML using Python
import re
import execjs
def find_equations(string):
""" Take in a string, and convert everything between $ ... $ into an inline
equation and everything between $$ ... $$ into a centred equation. """
doubledollar = re.compile(ur"\$\$([^$]+)\$\$")
singledollar = re.compile(ur"(?<![\$])\$([^$]+)\$(?!\$)")
@miki725
miki725 / .bash_prompt.sh
Last active June 25, 2024 08:57
Custom bash prompt which displays: (virtualenv) user:/path (git-branch)
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch of the current git/mercurial repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
@Ignas
Ignas / postgresql.mk
Created January 25, 2012 13:52
Set up for a local postgresql database using a Makefile
export PGPORT ?= 4488
PG_PATH ?= $(shell if test -d /usr/lib/postgresql/9.1; then echo /usr/lib/postgresql/9.1; else echo /usr/lib/postgresql/8.4; fi)
PG_DIR = ${PWD}/instance/var
PG_DATA = ${PG_DIR}/data
PG_RUN = ${PG_DIR}/run
PG_LOG = ${PG_DIR}/log
PG_SOCKET = ${PG_RUN}/.s.PGSQL.${PGPORT}
PGPARAMS = -D ${PG_DATA} -o "-F -c unix_socket_directory=${PG_RUN} -c custom_variable_classes='busy' -c busy.active_user=0" -l ${PG_LOG}/pg.log