Skip to content

Instantly share code, notes, and snippets.

View eriwen's full-sized avatar

Eric Wendelin eriwen

View GitHub Profile
@eriwen
eriwen / x
Created April 17, 2009 04:21
DZone command for Mozilla Ubiquity
CmdUtils.CreateCommand({
names: ["dzone", "dz"],
homepage: "http://eriwen.com/extras/dzone.html",
icon: "http://www.dzone.com/favicon.ico",
author: { name: "Eric Wendelin", email: "[email protected]" },
license: "GPL",
description: "Submit the current page to DZone",
help: "Running this command will submit the current page to DZone",
_title: function() {
@eriwen
eriwen / gist:187610
Created September 15, 2009 20:21 — forked from sanbornm/gist:177420
Pythonic site monitor
#!/usr/bin/env python
# sample usage: checksites.py eriwen.com nixtutor.com yoursite.org
import pickle, os, sys, logging
from httplib import HTTPConnection, socket
from smtplib import SMTP
def email_alert(message, status):
fromaddr = '[email protected]'
@eriwen
eriwen / gist:188105
Created September 16, 2009 15:33
apache httpd performance settings
# Set expires header and Remove ETags
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)(\.gz)?$">
Header set Expires "Thu, 15 Apr 2012 20:00:00 GMT"
Header unset ETag
FileETag None
</FilesMatch>
# Set cache-control header
<FilesMatch "\.(ico|jpg|png|gif)(\.gz)?$">
Header set Cache-Control "public"
@eriwen
eriwen / check_feedburner.py
Created November 4, 2009 21:30
check_feedburner.py
#!/usr/bin/env python
# Usage: ./check_feedburner.py MyFeedName
import re, sys, urllib, fileinput
from xml.dom import minidom
AWARENESS_API_URL = 'https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=%s'
# If you want to replace the feedburner count in a given file, define it here
FEED_COUNT_FILE = '/path/to/your/file.php'
@eriwen
eriwen / userChrome.css
Created November 6, 2009 15:52
userChrome.css
/* Do not remove the @namespace line -- it's required for correct functioning */
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* Add a keyword when adding a bookmark */
#keywordRow { display: -moz-grid-line !important; }
/* Remove extra padding from the Navigation Bar */
.toolbarbutton-1, .toolbarbutton-menubutton-button {
padding: 2px 3px !important;
}
@eriwen
eriwen / memoize_decorator.py
Created July 13, 2010 23:37
Memoize Decorator in Python
def memoize(fn):
cache = {}
def wrapper(*args):
try:
return cache[args]
except:
result = fn(*args)
cache[args] = result
return result
return wrapper
@eriwen
eriwen / ip_to_hex.py
Created July 14, 2010 21:16
IP Address to hex
#!/usr/bin/env python
import sys, re
ip_regex = re.compile('(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})')
ip_match = ip_regex.match(sys.argv[1])
if (ip_match == None):
print 'Invalid address'
sys.exit(1)
hex_ip_addr = 0
for i in range(1,5):
@eriwen
eriwen / git_puller.sh
Created August 28, 2010 16:59
Git repo updater
#!/bin/bash
# Git repository updater | Spencer Tipping
# Run this from a cron job to update all repos on a regular basis.
for file in *; do
[[ -d $file && -d $file/.git ]] || continue
cd $file
${GIT:-git} pull >& /dev/null || echo "Failed to update $file: $(${GIT:-git} pull 2>&1)"
cd ..
done
@eriwen
eriwen / eriwen-static-build.xml
Created September 26, 2010 05:02
YUI Compressor ant build for static content
<project name="eriwen-static" default="prod" basedir=".">
<property name="src.dir" location="${basedir}/static" />
<property name="js.version" value="2" />
<property name="css.version" value="17" />
<target name="prod" depends="js.concatenate, js.minify, css.minify"
description="Full production build">
</target>
<target name="load.properties">
@eriwen
eriwen / pretty_thunderbird_labels.css
Created December 29, 2010 00:12
userChrome.css snippet for Thunderbird to have pretty labels
/* Default Important Label */
treechildren::-moz-tree-cell(lc-FF0000) {
border-bottom: 1px solid #FF0000 !important; background-color: #FFCCCC !important;
}
treechildren::-moz-tree-cell-text(lc-FF0000) {
color: #000000 !important;
}
treechildren::-moz-tree-cell(lc-FF0000, selected) {
background-color: #FF0000 !important;
}