Skip to content

Instantly share code, notes, and snippets.

View jpstroop's full-sized avatar

Jon Stroop jpstroop

  • Princeton University Library
  • Princeton, NJ
View GitHub Profile
require 'rdf'
module RDF
class MARC_RELATORS < StrictVocabulary("http://id.loc.gov/vocabulary/relators/")
# Property definitions
property :abr, :label => 'Abridger'
property :act, :label => 'Actor'
property :adp, :label => 'Adapter'
property :rcp, :label => 'Addressee'
property :anl, :label => 'Analyst'
require 'linkeddata'
require 'rdf/cli/vocab-loader'
vocab_sources = {
lifecycle: {
uri: "http://purl.org/vocab/lifecycle/schema#",
source: "http://vocab.org/lifecycle/schema-20080603.rdf",
strict: true
},
exif: {
@jpstroop
jpstroop / sync_exist.sh
Created April 22, 2012 11:57
cron script for keeping eXist in sync with a filesystem
#!/bin/bash
#
# Load incremental changes since the last load. This script maintains a
# hidden file that keeps track of this information.
#
# UTILS
DATE="/bin/date"
CURL="/usr/bin/curl"
@jpstroop
jpstroop / dirtopdf.sh
Created June 19, 2012 19:37
Make a PDF form a directory of TIFFs
#!/bin/bash
#
# Takes a directory of TIFF images and makes a PDF
#
# Usage:
# ./dirtopdf [-rd] [-s <arg>] -o <file> <dir>
#
# e.g.: ./dirtopdf.sh -rd -s 3200 -o new.pdf /tmp/bar
#
@jpstroop
jpstroop / hathi_to_tsv.awk
Last active November 13, 2015 14:51
Filter NJP open content from HathiFiles
# Filter "Hathifiles" (https://www.hathitrust.org/hathifiles) to open content from NJP
# Run w/ e.g., `cat hathi_full_20151101.txt | awk -f hathi_to_tsv.awk`
BEGIN {
FS = "\t";
printf("%s\t%s\t%s\t%s\n", "title", "enum", "URI", "BBID")
}
($1 ~ /^njp/) && ($2 == "allow") {
printf "\"%s\t%s\thttp://hdl.handle.net/2027/%s\t%s\n", $12, $5, $1, $7
@jpstroop
jpstroop / c4l_loris_lightning_talk.md
Last active December 12, 2015 12:19
Lightning talk re: Loris <https://github.com/pulibrary/loris> for code4lib 2013.
@jpstroop
jpstroop / not_blomeka.md
Last active December 15, 2015 10:49
Notes, Examples, and Use Cases about an Exhibition / Ad Hoc Collection building utility built on Blacklight (Hydra?)
@jpstroop
jpstroop / recordInfo_mets.xml
Last active December 15, 2015 19:19
mods:recordinfo in METS
<snip>
<dmdSec ID="dmd-arab">
<mdWrap MDTYPE="MODS">
<xmlData>
<mods:recordInfo>
<mods:languageOfCataloging>
<mods:languageTerm>ara</mods:languageTerm>
<mods:scriptTerm type="code">Arab</mods:scriptTerm>
</mods:languageOfCataloging>
</mods:recordInfo>
@jpstroop
jpstroop / changes1.1.md
Last active December 17, 2015 20:58
IIIF Image API 1.1 Change Log

IIIF Image API 1.1 Change Log

  • Base URI defined. Section 2.2 recommends that this URI returns the image information or redirects to the image information request URI when dereferenced.
  • Clarified definition of the prefix segment of the base URI.
  • Added @id and @context properties to make image information JSON-LD compatible. The addition of the base URI in the @id property should make it easier for clients to get around XSS/SOP issues when working with IIIF image servers in different domains.
  • Image information in XML (http[s]://server/[prefix/]identifier/info.xml) and related schemas have been removed.
  • Clarified the definition of scale_factors.
@jpstroop
jpstroop / parent_days.py
Last active December 18, 2015 13:58
My birthday sometimes falls on Father's Day and Abi's sometimes falls on Mother's Day. I was wondering if this would this ever happen in the same year. Here's the answer:
#!/usr/bin/env python
from datetime import date
def fday_on_jons_bday(year):
return [d for d in range(15,22) if date(year, 6, d).weekday() == 6][0] == 16
def mday_on_abis_bday(year):
return [d for d in range(8,15) if date(year, 5, d).weekday() == 6][0] == 14
j_years = filter(lambda d: fday_on_jons_bday(d), range(2007,2078)) # F's bday to J's birth year + 100