Skip to content

Instantly share code, notes, and snippets.

Benjamin Keating bkeating

Block or report user

Report or block bkeating

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View countdown_to_newyear.py
# Depends on the OS X "say" command
import time, datetime, subprocess, math, sys
def say(s):
subprocess.call(['say', str(s)])
def seconds_until(dt):
return time.mktime(dt.timetuple()) - time.time()
View .gitignore
*.pyc
.DS_Store
build
db
local_settings.py
media
pip-log.txt
whoosh_index
@bkeating
bkeating / howto-filemerge-git-osx.md
Created Mar 11, 2010
HOWTO: Using FileMerge (opendiff) with Git on OSX
View howto-filemerge-git-osx.md

HOWTO: Using FileMerge (opendiff) with Git on OSX

FileMerge (opendiff) can really come in handy when you need to visually compare merging conflicts. Other times it's just a nice visual way to review your days work.

The following method works by creating a simple bash script (git-diff-cmd.sh) that sets us up with the proper command line arguments for Git to pass off files to FileMerge.

View get_longbets_comments.py
# -*- coding: utf-8 -*-
import datetime as dt
import dateutil.parser as dparser
import urllib2
from BeautifulSoup import BeautifulSoup
print "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
print "<articles>"
# Loop through each prediction and bet URL.
View get_longbets_comments.py
# -*- coding: utf-8 -*-
import datetime as dt
import dateutil.parser as dparser
import urllib2
from BeautifulSoup import BeautifulSoup
print "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
print "<articles>"
# Loop through each prediction and bet URL.
View php-fastcgi upstart configuration
# php-fastcgi - web server
description "php-fastcgi - keep up php-fastcgi"
author "Ben Keating <ben@deepdream.com>"
start on runlevel [2345]
stop on runlevel [!2345]
expect fork
respawn
@bkeating
bkeating / tab2xml.py
Created Nov 18, 2010
Converts ethnologue.com's LanguageCodes.tab file into XML.
View tab2xml.py
import csv
reader = csv.reader(open("/path/to/LanguageCodes.tab"), delimiter="\t")
print '<?xml version=\"1.0\" encoding=\"UTF-8\" ?>'
for row in reader:
print "<item>"
print " <LangID>" + row[0] + "</LangID>"
print " <CountryID>" + row[1] + "</CountryID>"
@bkeating
bkeating / wordpress-wxr-example.xml
Created Feb 23, 2011
A vanilla example of the WordPress WXR Schema. Im using this as a starting point to build my own comments importer for disqus.com
View wordpress-wxr-example.xml
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dsq="http://www.disqus.com/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/1.0/"
>
<channel>
<item>
<!-- title of article -->
@bkeating
bkeating / get_dns_zones.sh
Created May 19, 2011
Amazon Route 53 DNS - Get your DNS hosted zone list
View get_dns_zones.sh
# Stick this in your ``.profile`` to make for a quick and easy way to get your
# Route 53 hosted zone list(s). NOTE: Make sure ``dnscurl.pl`` in in your $PATH.
# UNFINISHED! I added a pipe to tidy (to prettify the xml) but i haven't yet cut out the non-xml output. Will need to do this with sed or something... Ideas?
function get_dns_zones() {
dnscurl.pl --keyfile ~/.aws-secrets --keyname $1 -- -v -H "Content-Type: text/xml; charset=UTF-8" https://route53.amazonaws.com/2010-10-01/hostedzone | tidy -xml -i -q;
}
###
@bkeating
bkeating / gunicorn_upstart.conf
Created Sep 13, 2011
An example of my Upstart script that can start/stop a Django project.
View gunicorn_upstart.conf
# PROJECT_NAME.conf - run PROJECT_NAME gunicorninstances
#
# This runs gunicorn_django for PROJECT_NAME; to install:
# * sudo ln -s <this file> /etc/init/PROJECT_NAME.conf
# * sudo initctl reload-configuration
# to use:
# * sudo start/stop/restart/reload/status PROJECT_NAME
#
# For a full list of configuration options: http://gunicorn.org/configure.html
You can’t perform that action at this time.