Skip to content

Instantly share code, notes, and snippets.

View grosscol's full-sized avatar

Colin grosscol

View GitHub Profile
@grosscol
grosscol / copy_node_btw_docs
Last active August 29, 2015 13:55
Nokogiri copy node between documents and DOMException WRONG_DOCUMENT_ERR
require 'nokogiri'
# The following illustrates unexpected behavior of the Nokogiri::XML::Document.add_child method.
# When called from a new document, the behavior is different depending on if the argument
# is a newly created node or duplicate node.
# String of XML for Nokogiri to parse.
dummy_xml = '<?xml version="1.0" encoding="UTF-8"?>
<root>
<Dummy>Text1</Dummy>
@grosscol
grosscol / active-fedora 9 demo
Last active August 29, 2015 14:09
ActiveFedora9 persisting to Fedora4 beta
# Simple ActiveFedora9 (Fedora4) Example
# Make sure hyda-jetty, using the fedora-4/edge branch, is running (rake jetty:start)
require "active_fedora"
class Dum < ActiveFedora::Base
# The Hydra convention is to minimally have descriptive and rights metadata.
# The Fedora4 paradigm is to define properties directly on the object as opposed to the datastreams of Fedora3
property :title, predicate: ::RDF::DC.title
@grosscol
grosscol / SHSViking Date Comparisons
Last active August 29, 2015 14:18
A naive implementation of doing some counting after data logic for a list of dates and a given source data frame.
# Generate your list of dates
mydays <- seq.Date( as.Date('2015-01-01'), as.Date('2015-03-09'), by="day")
# Write function to sum the number of open dates that occur in sourceData at least 31 days prior to given date.
numOpenDates <- function( givenDate ){
retValue <- sum( (givenDate - sourceDate$openDate) > 30 )
retValue
}
# Apply function to each date in your list of dates(mydays)
@grosscol
grosscol / 1086 rspec fails
Last active August 29, 2015 14:20
Sufia pcdm_1086 fails.
In feature branch to get GenericWork to top level class in Sufia, and
Sufia::Works::Work and Sufia::Works::Generic work as Concern in branch:
https://github.com/grosscol/sufia/tree/pcdm_1086
rspec Failures:
1) CurationConcern::GenericWorkActor#create valid attributes with a file authenticated visibility should stamp each file with the access rights
Failure/Error: expect(subject.create).to be true
ActiveFedora::UnknownAttributeError:
GenericFile does not have an attribute `generic_work_id'
Failures:
1) CurationConcern::GenericWorkActor#create valid attributes with a file authenticated visibility should stamp each file with the access rights
Failure/Error: expect(subject.create).to be true
ActiveFedora::UnknownAttributeError:
GenericFile does not have an attribute `generic_work_id'
# /home/grosscol/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/active-fedora-9.1.1/lib/active_fedora/attributes.rb:103:in `array_setter'
# /home/grosscol/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/active-fedora-9.1.1/lib/active_fedora/attributes.rb:66:in `[]='
# /home/grosscol/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/active-fedora-9.1.1/lib/active_fedora/associations/has_many_association.rb:51:in `set_owner_attributes'
# /home/grosscol/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/active-fedora-9.1.1/lib/active_fedora/associations/has_many_association.rb:57:in `insert_record'
@grosscol
grosscol / gist:c9254b3c89d276c7cacd
Created June 10, 2015 18:06
Ldp::HttpError 500 from Sufia PCDM
Ldp::HttpError in CurationConcern::GenericWorksController#create
STATUS: 500 ...
Extracted source (around line #108):
106
107
108
109
110
111
@grosscol
grosscol / ErrorLog
Created June 19, 2015 17:36
Ldp::HttpError 500 from Sufia pcdm logged
Started POST "/files" for 127.0.0.1 at 2015-06-19 13:33:25 -0400
Processing by GenericFilesController#create as JSON
Parameters: {"utf8"=>"✓", "authenticity_token"=>"n9jfvt5RMoUnka3usBxfJJzPtUh09+OK5tjR5f/FxX+tAq6eA8h3HlmuICdw86Q+CJD/BOlT2xUFupfv9+IICg==", "total_upload_size"=>"3458", "relative_path"=>"", "batch_id"=>"rj430457n", "work_id"=>"", "file_coming_from"=>"local", "terms_of_service"=>"1", "files"=>[#<ActionDispatch::Http::UploadedFile:0x007f36f3997718 @tempfile=#<Tempfile:/tmp/RackMultipart20150619-14610-1cuzuj7.txt>, @original_filename="teach_data_concepts.txt", @content_type="text/plain", @headers="Content-Disposition: form-data; name=\"files[]\"; filename=\"teach_data_concepts.txt\"\r\nContent-Type: text/plain\r\n">]}
User Load (4.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 2]]
(3.6ms) SELECT DISTINCT COUNT(DISTINCT "mailboxer_conversations"."id") FROM "mailboxer_conversations" INNER JOIN "mailboxer_notifications" ON "mailboxer_no
@grosscol
grosscol / EmpyWork Error Log
Created June 19, 2015 17:46
Error log resulting from attempt to create empty work.
Started POST "/works" for 127.0.0.1 at 2015-06-19 13:43:50 -0400
Processing by CurationConcern::GenericWorksController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"qL/V+XGs8GE8s0pwc5i30BZbuJP6xqVCMxp6YeRrnkKaZaTZrDW1+kKMx7mzd0zKggTy32dind3QeDxr7ExTNw==", "generic_work"=>{"resource_type"=>["", "Other"], "title"=>["EmptyWork"], "creator"=>["Colin A. Gross"], "contributor"=>[""], "description"=>[""], "tag"=>["blue"], "rights"=>["", "http://creativecommons.org/licenses/by/3.0/us/"], "publisher"=>[""], "date_created"=>[""], "subject"=>[""], "language"=>[""], "identifier"=>[""], "based_near"=>[""], "related_url"=>[""]}, "visibility"=>"open", "new_user_name_skel"=>"", "new_user_permission_skel"=>"none", "new_group_name_skel"=>"Select a group", "new_group_permission_skel"=>"none", "save_without_files"=>"Save without Files"}
User Load (4.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 2]]
(3.9ms) SELECT DISTINCT COUNT(DISTINCT "mailboxe
CREATE TABLE `ingress` (
`ing_index` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`mrn` varchar(9) DEFAULT NULL,
`originalvial` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`ing_index`)
) ENGINE=InnoDB AUTO_INCREMENT=187434 DEFAULT CHARSET=utf8;
CREATE TABLE `norminv` (
`pni_index` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`mrn` varchar(9) DEFAULT NULL,
       def help_icon
-        content_tag 'i', '', :'aria-hidden' => true, class: 'help-icon'
+        content_tag 'i', '', 'aria-hidden' => true, class: 'help-icon'
       end

Can this be aria-hidden: true ?