This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# converts the input string with underscores from eg lower_camel_case to lowerCamelCase (do you like what I did with the name there?) | |
# should work reasonably on anything with vaguely C-like syntax (not LISP probably, but who really cares?) | |
from contextlib import nested | |
def camelCaseWord(underscored): | |
output_vals = [] | |
prev_idx = 0 | |
und_idx = underscored.find('_') | |
while und_idx != -1: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% commands to get pdflatex to output in letter format | |
\special{papersize=8.5in,11in} | |
\setlength{\pdfpageheight}{\paperheight} | |
\setlength{\pdfpagewidth}{\paperwidth} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python -Wignore::DeprecationWarning | |
""" | |
Call this as a cron script to check for replication problems | |
""" | |
import MySQLdb | |
DB_HOST = '127.0.0.1' | |
DB_USER = 'USERNAME' | |
DB_PASSWD = 'PASSWORD' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# use with cron entries such as: | |
#3 */2 * * * $HOME/bin/mysql-backup.sh dbname backupname hourly H | |
#8 1 * * * $HOME/bin/mysql-backup.sh dbname backupname daily a | |
#33 2 1,8,15,23 * * $HOME/bin/mysql-backup.sh dbname backupname weekly d | |
#33 2 28 * * $HOME/bin/mysql-backup.sh dbname backupname monthly b | |
DB_NAME="$1" | |
BACK_ROOT="$2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grep install /usr/local/texlive/2010basic//texmf-var/web2c/tlmgr.log| perl -pi -e 's/.*install: //' | sudo xargs tlmgr install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%The following's adapted from the TeX Frequently Asked Questions - Rather than overwriting an old command it's common to want to add some code at the beginning or the end of it. Suppose we want a version of a command that does some small extension of its original definition: we might try: | |
\renewcommand{\splat}{addedcode\splat} | |
%However, this would not work: a call to \splat would execute addedcode, and then call the redefined \splat again; this is an infinite recursive loop. Fortunately, the TeX primitive \let command comes to our rescue; it allows us to take a "snapshot" of the current state of a command, which we can then use in the redefinition of the command. So: | |
\let\Oldsplat\splat | |
\renewcommand{\splat}{addedcode\Oldsplat} | |
%effects the required patch, safely. Adding things at the end of a command works similarly. | |
%If \splat takes arguments, one must pass them on: | |
\renewcommand{\splat}[2]{addedcode\Oldsplat{#1}{#2}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import division | |
import os | |
import sys | |
import optparse | |
""" | |
Designed for use with cron scripts, as in the default state it only prints output | |
when the free space it below the requested threshold. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gzip | |
import os | |
import errno | |
import codecs | |
from contextlib import nested | |
GZ_SUFF = '.gz' | |
BUFSIZE = 1048576 | |
def gzip_fname(filename): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from xml.etree import cElementTree as elemtree | |
from datetime import date | |
""" | |
Use this to parse XML from MeSH (Medical Subject Headings). More information | |
on the format at: http://www.ncbi.nlm.nih.gov/mesh | |
End users will primarily want to call the `parse_mesh` function and do something | |
with the output. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# use this for any package (such as ClearParser) which requires setting the | |
# classpath to a particular set of jar files | |
if [ -z $BASH_SOURCE ] ; then | |
echo "Script must be sourced (using '.' or 'source') and run under bash >= 3.0" | |
exit 1 | |
fi | |
script_path="${BASH_SOURCE%/*}" |
OlderNewer