Skip to content

Instantly share code, notes, and snippets.

Avatar

Jon Stroop jpstroop

  • Princeton University Library
  • Princeton, NJ
View GitHub Profile
@jpstroop
jpstroop / hathi_to_tsv.awk
Last active Nov 13, 2015
Filter NJP open content from HathiFiles
View hathi_to_tsv.awk
# 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 / 1_simple_manifest.rb
Last active Mar 20, 2018
Example: How to create a bare-bones IIIF Presentation Manifest w/ O'Sullivan
View 1_simple_manifest.rb
require 'iiif/presentation'
MY_IIIF_IMAGE_SERVER = 'http://libimages1.princeton.edu/loris/'
SOME_IIIF_IMAGES = [
{ id: 'pudl0001%2F4609321%2Fs42%2F00000006.jp2', label: "Page 1" },
{ id: 'pudl0001%2F4609321%2Fs42%2F00000007.jp2', label: "Page 2" },
{ id: 'pudl0001%2F4609321%2Fs42%2F00000008.jp2', label: "Page 3" },
{ id: 'pudl0001%2F4609321%2Fs42%2F00000009.jp2', label: "Page 4" },
{ id: 'pudl0001%2F4609321%2Fs42%2F00000010.jp2', label: "Page 5" }
]
View harvest_vocabs.rb
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: {
View marc_relators.rb
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'
View resourcesync_config_idea.yml
# Specifies a set of ResourceSync Sources
# Entire file could also be used to build the Capability List document
# E.g. engine at /rs/{service_id}
service_id:
- model: MyModel
datastreams:
- descMetadata
- model: MyOtherModel
@jpstroop
jpstroop / tree_spec.md
Last active Feb 14, 2017
Archives/EAD Tree Navigation API spec
View tree_spec.md
View jp2_kakadu_pillow.py
from PIL import Image
from PIL.ImageFile import Parser
from os import makedirs, path, unlink
import subprocess
import sys
KDU_EXPAND='/usr/local/bin/kdu_expand'
LIB_KDU='/usr/local/lib/libkdu_v72R.so'
TMP='/tmp'
INPUT_JP2='/home/jstroop/workspace/loris/tests/img/01/02/0001.jp2'
View capabilities_with_gravity.json
{
"@context" : [
"http://iiif.io/api/image-api/context.json",
{
"ab" : "http://penibelst.de/",
"ab:gravity" : {"@type" : "xsd:boolean"}
}
],
"@id" : "http://libimages.princeton.edu/loris",
"contact" : "mailto:admin@example.com",
@jpstroop
jpstroop / review.dot
Last active Aug 29, 2015
Blue Mountain Relationships in RDF experiments
View review.dot
// Command: dot -Tpng -o review.png review.dot
digraph G {
pad=".5";
label="\n\nReview / Work / Magazine Relationship Graph";
labelloc=bottom;
labeljust=left;
rankdir=LR
size="9"; // inches for the long side
fontpath="/usr/share/fonts";
graph [fontname="Monospace"];
View capabilities.json
{
"@context" : [
"http://iiif.io/api/image-api/context.json",
{
"ext" : "http://www.shared-canvas.org/iiif/ext/",
"ext:watermarking" : {"@type" : "xsd:boolean"}
}
],
"@id" : "http://libimages.princeton.edu/loris",
"contact" : "mailto:admin@example.com",