Skip to content

Instantly share code, notes, and snippets.

View bloomonkey's full-sized avatar

John Harrison bloomonkey

View GitHub Profile
@bloomonkey
bloomonkey / caselessDictionary.py
Created June 27, 2012 10:05
A Python dictionary sub-class that is case-insensitive when searching, but also preserves the keys as inserted.
class CaselessDictionary(dict):
"""A dictionary with case-insensitive keys.
A dictionary that is case-insensitive when searching, but also preserves
the keys as inserted.
"""
def __init__(self, initval={}):
if isinstance(initval, dict):
for key, value in initval.iteritems():
@bloomonkey
bloomonkey / addDoctype.py
Created July 30, 2012 11:58
Python (2.5 < v < 3.0) script to insert XHTML Doctype declaration at start of files where it's missing for a given directory
from __future__ import with_statement
import sys
import os
try:
myDir = sys.argv[1]
except IndexError:
myDir = os.getcwd()
for root, dirs, files in os.walk(myDir):
@bloomonkey
bloomonkey / subjectURIs.py
Created October 24, 2012 11:36
Generate Archives Hub URIs for records matching a given subject
"""Generate Archives Hub URIs for records matching a given subject.
Usage: %prog [options] subject
"""
import sys
import os
from contextlib import contextmanager
@bloomonkey
bloomonkey / tornadoSRU.py
Created October 25, 2012 09:47
Deploying Cheshire3's SRU Server in Tornado
import tornado.web
import tornado.httpserver
import tornado.wsgi
from cheshire3.web.sruWsgi import application
container = tornado.wsgi.WSGIContainer(application)
http_server = tornado.httpserver.HTTPServer(container)
http_server.listen(8888)
tornado.ioloop.IOLoop.instance().start()
@bloomonkey
bloomonkey / decypher.py
Last active December 17, 2015 07:39 — forked from davidtweaver/gist:5570661
Code Breaking. PyPool attempts to solve programming challenge: http://pi3.sites.sheffield.ac.uk/mini-challenges/chal6
"""Code Breaking.
PyPool attempts to solve programming challenge:
http://pi3.sites.sheffield.ac.uk/mini-challenges/chal6
"""
import string
# Encoded sentences
@bloomonkey
bloomonkey / numerals.py
Created June 11, 2013 07:09
Convert Roman numeral strings to integers #PyPool
"""Roman Numeral to Arabic Numbers.
Some doctests:
>>> convert_to_arabic('Nulla')
0
>>> convert_to_arabic('i')
1
>>> convert_to_arabic('v')
5

Keybase proof

I hereby claim:

  • I am bloomonkey on github.
  • I am bloomonkey (https://keybase.io/bloomonkey) on keybase.
  • I have a public key ASB7T45eCErQED60GdPMocBfSVFSQU6EfBRHN_y3LEPeSAo

To claim this, I am signing this object: