Skip to content

Instantly share code, notes, and snippets.

@lawlesst
lawlesst / eulxml_updater_demo.py
Created September 15, 2011 12:38
Sample METS update script using eulxml.
from eulxml import xmlmap
from eulxml.xmlmap import load_xmlobject_from_file
MODS_NAMESPACE = 'http://www.loc.gov/mods/v3'
METS_NAMESPACE = 'http://www.loc.gov/METS/'
SF = xmlmap.StringField
class Common(xmlmap.XmlObject):
"MODS class with namespace declaration common to all MODS XmlObjects."
@lawlesst
lawlesst / oaipmh_marc_harvest.py
Created October 28, 2011 20:57
OAI-PMH harvesting with Python
"""
Harvest MARC records via OAI-PMH.
"""
#Mostly from - http://code.google.com/p/oldmapsonline/source/browse/trunk/oai-pmh/oaipmh-client-pyoai-pymarc.py
# MarcXML reader - parsing done by pymarc
#Handle utf-8 strings
import codecs, sys
@lawlesst
lawlesst / innovative-driver.diff
Created November 15, 2011 17:49
Innovative driver patch
Index: web/conf/Innovative.ini
===================================================================
--- web/conf/Innovative.ini (revision 4582)
+++ web/conf/Innovative.ini (working copy)
@@ -1,6 +1,14 @@
[Catalog]
url = http://catalog.library.myuniversity.edu
+; Do not change unless you have changed your indexing routine to
+; strip the leading '.' and trailing check
@lawlesst
lawlesst / openurl.py
Created November 29, 2011 20:12
OpenURL context objects
"""
Really messy attempt at creating OpenURL context
objects for use in link resolver middleware.
Primary use will be to map resolved citiation metadata
from the 360 Link knowledge base and create open url
context objects that can be passed on to other services
- like Illiad - or used in other software.
"""
@lawlesst
lawlesst / brown_gadget.xml
Created December 6, 2011 15:40
Brown Sciverse Vufind gadget
<Module><ModulePrefs title="VuFindGadget"
description="&lt;p&gt;This application will search the Brown University collections and display relevant results alongside search
results from SciVerse Hub and ScienceDirect. Clicking on a result will take the user to the Brown University library
website, where more results and services will be available.&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;The application was built from the &lt;a href=&quot;http://www.applications.sciverse.com/action/appDetail/293706&quot;&gt;VuFind Template app&lt;/a&gt; for SciVerse developed at Villanova University. If your institution uses VuFind to power its library catalog a version of this application is easy to create for your institution. Learn more about the VuFind Template app to see if such an app on SciVerse can help your institution. Please contact &lt;a href=&quot;http://www.applications.sciverse.com/action/contactus&quot;&gt;Elsevier&lt;/a&gt; to learn more.&lt;/p&gt;
">
<Require feature="sciverse"/>
<Require feature="opensocial-0.9"/>
Name|LCNAF
Aaron, Hank|n80126307
Abel, I. W.|n85185062
Abernathy, Ralph|n87870916
Abourezk, James|
Abrams, Robert|
Abt, John|n92122744
Abzug, Bella|n83231578
Acosta, Jerry|
Acosta, Roberto|n84134984
@lawlesst
lawlesst / api.py
Created March 13, 2012 20:49
Simple setup for a Tastypie and Solr
"""
Simple setup for tastypie with Solr as the backend. This is based off Daniel Lindsley's Pycon 2012 presentation. Minor modifications.
http://speakerdeck.com/u/daniellindsley/p/restful-apis-with-tastypie
http://django-tastypie.readthedocs.org/
"""
import pysolr
@lawlesst
lawlesst / openurl_to_bibjson.py
Created March 20, 2012 20:57
Attempts to map OpenURLs to BibJSON
"""
Attempts to parse raw OpenURLs to the BibJSON convention.
"""
import urllib
import urlparse
import sys
import json
from pprint import pprint
@lawlesst
lawlesst / gist:2184245
Created March 24, 2012 15:23 — forked from anonymous/gist:2184239
Hot dog pricing data
hotdog_years = ["2011", "2010", "2009"]
hotdog_data = [{"Team":"Boston Red Sox","TeamID":"redsox","2011":4.5,"2010":4.5,"2009":4.5},
{"Team":"New York Yankees","TeamID":"yankees","2011":3,"2010":3,"2009":3},
{"Team":"Chicago Cubs","TeamID":"cubs","2011":4.5,"2010":4.25,"2009":3},
{"Team":"Chicago White Sox","TeamID":"whitesox","2011":3.5,"2010":3.25,"2009":3.25},
{"Team":"New York Mets","TeamID":"mets","2011":5,"2010":5,"2009":4.75},
{"Team":"Philadelphia Phillies","TeamID":"phillies","2011":3.75,"2010":3.75,"2009":3.75},
{"Team":"Los Angeles Dodgers","TeamID":"dodgers","2011":5,"2010":5,"2009":5},
{"Team":"St. Louis Cardinals","TeamID":"cardinals","2011":4.25,"2010":4,"2009":4},
{"Team":"Houston Astros","TeamID":"astros","2011":4.75,"2010":4.75,"2009":4.75},
@lawlesst
lawlesst / ballpark_costs_03_11.csv
Created March 24, 2012 20:13
Various costs for ballparks - compiled from reports from teamarketing.com
Year Short Name Team Ticket Change Ticket Beer Drink Dog Parking Program Cap FCI Change
2011 diamondbacks Arizona Diamondbacks 15.74 0.1 60.5 4.0014 3.7524 2.75 10.0 0.0 7.0 120.96 0.05
2011 braves Atlanta Braves 19.38 0.0 49.26 6.7516 4.5022 4.5 12.0 0.0 15.0 169.02 0.029
2011 orioles Baltimore Orioles 23.9 0.021 43.72 6.2518 2.0016 2.5 8.0 5.0 15.0 174.1 0.011
2011 redsox Boston Red Sox 53.38 0.02 172.51 7.2512 4.002 4.5 27.0 5.0 20.0 339.01 0.013
2011 cubs Chicago Cubs 46.9 -0.012 103.47 6.5016 3.0015 4.5 25.0 5.0 20.0 305.6 -0.012
2011 whitesox Chicago White Sox 40.67 0.052 99.77 6.5016 3.0014 3.5 23.0 4.0 13.0 258.68 0.036
2011 reds Cincinnati Reds 20.56 0.071 60.23 5.5012 1.0012 1.0 17.0 4.0 18.0 162.24 0.073
2011 indians Cleveland Indians 18.49 -0.164 60.56 4.5012 4.7524 4.25 12.0 0.0 20.0 170.96 -0.053
2011 rockies Colorado Rockies 19.5 0.0 36.5 5.5016 3.2518 3.25 8.0 5.0 14.0 161.0 0.0