Skip to content

Instantly share code, notes, and snippets.

Avatar

Jon Stroop jpstroop

  • Princeton University Library
  • Princeton, NJ
View GitHub Profile
View info_with_access.json
{
"@context": "http://iiif.io/image-api/1.1/context.json",
"@id": "http://libimages.princeton.edu/loris/pudl0052%2F6131707%2F00000001.jp2",
"profile": "http://iiif.io/image/1.2/levels/2.json", //local or iiif.io profile
"capabilities": "http://libimages.princeton.edu/loris/capabilities.json", //local or iiif.io profile
"formats": [ "jpg", "png", "tif", "gif" ],
"width": 122877,
"height": 3783,
"login": "http://libimages.princeton.edu/loris/login", // Exclusive w/
"logout": "http://libimages.princeton.edu/loris/logout", // this. Both optional. Logout required if logged in.
View server_breakout.md

Server Breakouts

Implementations

Yale: IIIP MooViewer shim that sits along side Djatoka. level1 compliant with some level2. Limited in terms of errors it can report. BL: (3 servers)

  1. IIS, C#, invoking Kakadu binary OSS
  2. Same as above, compiled w/ KDU
@jpstroop
jpstroop / get_vocab.rb
Created Feb 10, 2014
Use RDF.rb to generate an `RDF::Vocabulary` or `RDF::StrictVocabulary`. Based on https://github.com/ruby-rdf/rdf/blob/develop/Rakefile#L39-L95
View get_vocab.rb
require 'linkeddata'
require 'rdf/cli/vocab-loader'
vocab_sources = {
lifecycle: {
prefix: "http://purl.org/vocab/lifecycle/schema#",
source: "http://vocab.org/lifecycle/schema-20080603.rdf",
strict: true
}
}
View profile_with_extension_bnodes.ttl
@prefix : <http://iiif.io/api/image-api#> .
@prefix ns1: <http://purl.org/dc/terms/> .
@prefix ns2: <http://libimages.princeton.edu/loris#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://libimages.princeton.edu/loris> :contact "mailto:azaroth42@gmail.com" ;
:extensions [ :feature "http://libimages.princeton.edu/loris#myNextCoolFeature" ;
@jpstroop
jpstroop / profile.json
Last active Aug 29, 2015
Strawman for profile.json
View profile.json
{
"@context": {
"@vocab": "http://iiif.io/api/image#",
"xsd" :" http://www.w3.org/2001/XMLSchema#"
},
"@id": "http://libimages.princeton.edu/loris",
"supportsRegionByPct": {
"@value": "true",
"@type": "xsd:boolean"
},
View iiif_examples.md

IIIF Image API URIs

Image

{scheme}://{server}{/prefix}/{identifier}/{region}/{size}/{rotation}/{quality}{.format}
@jpstroop
jpstroop / get_iso_langs.rb
Created Dec 6, 2013
Download the ISO 639-2 codes as RDF and convert to CSV
View get_iso_langs.rb
require 'rdf/rdfxml'
require 'csv'
# Gets the ISO639-2 languages from id.loc.gov and saves it as CSV.
SRC_URI="http://id.loc.gov/vocabulary/iso639-2.rdf"
MADS_LANGUAGE = RDF::URI.new("http://www.loc.gov/mads/rdf/v1#Language")
MADS_CODE = RDF::URI.new("http://www.loc.gov/mads/rdf/v1#code")
SAVE_AS = File.expand_path("../../../db/fixtures/iso639-2.csv", __FILE__)
@jpstroop
jpstroop / qdc_rdf.rb
Created Nov 4, 2013
Qualified DC to N-Triples
View qdc_rdf.rb
require 'nokogiri'
require 'rdf'
require 'chronic'
xmldoc = Nokogiri::XML('<metadata xmlns="http://example.org/myapp/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xsi:schemaLocation="http://example.org/myapp/ http://example.org/myapp/schema.xsd">
<dc:title>
UKOLN
</dc:title>
<dcterms:alternative>
UK Office for Library and Information Networking
@jpstroop
jpstroop / owl_to_rb.rb
Created Oct 22, 2013
OWL to RDF::Vocabulary
View owl_to_rb.rb
require 'linkeddata'
include RDF
# args
@ns = 'http://library.ucsd.edu/ontology/dams/#'
@class_name = 'UCSD_DAMS'
@i = 'https://raw.github.com/ucsdlib/dams/master/ontology/dams.owl'
@o = 'ucsd_dams.rb'
#
@jpstroop
jpstroop / parent_days.py
Last active Dec 18, 2015
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:
View parent_days.py
#!/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