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 / demo.txt
Last active March 2, 2018 22:30
TACO Sprint 2 Demo Script
curl -X POST -H "Content-Type: application/json" -d@examples/request.json http://taco-dev.sul.stanford.edu/v1/resource
curl -s http://taco-dev.sul.stanford.edu/v1/resource/ | json_pp
curl -X PATCH -H "Content-Type: application/json" -d@examples/update_request.json http://taco-dev.sul.stanford.edu/v1/resource/
curl -s http://taco-dev.sul.stanford.edu/v1/resource/ | json_pp
@jcoyne
jcoyne / taco1-demo-script.txt
Last active February 22, 2018 22:58
TACO Sprint 1 Demo script
SERVICES=dynamodb,kinesis,s3 localstack start
# Open new shell
awslocal dynamodb create-table --table-name resources \
--attribute-definitions "AttributeName=id,AttributeType=S" \
--key-schema "AttributeName=id,KeyType=HASH" \
--provisioned-throughput=ReadCapacityUnits=100,WriteCapacityUnits=100
awslocal s3api create-bucket --bucket taco-deposited-files
@jcoyne
jcoyne / Email.txt
Created November 6, 2017 19:46
Email.txt
Hey all,
Sorry for the lateness of this, I had a lot of trouble getting the VM for this to work. Before the workshop tomorrow, please do the following:
Download and install Vagrant https://www.vagrantup.com/downloads.html
Download and install Virtualbox https://www.virtualbox.org/wiki/Downloads
Checkout the Github project: https://github.com/tpendragon/valkyrie_workshop.git (either git clone https://github.com/tpendragon/valkyrie_workshop.git or download from https://github.com/tpendragon/valkyrie_workshop/archive/master.zip)
Within that project run `vagrant up`
On Hotel wireless the above takes around 40->60 minutes.
After it’s done importing, you can bring the VM down with `vagrant down`

Cantaloupe, no-cache, using Kakadu

$ ab -n 30 'https://sul-imageserver-uat.stanford.edu/iiif/2/bc%2F151%2Fbq%2F1744%2Fbc151bq1744_00_0001.jp2/full/!400,400/0/default.jpg'
Document Length:        19677 bytes

Concurrency Level:      1
Time taken for tests:   3.441 seconds
Complete requests:      30
Failed requests:        0
Total transferred:      606390 bytes
id = StacksIdentifier.new('yx350pf4616%2Fyx350pf4616_00_0001.jp2')
transform = Iiif::OptionDecoder.decode(region: 'full', size: '748,')
image = StacksImage.new(id: id)
projection = image.projection_for(transform)
ability = Ability.new(User.new)
ability.can?(:read, projection)
=> true
$ rvm install ruby-2.4.2
ruby-2.4.2 - #removing src/ruby-2.4.2...
Error running '__rvm_rm_rf /usr/local/rvm/src/ruby-2.4.2',
showing last 15 lines of /usr/local/rvm/log/1506095856_ruby-2.4.2/remove.src.log
++ case "${target}" in
++ [[ -z /usr/local/rvm/src/ruby-2.4.2 ]]
++ [[ -d /usr/local/rvm/src/ruby-2.4.2 ]]
++ command rm -rf /usr/local/rvm/src/ruby-2.4.2
++ rm -rf /usr/local/rvm/src/ruby-2.4.2
rm: cannot remove `/usr/local/rvm/src/ruby-2.4.2/.ext/include/x86_64-linux/ruby/config.h': Permission denied
1) Blacklight::ShowPresenter#html_title with an html_title_field passes the no_html option to the FieldPresenter
Failure/Error: FieldPresenter.new(view_context, document, field_config, options).render
#<Blacklight::FieldPresenter (class)> received :new with unexpected arguments
expected: (#<Double (anonymous)>, #<SolrDocument:0x007ffa0239af18 @_source={"id"=>1, "link_to_facet_true"=>"x", "link_to_facet_named"=>...8915446827338632>}, :dc_xml=>{:content_type=>"text/xml"}, :oai_dc_xml=>{:content_type=>"text/xml"}}>, an_instance_of(Blacklight::Configuration::NullField), {:no_html=>true})
got: (#<Double (anonymous)>, #<SolrDocument:0x007ffa0239af18 @_source={"id"=>1, "link_to_facet_true"=>"x", "link_to_facet_named"=>...8915446827338632>}, :dc_xml=>{:content_type=>"text/xml"}, :oai_dc_xml=>{:content_type=>"text/xml"}}>, #<Blacklight::Configuration::NullField field="id">, {:no_html=>true})
Diff:
@@ -1,5 +1,5 @@
[#<Double (anonymous)>,
#<SolrDocumen
@jcoyne
jcoyne / errors.json
Last active August 21, 2017 19:39
Errors with 2k+ occurances
{"notices_count"=>2338, "klass"=>"Faraday::ClientError", "message"=>"the server responded with status 500", "url"=>"https://app.honeybadger.io/projects/50046/faults/33402072", "project_name"=>"sul_pub"}
{"notices_count"=>2364, "klass"=>"Blacklight::Exceptions::InvalidSolrID", "message"=>"Blacklight::Exceptions::InvalidSolrID", "url"=>"https://app.honeybadger.io/projects/50022/faults/33185669", "project_name"=>"SearchWorks"}
{"notices_count"=>2528, "klass"=>"ActiveJob::DeserializationError", "message"=>"Error while trying to deserialize arguments: Couldn't find MediatedPage with 'id'=115150 [WHERE `requests`.`type` IN ('MediatedPage')]", "url"=>"https://app.honeybadger.io/projects/49963/faults/31911913", "project_name"=>"sul-requests"}
{"notices_count"=>2669, "klass"=>"NoMethodError", "message"=>"undefined method `[]' for nil:NilClass", "url"=>"https://app.honeybadger.io/projects/52892/faults/34206434", "project_name"=>"dor-utils"}
{"notices_count"=>2902, "klass"=>"RuntimeError", "message"=>"Server error on au
#!/usr/bin/env ruby
# Provide your honeybadger access token as the first argument
@token = ARGV[0]
require 'json'
require 'net/http'
require 'active_support'
require 'active_support/core_ext/hash'
@jcoyne
jcoyne / block.rb
Created August 17, 2017 02:29
Ruby confusion
# Ruby's String#gsub can take a block argument.
'foo'.gsub(/f(.)/) { Regexp.last_match[1] }
=> "oo"
# Here's a method that takes a block argument and passes it to String#gsub
def do_thing(&block)
'foo'.gsub(/f(.)/, &block)
end