Skip to content

Instantly share code, notes, and snippets.

View SethMMorton's full-sized avatar

Seth Morton SethMMorton

View GitHub Profile
@SethMMorton
SethMMorton / patch_doctest.py
Created May 19, 2015 03:29
Script to patch the doctest standard library module to be able to work on C extension modules.
"""\
Copies doctest.py from the stdlib to the current directory,
and modifies it so that
a) It will load "*.so" files as modules just like a "*.py" file
b) It recognizes functions defined in "*.so" files
c) Remove the configuration extension from the "*.so" files (on Python3)
With these enhancements, doctest can be run on a C python extension module.
"""
@SethMMorton
SethMMorton / countwords.py
Created June 9, 2012 16:49
Count the most common words in a [LaTeX] file, ignoring common words (the, an, etc...)
#! /usr/bin/env python
from __future__ import print_function, division
import sys
import re
from subprocess import Popen, PIPE
from collections import defaultdict
from operator import itemgetter
######################################################
@SethMMorton
SethMMorton / .bashrc
Created June 9, 2012 16:45
General Linux .bashrc
#! /bin/bash
############################################################################
# DON'T PUT ANY CUSTOMIZATIONS HERE (THEY MAY GET OVERWRITTEN BY THE SYSTEM)
############################################################################
# Source global definitions
if [ -f /etc/bashrc ]; then # Fedora
. /etc/bashrc
elif [ -f /etc/bash.bashrc ]; then # Debian
@SethMMorton
SethMMorton / .profile
Created June 9, 2012 16:03
General Mac OS X .profile
#!/bin/bash
# Global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Change the window title of X terminals (similar to Fedora's)
export PS1="[\u@\h \W]\\$ "
export PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'