Skip to content

Instantly share code, notes, and snippets.

View twneale's full-sized avatar

Thom Neale twneale

View GitHub Profile
@twneale
twneale / getcitations.py
Last active August 29, 2015 13:56
Basic uscode citation-to-neoid function.
import re
def citations(text):
rgx = u'(\\d+)\\s+U\\.?S\\.?C\\.?\\s*\xa7*\\s\\s*([\\d\\w\\-\\\u2013\\.\u2013]+)(\\([\\d\\w\\-\\\u2013\\.\u2013()]+\\))*'
matches = []
for match in re.finditer(rgx, text):
title, section, path = match.groups()
section = section.strip(u'\u2013.- ')
start, end = match.span()
usc25.xml:
- The xml for /us/usc/t25/s450l (Contract or grant specifications) contains a model agreement with its own internal
Thom Neale <twneale@gmail.com>
Apr 13
to Katherine
Hi Katherine, please forgive the earlier email fragment; I accidentally sent if before I was done typing.
@twneale
twneale / gist:86ac56607f48ab375e60
Created June 5, 2014 17:24
Duped US Code identifiers
[('/us/usc/t21/s812/b/1', 4),
('/us/usc/t21/s812/b/4', 4),
('/us/usc/t21/s812/b/5', 4),
('/us/usc/t21/s812/b/2', 4),
('/us/usc/t21/s812/a', 4),
('/us/usc/t21/s812/b', 4),
('/us/usc/t21/s812/b/3', 4),
('/us/usc/t21/s812/c', 4),
('/us/usc/t42/s14214/d/10', 3),
('/us/usc/t21/s812/a/1', 3),
@twneale
twneale / gist:ef11712e43991d671747
Created June 11, 2014 01:55
All hyperlinked citations in the Boston municipal code
Any person violating any provision of subsection
1-2.6
shall be punished by a fine not exceeding twenty ($20.00) dollars for each offense, and not only the
The provisions of subsection
2-12.3
to the contrary notwithstanding, this ordinance shall be published by the action of the City Council
@twneale
twneale / gpolocator.py
Created January 23, 2012 05:34
Getting GPO Locator data into a more usable form
# -*- coding: utf-8 -*-
'''
Usage:
>>> f = open('usc08.10')
>>> x = getlines(f)
>>> x.next()
GPOLocatorLine(code='F', arg='5800', data=u'\r\n')
>>> print x.next().data
TITLE 8–ALIENS AND NATIONALITY
@twneale
twneale / crawler.py
Created April 5, 2012 22:57 — forked from jmoiron/crawler.py
Simple gevent/httplib2 web crawler.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Simple async crawler/callback queue based on gevent."""
import traceback
import logging
import httplib2
import gevent
@twneale
twneale / ubuntu-neo4j.sh
Created July 28, 2012 20:17 — forked from quinn/ubuntu-neo4j.sh
neo4j on ubuntu
sudo apt-get install openjdk-6-jre-headless
curl -O http://dist.neo4j.org/neo4j-community-1.5.M02-unix.tar.gz
tar -xf neo4j-community-1.5.M02-unix.tar.gz
rm neo4j-community-1.5.M02-unix.tar.gz
neo4j-community-1.5.M02/bin/neo4j start
{'email': u'twneale@gmail.com',
'interests': [{'active': False,
'changed_at': datetime.datetime(2012, 11, 16, 21, 16, 33, 661000),
'filters': {'state': u'CA'},
'in': u'rent',
'interest_type': 'search',
'query_type': 'advanced',
'search_type': 'state_bills'}],
'notifications': 'email_daily',
'secret_key': 'openstates-scout-staging',
{u'actions': {u'added': 5, u'removed': 0},
u'user': {u'_id': u'50d34ac74a4ee9b329000001',
u'email': u'twneale@gmail.com',
u'interests': [{u'_id': u'50d3512c4a4ee90c4d000004',
u'created_at': u'2012-12-20T12:55:58-05:00',
u'filters': {u'state': u'CA'},
u'in': u'rent',
u'interest_type': u'search',
u'query_type': u'advanced',
u'updated_at': u'2012-12-20T12:55:58-05:00'},
{u'email': u'twneale@gmail.com',
u'interests': [{u'active': False,
u'changed_at': 1353100593.0,
u'filters': {u'state': u'CA'},
u'in': u'rent',
u'interest_type': u'search',
u'query_type': u'advanced',
u'search_type': u'state_bills'},
{u'active': True,
u'changed_at': 1353338983.0,