Skip to content

Instantly share code, notes, and snippets.

View awead's full-sized avatar
🏠
Working from home

Adam Wead awead

🏠
Working from home
View GitHub Profile
@awead
awead / gist:73dff46f95ac30e1a4ff
Created January 27, 2015 20:42
scholarsphere:x346d634h
<rdf:RDF xmlns:ns0="info:fedora/fedora-system:def/relations-external#" xmlns:ns1="info:fedora/fedora-system:def/model#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="info:fedora/scholarsphere:x346d634h">
<ns1:hasModel rdf:resource="info:fedora/afmodel:GenericFile"></ns1:hasModel>
<ns0:isPartOf rdf:resource="info:fedora/scholarsphere:x346d619d"></ns0:isPartOf>
</rdf:Description>
</rdf:RDF>
irb(main):012:0> f = GenericFile.find("scholarsphere:x346d634h")
=> #<GenericFile pid: "scholarsphere:x346d634h", mime_type: "application/pdf", format_label: ["Portable Document Format"], file_size: ["1309183"], last_modified: ["2014:10:21 16:10:38-04:00"], filename: ["2006.001.Jones-Stolper.pdf"], original_checksum: ["8daaea4d5e7d94adf06a0d75b7612911"], rights_basis: [], copyright_basis: [], copyright_note: [], well_formed: ["true"], valid: ["true"], status_message: [], file_title: [], file_author: [], page_count: ["22"], file_language: [], word_count: [], character_count:
@awead
awead / gist:a87f9cb2bc9a6224ae54
Created January 23, 2015 15:58
Escaped triples
<info:fedora/scholarsphere:6395wb555> <http://purl.org/dc/terms/title> "Leeman et al. 2014 JGR Data" .
<info:fedora/scholarsphere:6395wb555> <http://purl.org/dc/terms/creator> "John R. Leeman" .
<info:fedora/scholarsphere:6395wb555> <http://purl.org/dc/terms/description> "Data for:\r\nJournal: Journal of Geophysical Research: Solid Earth\r\n\r\nArticle title: \"On the Origin and Evolution of Electrical Signals During Frictional Stick-Slip in Sheared Granular Material\"" .
<info:fedora/scholarsphere:6395wb555> <http://purl.org/dc/terms/dateSubmitted> "2014-04-30Z"^^<http://www.w3.org/2001/XMLSchema#date> .
<info:fedora/scholarsphere:6395wb555> <http://purl.org/dc/terms/modified> "2014-04-30Z"^^<http://www.w3.org/2001/XMLSchema#date> .
@awead
awead / gist:c318aa5d8629bdb4cbca
Created January 16, 2015 16:20
Writing to fcr:metadata
irb(main):018:0> f4.thumbnail.metadata.get_values(ActiveFedora::RDF::Fcrepo4.created)
=> [Fri, 16 Jan 2015 03:43:25 +0000]
irb(main):019:0> f4.thumbnail.metadata.set_value(ActiveFedora::RDF::Fcrepo4.created, "foo")
=> nil
irb(main):020:0> f4.thumbnail.metadata.get_values(ActiveFedora::RDF::Fcrepo4.created)
=> ["foo"]
irb(main):021:0> f4.thumbnail.metadata.save
NoMethodError: undefined method `local_attributes' for #<ActiveFedora::WithMetadata::MetadataNode:0x007fc8c9e8d340>
from /Users/awead/Projects/Github/psu-stewardship/scholarsphere/.bundle/ruby/2.1.0/gems/rdf-1.1.7/lib/rdf/mixin/enumerable.rb:693:in `method_missing'
from /Users/awead/Projects/Github/psu-stewardship/scholarsphere/.bundle/ruby/2.1.0/gems/rdf-1.1.7/lib/rdf/mixin/mutable.rb:175:in `method_missing'
@awead
awead / gist:f8411090bd28d14ead09
Created January 14, 2015 19:47
Using RDF::Reader with ntriples datastream
[16, 25] in /Users/awead/Projects/Github/projecthydra-labs/fedora-migrate/lib/fedora_migrate/rdf_datastream_mover.rb
16: save
17: end
18:
19: def migrate_rdf_triples
20: byebug
=> 21: target.resource << RDF::Reader.for(:ntriples).new(source.content)
22: end
23:
@awead
awead / gist:20249664b9a23281f614
Created January 9, 2015 20:42
Cap failure messages
~/Projects/Github/psu-stewardship/scholarsphere (fedora-4/migrate *%=)$ bundle exec cap demo deploy BRANCH_NAME=fedora-4/migrate
** Invoke demo (first_time)
** Execute demo
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke rbenv:validate (first_time)
** Invoke rbenv:install (first_time)
** Execute rbenv:install
** Invoke rbenv:install_rbenv (first_time)
** Execute rbenv:install_rbenv
@awead
awead / gist:81da09a83b173af505ab
Created January 9, 2015 19:57
Cap deploy fails
~/Projects/Github/psu-stewardship/scholarsphere (fedora-4/migrate *%=)$ bundle exec cap demo deploy BRANCH_NAME=fedora-4/migrate
** Invoke demo (first_time)
** Execute demo
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke rbenv:validate (first_time)
** Invoke rbenv:install (first_time)
** Execute rbenv:install
** Invoke rbenv:install_rbenv (first_time)
** Execute rbenv:install_rbenv
@awead
awead / gist:7025154f9c9674253ade
Created January 8, 2015 20:02
Scholarsphere fedora-4/develop failure
GenericFilesController::create rescued ActionView::MissingTemplate
Missing template generic_files/jq_upload, application/jq_upload with {:locale=>[:en], :formats=>[:json], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml]}. Searched in:
* "/Users/awead/Projects/Github/psu-stewardship/scholarsphere/app/views"
* "/Users/awead/Projects/Github/psu-stewardship/scholarsphere/.bundle/ruby/2.1.0/gems/devise-3.2.4/app/views"
* "/Users/awead/Projects/Github/psu-stewardship/scholarsphere/.bundle/ruby/2.1.0/bundler/gems/sufia-81d7d2b23292/app/views"
* "/Users/awead/Projects/Github/psu-stewardship/scholarsphere/.bundle/ruby/2.1.0/gems/mailboxer-0.12.4/app/views"
* "/Users/awead/Projects/Github/psu-stewardship/scholarsphere/.bundle/ruby/2.1.0/gems/blacklight_advanced_search-5.1.2/app/views"
* "/Users/awead/Projects/Github/psu-stewardship/scholarsphere/.bundle/ruby/2.1.0/bundler/gems/browse-everything-d380e4b8c91a/app/views"
* "/Users/awead/Projects/Github/psu-stewardship/scholarsphere/.
@awead
awead / gist:219b6055e08b1a5bd8c3
Created November 13, 2014 17:00
has versions
def has_verisons?
ActiveFedora.fedora.connection.get(versions_url)
true
rescue Ldp::Error
false
end
end
@awead
awead / gist:960301e1b0e39742fd6b
Created October 29, 2014 17:22
Curl example to make something versionable
curl -X PATCH -H "Content-type: application/sparql-update" --data-binary "insert data { <http://localhost:8983/fedora/rest/test/81/e3/aa/db/81e3aadb-e54e-423f-9ac3-85d96c726aa3/descMetadata/fcr:versions> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.jcp.org/jcr/mix/1.0versionable> . }" http://localhost:8983/fedora/rest/test/81/e3/aa/db/81e3aadb-e54e-423f-9ac3-85d96c726aa3/descMetadata/fcr:versions
@awead
awead / gist:787bdd31c6182db77230
Created October 28, 2014 16:01
curl -H "Accept: text/turtle" http://localhost:8983/fedora/rest/test/4c/e0/ee/93/4ce0ee93-7bfb-4745-aaaa-62c7ce0cf7e5/fcr:versions
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix nt: <http://www.jcp.org/jcr/nt/1.0> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix fcrepo: <http://fedora.info/definitions/v4/repository#> .
@prefix ns001: <http://purl.org/dc/terms/> .
@prefix test: <info:fedora/test/> .
@prefix fedoraconfig: <http://fedora.info/definitions/v4/config#> .
@prefix image: <http://www.modeshape.org/images/1.0> .
@prefix xs: <http://www.w3.org/2001/XMLSchema> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .