Skip to content

Instantly share code, notes, and snippets.

View edsu's full-sized avatar

Ed Summers edsu

View GitHub Profile
@edsu
edsu / twitter2pinboard.txt
Created April 18, 2011 14:09
output of twitter2pinboard.py
http://pinboard.in/u:Pinboard
http://pinboard.in/u:rubinsztajn
http://pinboard.in/u:pberry
http://pinboard.in/u:rybesh
http://pinboard.in/u:librarywebchic
http://pinboard.in/u:archivesnext
http://pinboard.in/u:Skud
http://pinboard.in/u:hoverbird
http://pinboard.in/u:paulsmith
http://pinboard.in/u:helrond
@edsu
edsu / doi.ttl
Created April 21, 2011 12:46
curl --header "Accept: text/turtle" http://dx.doi.org/10.1126/science.1157784
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
<http://dx.doi.org/10.1126/science.1157784>
<http://prismstandard.org/namespaces/basic/2.1/doi> "10.1126/science.1157784" ;
<http://prismstandard.org/namespaces/basic/2.1/endingPage> "832" ;
<http://prismstandard.org/namespaces/basic/2.1/startingPage> "828" ;
<http://prismstandard.org/namespaces/basic/2.1/volume> "325" ;
<http://purl.org/dc/terms/creator> <http://id.crossref.org/contributor/a-h-renear-1z0zrfd0bp2b7>, <http://id.crossref.org/contributor/c-l-palmer-1z0zrfd0bp2b7> ;
<http://purl.org/dc/terms/date> "2009-08-13Z"^^<http://www.w3.org/2001/XMLSchema#date> ;
<http://purl.org/dc/terms/identifier> "10.1126/science.1157784" ;
@edsu
edsu / wsgi_multiprocessing.py
Created May 2, 2011 12:58
simple test of multiprocessing in wsgi environment
#!/usr/bin/env python
"""
install web.py and mod_wsgi and put this in your apache config:
WSGIScriptAlias /multiprocessing /home/ed/wsgi_multiprocessing.py
AddType text/html .py
Then visit,
@edsu
edsu / unimarc.py
Created May 4, 2011 14:43
read in some unimarc
import pymarc
import codecs
reader = pymarc.MARCReader(codecs.open('test.dat', 'r', 'windows-1251'))
record = reader.next()
print record['200']['a'].encode('utf-8')
[2011-05-06 11:49:40,739: ERROR/MainProcess] Task sampler.web.tasks.load_bags[96bb7e3a-dc18-4214-bdd3-547933217bf0] raised exception: TypeError("KeyError('bagKey',) is not JSON serializable",)
Traceback (most recent call last):
File "/home/esummers/.virtualenvs/sampler/lib/python2.6/site-packages/celery/execute/trace.py", line 34, in trace
return cls(states.SUCCESS, retval=fun(*args, **kwargs))
File "/home/esummers/.virtualenvs/sampler/lib/python2.6/site-packages/celery/task/base.py", line 241, in __call__
return self.run(*args, **kwargs)
File "/home/esummers/.virtualenvs/sampler/lib/python2.6/site-packages/celery/app/__init__.py", line 141, in run
return fun(*args, **kwargs)
File "/home/esummers/projects/sampler/sampler/../sampler/web/tasks.py", line 19, in load_bags
cts_loader.service_requests()
@edsu
edsu / ptree.txt
Created May 27, 2011 13:41
ptree usage
>>> import ptree
>>> ptree.id2ptree("info:lccn/hahah/motherhubbard")
'/in/fo/+l/cc/n=/ha/ha/h=/mo/th/er/hu/bb/ar/d/'
>>> ptree.ptree2id("/in/fo/+l/cc/n=/ha/ha/h=/mo/th/er/hu/bb/ar/d/")
u'info:lccn/hahah/motherhubbard'
>>>
@edsu
edsu / locah.txt
Created May 27, 2011 17:49
resource types in LOCAH sample data (http://data.archiveshub.ac.uk/)
ed@rorty:~$ rdfsum meta
7591 <http://xmlns.com/foaf/0.1/Document>
7590 <http://purl.org/ontology/bibo/Document>
7377 <http://www.w3.org/2006/time#Interval>
6982 <http://purl.org/NET/c4dm/event.owl#Event>
6982 <http://linkedevents.org/ontology/Event>
6225 <http://data.archiveshub.ac.uk/def/ArchivalResource>
6163 <http://data.archiveshub.ac.uk/def/Creation>
5761 <http://www.w3.org/2004/02/skos/core#Concept>
4533 <http://xmlns.com/foaf/0.1/Agent>
@edsu
edsu / rdfsum
Created May 27, 2011 18:15
silly command line tool to summarize type assertions in a batch of ntriples
#!/bin/sh
#
# pass this script a filename of ntriples data and get back a
# little report about the types of resources in the rdf, e.g.
#
# ed@curry:~/$ rdfsum oreily_catalog.nt
# 6803 <http://purl.org/goodrelations/v1#TypeAndQuantityNode>
# 5861 <http://purl.org/goodrelations/v1#Offering>
# 4564 <http://purl.org/goodrelations/v1#UnitPriceSpecification>
@edsu
edsu / test.py
Created June 14, 2011 14:04
check to see if i can bind to a port
>>> import socket
>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> s.bind(('localhost', 8080))
>>> s.listen(1)
@edsu
edsu / host.txt
Created June 23, 2011 15:45
en.wikipedia.org
ed@rorty:~$ host en.wikipedia.org
en.wikipedia.org is an alias for text.wikimedia.org.
text.wikimedia.org is an alias for text.pmtpa.wikimedia.org.
text.pmtpa.wikimedia.org has address 208.80.152.2