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
@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 / bots.py
Created December 4, 2012 16:42 — forked from edsu/bots.py
see what your bot traffic is like
#!/usr/bin/env python
"""
Hack to look for user agent strings in typical Apache style log and
count up the number of requests by bots vs non-bots. The list of bot
user agents comes from http://www.user-agents.org/ but has had some
agents added to it, since the user-agents.org list is pretty out of date, e.g.
no Bing?!
"""
@jpstroop
jpstroop / dzi_to_iiif.py
Last active October 15, 2020 14:09
DZI syntax to IIIF
# Take params from the DZI syntax and turn them into an IIIF request
#
# Copyright (C) 2009 CodePlex Foundation
# Copyright (C) 2010-2013 OpenSeadragon contributors
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# - Redistributions of source code must retain the above copyright notice,
@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
@jpstroop
jpstroop / owl_to_rb.rb
Created October 22, 2013 23:20
OWL to RDF::Vocabulary
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'
#