Skip to content

Instantly share code, notes, and snippets.

#!/usr/python3
import os
import csv
from ipwhois import IPWhois
# clean-up
try:
os.remove('.\\output\\Z39.50 Usage - IPs (last 3 months) -- enhanced.csv')
except FileNotFoundError:
pass
@comstock
comstock / curlLibraryCloud.md
Last active December 13, 2023 18:45
Using Harvard Library's LibraryCloud, send a MARC/MODS XML, Dublin Core XML, or MODS JSON version of an item record to standard output.

curl "https://api.lib.harvard.edu/v2/items.[xml | dc | json]?recordIdentifier=[Hollis ID]"

Example, Dublin Core output: curl "https://api.lib.harvard.edu/v2/items.dc?recordIdentifier=990058255550203941"

@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
@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
@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.
@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')]

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:

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):
@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 ^$
// 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