Skip to content

Instantly share code, notes, and snippets.

View jcoyne's full-sized avatar

Justin Coyne jcoyne

  • Stanford University Libraries
  • Minneapolis, MN
View GitHub Profile
@jcoyne
jcoyne / ocfl-migrate.rb
Last active March 14, 2024 19:07
Test migration of OCFL
# TODO: There is one problem with this approach
# We have no way to differentiate the cocina.json/public/mods files from purl from the files from stacks.
# It may be possible that one of the stacks files could have a name collision (e.g. if the name was "public")
require 'ocfl'
require 'druid-tools'
DRUIDS = %w[
bd072pn1284
]
OCFL_ROOT = '/stacks/ocfl-experiment-jcoyne'
@jcoyne
jcoyne / clear_gh_cache.rb
Last active October 17, 2022 16:11
Clear github caches
TOKEN = ENV['GH_TOKEN']
REPO = ENV['GH_REPO']
ids = `curl -s \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token #{TOKEN}" \
https://api.github.com/repos/#{REPO}/actions/caches | jq '.actions_caches[].id'`
ids.split.each do |id|
`curl -s \
@jcoyne
jcoyne / logs.txt
Created June 26, 2020 14:08
Fedora logs processing
tail -10000 dor_access_ssl.log | grep 'content ' | grep 200 | sed 's/.\+\(GET \/fedora\/objects\/druid.\+datastreams.\+\/content.\+\)HTTP\/1.1" 200 \([0-9]\+\).\+/\2 \1/'
@jcoyne
jcoyne / openapi.yml
Created June 10, 2020 20:03
Example with Openapi3Parser::Error::InvalidData
openapi: 3.0.0
info:
description: Specification for Cocina Models
version: 1.0.0
title: Cocina Models
license:
name: Apache 2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
paths:
/validate/Description:
@jcoyne
jcoyne / openapi.yml
Last active June 9, 2020 16:53
Descriptive metadata with recursion
openapi: 3.0.0
info:
description: Specification for Cocina Models
version: 1.0.0
title: Cocina Models
license:
name: Apache 2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
paths:
/validate/DescriptiveBasicValue:
@jcoyne
jcoyne / works.rb
Created September 17, 2015 17:00
class Book < ActiveFedora::Base
include Hydra::Works::Work
end
class Page < ActiveFedora::Base
include Hydra::Works::Work
end
book = Book.new
page = Page.new
@jcoyne
jcoyne / characterization.rb
Last active January 19, 2020 03:52
Test characterization hydra pcdm goldenseal curationexperts
fs = FileSet.find('mp48sc83h')
file_name = 'tmp/uploads/mp/48/sc/83/letz_01_0020_019.tif'
service = Hydra::Works::CharacterizationService.new(fs, file_name, {})
fits_output = service.send(:extract_metadata, file_name)
terms = service.send(:parse_metadata, fits_output)
irb(main):006:0> local_file = File.open('spec/fixtures/images/world.png') => #<File:spec/fixtures/images/world.png>
irb(main):007:0> local_file = Hydra::Derivatives::IoDecorator.new(local_file)
=> #<File:spec/fixtures/images/world.png>
irb(main):008:0> local_file.mime_type = 'application/foo'
=> "application/foo"
irb(main):009:0> local_file.original_name = 'world.png'
=> "world.png"
irb(main):010:0> Hydra::Works::AddFileToFileSet.call(fs, local_file, :original_file, versioning: false)
Unable to check /var/folders/9t/rygbnddx0b1ckw6tjs3m18qm0000gq/T/20160531-85153-cfleh6 for viruses because no virus scanner is defined
=> #<FileSet id: "ww72bb63r", label: nil, relative_path: nil, import_url: nil, part_of: [], resource_type: [], creator: [], contributor: [], description: [], keyword: [], rights: [], publisher: [], date_created: [], subject: [], language: [], identifier: [], based_near: [], related_url: [], bibliographic_citation: [], source: [], head: [], tail: [], depositor: "jcoyne", title: [], date_uploaded:
@jcoyne
jcoyne / gist:c14691c43e987854922c9e1d84adc949
Last active December 17, 2019 01:46
Fix missing workflows
druids = Sidekiq::RetrySet.new do |job|
((klass, method, args) = YAML.load(job.args[0]))
end.map do |doc|
doc['error_message'].sub(%r{.*http://sul-lyberservices-prod.stanford.edu/workflow//objects/(druid:.{11})/.*}, '\1')
end
druids = ["druid:dv067yc0690", "druid:dt469gf3081", "druid:ky920wg4012", "druid:bk337cj4274", "druid:fr259mm2512", "druid:fv474yq5934", "druid:dq379sd3137", "druid:jv189bp0832", "druid:dv627hd0865", "druid:fv162qg9812", "druid:gz880xr9536", "druid:jz243nw3598", "druid:bz827kn6480", "druid:fp744tg4855", "druid:jg658nj5435", "druid:jk783gq9820", "druid:px855nm9126", "druid:ch376fv6873", "druid:bj513tx7008", "druid:mp546mj3927", "druid:bh956cq9786", "druid:df253qd2344", "druid:gt608br6686", "druid:bq013ky8003", "druid:ms951zt0048", "druid:fn279jk7616", "druid:fv217kn2691", "druid:fk707gf7514", "druid:cz014dj2495", "druid:cb475qw5208", "druid:hx396ky8951", "druid:cw372fd1981", "druid:hq532jr8640", "druid:jt102my9479", "druid:bx756rm7202", "druid:fr190hz8212", "druid:dx487gv0982", "drui
@jcoyne
jcoyne / github-pr-urls.js
Last active November 25, 2019 16:12
Grab GitHub PR URLs for weekly dependency updates
// Forked from https://gist.githubusercontent.com/camillevilla/16b53c50eccc11de0cb40ee0be7dcf03/raw/51f2473d5b04bb72e835ac9168381d87c0961d31/github-pr-urls.js
// PR search at https://github.com/pulls
// is:pr org:sul-dlss head:update-dependencies created:2018-05-08..2018-05-09
// Repo order used in our update script and status table
// https://github.com/sul-dlss/access-update-scripts/blob/master/infrastructure/ruby
var repoList= "argo common-accessioning dlme dlme-transform dor-services-app dor_indexing_app dor-fetcher-service gis-robot-suite google-books hydra_etd hydrus lyberservices-scripts modsulator-app-rails preservation_catalog preservation_robots pre-assembly repository-api rialto-etl rialto-webapp robot-console sul_pub sdr-services-app was-registrar-app was_robot_suite was-thumbnail-service workflow-server-rails"
repoList = repoList.split(' ')