Skip to content

Instantly share code, notes, and snippets.

View grosscol's full-sized avatar

Colin grosscol

View GitHub Profile
@grosscol
grosscol / rescueme.rb
Created January 28, 2016 19:14
Rescue next
(-5..5).each do |v|
begin
puts 10 / v
rescue => e
puts "#{e.message}"
next
end
end
@grosscol
grosscol / solr_cores_status.rb
Last active June 14, 2016 15:55
Grabbing status of solr cores via restful api
def cores_status
vars = {
action: "STATUS",
wt: "json"}
target_url = "#{self.solr_admin_url}/cores"
resp = Typhoeus.get(target_url, params: vars)
if resp.response_code == 200
body = JSON.parse!(resp.response_body)
@grosscol
grosscol / bgrep.sh
Created June 14, 2016 21:25
Grep through the bundle dependencies.
function bgrep {
ag "$@" $(bundle show --paths) .
}
@grosscol
grosscol / gist:bb72a4c47544ef3144505349c5c99200
Created July 21, 2016 21:08
Sufia.rc2 Testing. work/new Error at line 83.
I, [2016-07-21T16:49:06.646470 #24163] INFO -- : Started GET "/concern/works/new" for 141.213.175.79 at 2016-07-21 16:49:06 -0400
I, [2016-07-21T16:49:06.649934 #24163] INFO -- : Processing by CurationConcerns::WorksController#new as HTML
D, [2016-07-21T16:49:06.657529 #24163] DEBUG -- : User Load (0.7ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
D, [2016-07-21T16:49:06.658383 #24163] DEBUG -- : Usergroups are ["public", "registered"]
D, [2016-07-21T16:49:06.679429 #24163] DEBUG -- : Looking for edit field partial curation_concerns/work_forms/edit_fields/_title
D, [2016-07-21T16:49:06.679633 #24163] DEBUG -- : Looking for edit field partial records/edit_fields/_title
D, [2016-07-21T16:49:06.679736 #24163] DEBUG -- : Looking for edit field partial curation_concerns/work_forms/edit_fields/_default
D, [2016-07-21T16:49:06.679883 #24163] DEBUG -- : Looking for edit field partial records/edit_fields/_default
I, [2016-07-21T16:49:06.683664 #24
@grosscol
grosscol / sufia.rc2.resquefail.rb
Created July 22, 2016 21:26
Sufia.rc2 resque failure
{"failed_at"=>"2016/07/22 17:22:34 EDT",
"payload"=>{"class"=>"ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper",
"args"=>[{"job_class"=>"AttachFilesToWorkJob",
"job_id"=>"743a3137-e4bd-4761-8031-b14f7f2e8c24",
"queue_name"=>"ingest",
"arguments"=>[{"_aj_globalid"=>"gid://vs/Work/jq085j963"}, [{"_aj_globalid"=>"gid://vs/Sufia::UploadedFile/14"}, {"_aj_globalid"=>"gid://vs/Sufia::UploadedFile/15"}, {"_aj_globalid"=>"gid://vs/Sufia::UploadedFile/16"}, {"_aj_globalid"=>"gid://vs/Sufia::UploadedFile/17"}]], "locale"=>"en"}]},
"exception"=>"ActiveJob::DeserializationError",
"error"=>"Error while trying to deserialize arguments: uninitialized constant Work",
"backtrace"=>["/hydra-dev/umrdr-staging/shared/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/inflector/methods.rb:261:in `const_get'", "/hydra-dev/umrdr-staging/shared/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/inflector/methods.rb:261:in `block in constantize'", "/hydra-dev/umrdr-staging/shared/vendor
@grosscol
grosscol / print_af_base_properties.rb
Created August 7, 2016 16:03
Print properties and predicates of an ActiveFedora::Base subclass
# Use given single class name arg or default to GenericWork
desc "Print properties of a sub-class of ActiveFedora::Base"
task :properties_to_csv, [:class_name] => :environment do |t, args|
Rails.application.eager_load!
class_name = args.one? ? args[:class_name] : "GenericWork"
print_properties_of class_name.constantize
end
# Given a class, print some properties information as csv
def print_properties_of(klass)
@grosscol
grosscol / print_af_base_properties.rb
Created August 7, 2016 16:03
Print properties and predicates of an ActiveFedora::Base subclass
# Use given single class name arg or default to GenericWork
desc "Print properties of a sub-class of ActiveFedora::Base"
task :properties_to_csv, [:class_name] => :environment do |t, args|
Rails.application.eager_load!
class_name = args.one? ? args[:class_name] : "GenericWork"
print_properties_of class_name.constantize
end
# Given a class, print some properties information as csv
def print_properties_of(klass)
@grosscol
grosscol / Migration Ldp 500
Created September 14, 2016 04:16
Sufia 7.pre -> Sufia 7.1 Migration Error
irb(main):002:0> fs = FileSet.find('gb19f580q')
=> #<FileSet id: "gb19f580q", label: "it150815_074300_000.idl", relative_path: "Data/Simulation Output/Ionosphere Output/it150815_...", 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: "dcsoztrk@umich.edu", title: ["it150815_074300_000.idl"], date_uploaded: "2016-04-21 18:49:04", date_modified: "2016-04-21 18:49:04", access_control_id: "10d89226-68ee-4661-afff-9e3056f45e1a", embargo_id: nil, lease_id: nil>
irb(main):003:0> fs.original_file
=> #<Hydra::PCDM::File uri="http://localhost:8301/fedora/rest/umrdr/gb/19/f5/80/gb19f580q/files/90e50337-8c1a-4482-9842-3eaa9641fc58" >
irb(main):004:0> fs.characterization_proxy
=> #<Hydra::PCDM::File uri="http://localhost:8301/fedora/rest/umrdr/gb/19/f5/80/gb19f580q/files/90e50
@grosscol
grosscol / irb_and_stack_trace
Created September 15, 2016 19:07
Hydra PCDM::Object (FileSet) and PCDM::File (original_file) results in Fedora LDP 500 response.
irb(main):004:0> file_set = FileSet.find("0c483j36g")
=> #<FileSet id: "0c483j36g", label: "Evans_Old_Field_Plant_Database.zip", 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: "cwdick@umich.edu", title: ["Evans_Old_Field_Plant_Database.zip"], date_uploaded: "2016-03-04", date_modified: nil, access_control_id: "5b97fa6e-ed85-4293-a188-294331ac8904", embargo_id: nil, lease_id: nil>
irb(main):005:0> file_set.original_file
=> #<Hydra::PCDM::File uri="http://localhost:8301/fedora/rest/umrdr/0c/48/3j/36/0c483j36g/files/d39bd72b-ada0-4c69-9b3d-40ec151d5525" >
irb(main):006:0> file_set.original_file.metadata
=> #<ActiveFedora::WithMetadata::MetadataNode:0x3f8da1e337d0(#<ActiveFedora::WithMetadata::MetadataNode:0x007f1b43c66fa0>)>
irb(main):007:0> f
@grosscol
grosscol / FeatureError Stacktrace
Created October 10, 2016 20:39
assign_admin_set Stacktrace from Sufia 7.2 upgrade
Started GET "/" for 127.0.0.1 at 2016-10-10 16:37:58 -0400
ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
ActiveFedora: loading fedora config from /home/grosscol/workspace/vanilla-sufia/config/fedora.yml
ActiveFedora: loading solr config from /home/grosscol/workspace/vanilla-sufia/config/solr.yml
Processing by Sufia::HomepageController#index as HTML
Usergroups are ["public"]
ContentBlock Load (0.2ms) SELECT "content_blocks".* FROM "content_blocks" WHERE "content_blocks"."name" = ? ORDER BY created_at DESC LIMIT 1 [["name", "featured_researcher"]]
ContentBlock Load (0.2ms) SELECT "content_blocks".* FROM "content_blocks" WHERE "content_blocks"."name" = ? LIMIT 1 [["name", "marketing_text"]]
ContentBlock Load (0.1ms) SELECT "content_blocks".* FROM "content_blocks" WHERE "content_blocks"."name" = ? LIMIT 1 [["name", "announcement_text"]]
Completed 500 Internal Server Error in 129ms (ActiveRecord: 1.1ms)