Skip to content

Instantly share code, notes, and snippets.

View dtanham's full-sized avatar

Dan Tanham dtanham

View GitHub Profile
@dtanham
dtanham / Install_Pillow.sh
Created May 6, 2014 20:36
Installing Pillow on OS X
source venv/bin/activate # Remove if not using a virtualenv
export CFLAGS=-Qunused-arguments # /headbashing
pip install Pillow # Install with pip
python -c "import PIL" # Verify it worked
@dtanham
dtanham / mail.py
Created April 26, 2014 17:54
Python SMTP mailer class for HTML and plain text email
import os
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
class Mailer:
def __init__(self, **kwargs):
mandatory_args = ["username","password","server","port"]
for x in mandatory_args:
@dtanham
dtanham / flush-iptables.sh
Created January 27, 2014 12:43
Remove firewall rules from default Debian build
#!/bin/sh
# This file will reset the firewall to allow everything.
#
# Set the default policy
#
/sbin/iptables -P INPUT ACCEPT
/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables -P OUTPUT ACCEPT
#
# Set the default policy for the NAT table
import parsedatetime.parsedatetime as pdt
def datetimeFromString( s ):
c = pdt.Calendar()
result, what = c.parse( s )
dt = None
# what was returned (see http://code-bear.com/code/parsedatetime/docs/)
@dtanham
dtanham / param_substitution.js
Created April 21, 2013 17:41
Very simple parameter subsitution in JS. Arguments are string containing parameter placeholders and a corresponding object of keys and values. Depends on jQ.
// Return s, with parameters substituted as in key-values of object params
function subsituteParams(s, params) {
$.each(params, function(k,v) {
s = s.replace(k,v);
});
return s;
}