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/bash | |
SOCKS_PORT='' | |
LOCAL_PORT='5525' | |
SSH_HOST='sccs.swarthmore.edu' | |
TARGET_HOST='smtp.swarthmore.edu' | |
TARGET_PORT='25' | |
while getopts 'D:p:s:h:P:' OPTION | |
do |
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/bash | |
# Note: you might prefer latexmk -c since latexmk is great. It doesn't clean all of these, but see | |
# https://tex.stackexchange.com/questions/83341/clean-bbl-files-with-latexmk-c/83386#83386 | |
exts=".aux .lof .log .lot .fls .out .toc .dvi .bbl .bcf .blg -blx.aux -blx.bib -blx.bib .run.xml .fdb_latexmk .synctex.gz .syntex.gz(busy) .pdfsync .algorithms .alg .loa .thm .nav .snm .vrb .acn .acr .glg .glo .gls .brf .lol .idx .ilg .ind .ist .maf .mtc .mtc0 .pyg .nlo .tdo .xdy .keys" | |
for x in "${@:-.}"; do | |
arg=$(echo ${x:-.} | perl -pe 's/\.(tex|pdf)$//') |
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 | |
# hg-to-git | |
# sets up a clone of a remote mercurial repository to a git repo | |
# relies on the wonderful tools from http://repo.or.cz/w/fast-export.git | |
PROJ_NAME=$1 | |
HG_REMOTE=$2 | |
GIT_REMOTE=$3 | |
echo "---- making the project in $PROJ_NAME" |
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 django.core.management.base import NoArgsCommand, CommandError | |
from django.conf import settings | |
import datetime | |
import sys, os, os.path | |
DUMP_DIRECTORY = os.path.expanduser("~/db-backups/") | |
DUMP_PATTERN = "gazjango_%Y-%m-%d_%H-%M.sql.bz2" | |
class Command(NoArgsCommand): | |
def handle_noargs(self, **options): |
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 django.core.management.base import NoArgsCommand | |
from gazjango.misc.management.commands.backup_db import DUMP_DIRECTORY, DUMP_PATTERN | |
import os, re | |
DUMP_MATCHER = re.compile(r"^%s$" % re.sub(r'\\%[a-zA-Z]', | |
r'.+', | |
re.escape(DUMP_PATTERN))) | |
NUM_TO_SAVE = 8 | |
class Command(NoArgsCommand): |
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 | |
import lxml.html | |
import urllib | |
import Queue | |
import re | |
import sys | |
import threading | |
doc = lxml.html.parse(sys.argv[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
#!/bin/sh | |
while true; do | |
$* | |
sleep 30 | |
done |
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 __future__ import division | |
import random | |
from collections import defaultdict | |
def find_pmf(fun, iters=100000): | |
counts = defaultdict(int) | |
for i in range(iters): | |
counts[fun()] += 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
#include <stdio.h> | |
#include <stdlib.h> | |
// Prompts the user for two times (in hh:mm format) and outputs | |
// the difference between them, assuming they're on the same day. | |
// No error checking. | |
int main() { | |
int hours1, minutes1, hours2, minutes2; | |
int hourDiff, minuteDiff; |
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 | |
# A little script to move the times in SRT subtitle files to | |
# align properly with your video. | |
import datetime | |
import re | |
time_re = re.compile(r'(\d\d):(\d\d):(\d\d),(\d\d\d)') | |
def next(i): # for python 2.5 |
OlderNewer