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 / search.rb
Last active November 13, 2019 15:12
Search for Druids
filter = 'wf_wps_ssim:"accessionWF:sdr-ingest-transfer:error"'
search = Blacklight.default_index.search(fq: filter, fl: 'id', rows: 10_000)
druids = search.response['docs'].map {|d| d['id']}
@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
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
["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", "druid:bh459tv
@jcoyne
jcoyne / gist:e588b17557132666441a41dca6ef5e6c
Last active October 31, 2019 20:50
Check for complete results.
def check(id)
result = Dor::Services::Client::AsyncResult.new(url: "https://dor-services-prod.stanford.edu/v1/background_job_results/#{id}")
return 'good' if result.complete? && result.errors.nil?
return 'not complete' if !result.complete?
result.errors
end
ids = ["18157", "18108"]
ids.each { |id| puts id if check(id) == 'good' }
@jcoyne
jcoyne / 01_declaring_controller.html
Last active October 22, 2019 19:26 — forked from noelrappin/01_declaring_controller.html
Copy paste parts from Stimulus Workshop
# app/views/schedule/index.html.erb:29-30
<section class="day-body"
id="day-body-<%= schedule_day.day.by_example("2006-01-02") %>"
data-controller="toggle">