Skip to content

Instantly share code, notes, and snippets.

@lawlesst
lawlesst / search_z3950.py
Created July 23, 2011 13:09
Sample Z39.50 search with Python.
"""
Simple script to search a Z39.50 target using Python
and PyZ3950.
"""
from PyZ3950 import zoom
ISBNs = ['9781905017799', '9780596513986']
@edsu
edsu / worldcat_live.py
Last active December 1, 2016 17:36
A Python module for interacting with the experimental OCLC Worldcat Live API.
#!/usr/bin/env python
"""
This is mainly a demonstration of OCLC's experimental Worldcat Live API [1]
from Python. You should be able to use this module like so:
import worldcat_live
for item in worldcat_live.items():
print item["title"]
// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class
@pmgreen
pmgreen / openrefine_regexp.md
Last active November 21, 2022 21:49
Quick primer on using regular expressions in OpenRefine.

Using regular expressions in OpenRefine

A regular expression is a string that describes a text pattern occurring in other strings, m'kay.

Basic concepts

With which one can go quite far.

* metacharacters
* character escapes \
* anchors \A\Z or ^$
from itertools import chain, starmap
def flatten_json_iterative_solution(dictionary):
"""Flatten a nested json file"""
def unpack(parent_key, parent_value):
"""Unpack one level of nesting in json file"""
# Unpack one level only!!!
if isinstance(parent_value, dict):

How to use Gephi to visualize from Wikidata

I'm a long-time fan of the graph visualization tool Gephi and since Wikimania 2019 I got involved with Wikidata. I was aware of the Gephi plugin "Semantic Web Importer", but when I check it out, I only find old tutorials connecting to DBpedia, not Wikidata:

@kschlottmann
kschlottmann / ead_mrs_top-level-scope.xq
Last active September 11, 2020 20:49
Get description with 'Mrs' from EAD
<data>
{
for $Record in /ead
where $Record/archdesc/scopecontent/p[contains(., 'Mrs')]
let $id := $Record/archdesc/did/unitid[1]/text()
let $title := $Record/archdesc/did/unittitle
let $repo := $Record/eadheader/eadid/@mainagencycode
let $scopeMrs := $Record/archdesc/scopecontent/p[contains(., 'Mrs')]
@chrisdaaz
chrisdaaz / git-for-librarians-reading-list.md
Last active April 5, 2025 14:53
A reading list for librarians learning about Git and GitHub

Git and GitHub for Librarians: A Brief Bibliography

Each citation includes an abstract or annotation. Feel free to suggest an addition!

Libraries

Davis, Robin Camille. 2015. “Git and GitHub for Librarians.” Publications and Research, January. https://academicworks.cuny.edu/jj_pubs/34.

  • One of the fastest-growing professional social networks is GitHub, an online space to share code. GitHub is based on free and open-source software called Git, a version control system used in many digital projects, from library websites to government data portals to scientific research. For projects that involve developing code and collaborating with others, Git is an invaluable tool; it also creates a backup system and structured documentation. In this article, we examine version control, the particulars of Git, the burgeoning social network of GitHub, and how Git can be an archival tool.
@ngeraci
ngeraci / terms_of_aggrandizement.py
Last active March 4, 2021 01:02
Python/ArchivesSpace adaptation of Kelly Bolding's Terms of Aggrandizement xquery script to report on language in archival finding aid "Biography or History" (bioghist) notes.
""" Adaptation of Kelly Bolding's Terms of Aggrandizement xquery script to report on aggrandizing
language in archival finding aid "Biography or History" (bioghist) notes.
The original script uses xquery on a directory of EAD XML files, and produces an XML report.
This version uses Python to query the ArchivesSpace REST API, and produces a JSON report.
"""
import re
import json
from asnake.aspace import ASpace
@ngeraci
ngeraci / terms_of_aggrandizement.txt
Last active March 4, 2021 01:03
term list that goes with terms_of_aggrandizement.py
influential
renowned
not(able|ed)
distinguished
reputable
prestigious
prominent
significant
respected
expert