Skip to content

Instantly share code, notes, and snippets.

View no-reply's full-sized avatar

tamsin woo no-reply

  • UC Santa Barbara Library
  • United States
View GitHub Profile
@no-reply
no-reply / sparql.rb
Created October 11, 2014 18:16
Marmotta Ask Bug(?)
subject.query_client.ask.whether([:s, :p, :o]).to_s
# => "ASK WHERE { ?s ?p ?o . }"
subject.query_client.ask.whether([:s, :p, :o]).true?
# => true
subject.query_client.ask.whether([:s, RDF::DC.title, 'my item']).to_s
# => "ASK WHERE { ?s <http://purl.org/dc/terms/title> \"my item\" . }"
subject.query_client.ask.whether([:s, RDF::DC.title, 'my item']).true?
require 'mime/type' #=> NameError: uninitialized constant MIME
require 'mime' # works fine, but then `Mime` exists and `MIME` does not
@no-reply
no-reply / aggregation_json.rb
Created October 23, 2014 17:31
Aggregation as JSON (possible initial indexing strategy)
require 'factory_girl'
include FactoryGirl::Syntax::Methods
require 'dpla/map/factories'
agg = build(:aggregation)
agg.to_json
# => => "{\"aggregatedCHO\":[{\"alternateTitle\":[\"Stonewall Inn Graffiti\"],\"collection\":[{\"title\":[\"Diana Davies photographs, 1965-1978\"],\"description\":[\"Photographs of Diana Davies; LGBT and HIV/AIDS Activist Collections\"]}],\"contributor\":[{\"label\":[\"Norma Ford\"],\"providedLabel\":[\"Norma Ford\"],\"exactMatch\":[],\"closeMatch\":[]}],\"creator\":[{\"label\":[\"Davies, Diana (1938-)\"],\"providedLabel\":[\"Norma Ford\"],\"exactMatch\":[],\"closeMatch\":[]}],\"date\":[{\"providedLabel\":[\"1969.\"],\"begin\":[\"1969-01-01\"],\"end\":[\"1969-12-31\"]}],\"description\":[\"Window of the Stonewall Bar N.Y. 1969. The other half of the graffiti was erased by the time Diana photographed it.\"],\"extent\":[\"10x12 cm\"],\"format\":[\"Silver Gelatin Print\"],\"genre\":[{\"id\":\"http://vocab.getty.edu/aat/300132472\",\"prefLabel\":[],\"providedLabel\":[],\"exactMatch\":[],
@no-reply
no-reply / agg.json
Created October 23, 2014 19:19
DPLA Aggregation JSON-LD
puts agg.dump(:jsonld, {standard_prefixes: true})
{
"@context": {
"aat": "http://vocab.getty.edu/aat/",
"dc": "http://purl.org/dc/terms/",
"dc11": "http://purl.org/dc/elements/1.1/",
"dcmitype": "http://purl.org/dc/dcmitype/",
"dpla": "http://dp.la/about/map/",
"edm": "http://www.europeana.eu/schemas/edm/",
"iso_639_3": "http://lexvo.org/id/iso639-3/",
@no-reply
no-reply / context.jsonld
Last active August 29, 2015 14:08
DPLA MAPv4 Context & Frame
{
"@context": {
"aat": "http://vocab.getty.edu/aat/",
"dc": "http://purl.org/dc/terms/",
"dc11": "http://purl.org/dc/elements/1.1/",
"dcmitype": "http://purl.org/dc/dcmitype/",
"dpla": "http://dp.la/about/map/",
"edm": "http://www.europeana.eu/schemas/edm/",
"iso_639_3": "http://lexvo.org/id/iso639-3/",
"ore": "http://www.openarchives.org/ore/terms/",
@no-reply
no-reply / framed.jsonld
Last active August 29, 2015 14:08
DPLA MAPv4 Framed
{
"@context": {
"aat": "http://vocab.getty.edu/aat/",
"dc": "http://purl.org/dc/terms/",
"dc11": "http://purl.org/dc/elements/1.1/",
"dcmitype": "http://purl.org/dc/dcmitype/",
"dpla": "http://dp.la/about/map/",
"edm": "http://www.europeana.eu/schemas/edm/",
"iso_639_3": "http://lexvo.org/id/iso639-3/",
"ore": "http://www.openarchives.org/ore/terms/",
@no-reply
no-reply / etags.bash
Created November 5, 2014 22:12
Marmotta ETags
$ curl -i http://localhost:8080/marmotta/ldp/container
HTTP/1.1 200 OK
Server: Apache Marmotta/3.2.1 (build 0)
Last-Modified: Wed, 05 Nov 2014 21:46:56 GMT
ETag: W/"1415224016000"
Link: <https://wiki.apache.org/marmotta/LDPImplementationReport/2014-03-11>; rel="describedby"
Link: <http://www.w3.org/ns/ldp#Container>; rel="type"
Link: <http://www.w3.org/ns/ldp#Resource>; rel="type"
Link: <http://www.w3.org/ns/ldp#RDFSource>; rel="type"
Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel="type"
# Note: this is all pseudocode to mock up a DSL at this point.
# THIS IS A VERY INCOMPLETE EXAMPLE; much work to do for mods.
bpl_mods_mapper = Krikri::Mapper.new
bpl_mods_mapper.build do
input_format :xml # :json, :csv, :tsv others?
selector type: :xpath, "//record"
# select an XPath relative to `selector` as the default parent for mappings
class Registry
include Singleton
include Enumerable
attr_reader :mappings
delegate :each, :[], :[]=, to: :mappings
def initialize
@mappings = {}
end
@no-reply
no-reply / parser_methods.rb
Created December 2, 2014 16:01
a sketch of parsed OriginalRecords in mapping DSL
module Krikri::MappingDSL
module ParserMethods
extend ActiveSupport::Concern
def use_parser(parser_class)
@parser = parser_class
end
def record(*args)
raise 'No parser selected; set a parser with #use_parser(class)' unless