Skip to content

Instantly share code, notes, and snippets.

View jroo's full-sized avatar

jroo jroo

View GitHub Profile
@jroo
jroo / extract_legislation.py
Created February 22, 2009 19:01
return list of congressional bill numbers extracted from string
# return list of bill numbers extracted from string
import re
def extract_legislation(haystack):
haystack = haystack.upper()
p = re.compile('S\.?\s?CON\.?\s?RES\.?\s?\d{1,5}|H\.?\s?CON\s?RES\.?\s?\d{1,5}|S\.?\s?J\.?\s?RES\.?\s\d{1,5}|H\.?\s?J\.?\s?RES\.?\s\d{1,5}|S\.?\s?RES\.?\s?\d{1,5}|H\.?\s?RES\.?\s?\d{1,5}|H\.?\s?\R\.?\s?\d{1,5}|S\.?\s?\d{1,5}')
needle_list = p.findall(haystack)
return needle_list
@jroo
jroo / extract_laws.py
Created February 22, 2009 19:05
return list of U.S. public law numbers extracted from string
import re
# return list of public law numbers extracted from string
def extract_laws(haystack):
p = re.compile('P\.L\.\s?\d{1,3}-\d{1,3}')
needle_list = p.findall(haystack)
return needle_list
@jroo
jroo / extract_ordercodes.py
Created February 22, 2009 19:15
extract CRS report order codes from string and return as list
import re
#extract CRS report order codes from string and return as list
def extract_ordercodes(haystack):
p = re.compile('R\d{5}|RL\d{5}|RS\d{5}|IB\d{5}')
needle_list = p.findall(haystack)
return needle_list
@jroo
jroo / extract_gao_id.py
Created February 22, 2009 20:24
extract GAO report ID's from text and return as a list
import re
#extract GAO report ID's from text and return as a list
def extract_gao_id(haystack):
p = re.compile('GAO-\d{2}-?\d{1,4}\w?')
needle_list = p.findall(haystack)
return needle_list
@jroo
jroo / congress_from_year.py
Created February 22, 2009 21:00
returns number of Congress in session for provided year
#returns number of Congress in session for provided year
def congress_from_year(year):
if year < 1789:
return None
else:
return int((year-1789)/2) + 1
@jroo
jroo / grab_gao_pastyear.py
Created March 22, 2009 21:57
returns list of GAO reports for past year
import datetime, time
import urllib2
from BeautifulSoup import BeautifulSoup
#returns list of GAO reports for past year
def grab_gao():
doc_type = "GAO"
page = urllib2.urlopen("http://gao.gov/docsearch/pastyear.html")
soup = BeautifulSoup(page)
report_list = []
#python string date to date
date_str = "June 8, 1976"
release_date = time.strftime('%Y-%m-%d', time.strptime(date_str, '%B %d, %Y'))
@jroo
jroo / session_from_year.py
Created June 12, 2009 14:57
returns session number of Congress for a provided year
#returns session number of Congress for a provided year
def session_from_year(year):
return 2 - (year % 2)
#songsincode
def another():
return "you've been messing around"
def friend(x):
return another() if x else friend(1)
i=friend(0)
@jroo
jroo / tt_tricephale.txt
Last active January 25, 2022 22:20
teletype tricéphale: a pentatonic generative sequencer with three playheads for teletype and grid
TRICEPHALE
#1
A WRAP + A 1 0 15
IF G.FDR.EN A: Y A; X 1; $ 5
$ 6
EVERY 64: $ 4
#2