Skip to content

Instantly share code, notes, and snippets.

View jeremyf's full-sized avatar

Jeremy Friesen jeremyf

View GitHub Profile
@jeremyf
jeremyf / super.rb
Created April 13, 2017 20:01
Super method definition
module A
def hello
puts 'hello'
end
end
module B
def hello
puts 'potato'
super
@jeremyf
jeremyf / solr_doc_for.rb
Created March 21, 2017 14:46
Proposed extraction of SolrDocFor
module ActiveFedora
module Plugin
module SolrDocFor
class_attribute :default_solr_document_class
self.default_solr_document_class = ::SolrDocument
# @param [String] id - of the object to cast to the given :solr_document_class
# @param [#new] solr_document_class
# @return Instance of the configured ActiveFedora::Plugin::SolrDocFor.default_solr_document_class
# @see ActiveFedora::Plugin::SolrDocFor.default_solr_document_class
@jeremyf
jeremyf / run-hyrax.md
Last active December 19, 2017 20:14
Script to run the internal app of Hyrax (and thus ease testing a bit)
  1. Open Terminal 1
  2. cd /path/to/hyrax
  3. rake engine_cart:regenerate -- Rebuild the internal app; May not be necessary
  4. Terminal 1: rake engine_cart:server -- Analogue to cd .internal_test_app; rails s
  5. Open Terminal 2
  6. cd cd /path/to/hyrax
  7. fcrepo_wrapper -v -p 8984 --no-jms
  8. Open Terminal 3
  9. cd cd /path/to/hyrax
  10. solr_wrapper -v -d solr/config/ -n hydra-development -p 8983
@jeremyf
jeremyf / deep_merge_two_yaml_files.rb
Created November 3, 2016 16:06
deep_merge_two_yaml_files.rb
gem 'activesupport'
require 'active_support/core_ext/hash/deep_merge'
require 'psych'
first_hash = Psych.load_file(PATH_TO_FIRST_FILE)
second_hash = Psych.load_file(PATH_TO_SECOND_FILE)
File.write(PATH_TO_MERGED_FILE, Psych.dump(first_hash.deep_merge(second_hash)))
@jeremyf
jeremyf / presentation.md
Last active October 5, 2016 13:46
We added Sipity workflow to CurationConcerns [Hydra Connect 2016 Lightning Talk]
"Theme From Flood" by They Might Be Giants
"Good Vibrations" by The Beach Boys
"I'm The Ocean" by Neil Young
"Take Me To The River" by Talking Heads
"Undertow" by R.E.M.
"The Ocean" by U2
"Everyday Is Like Sunday" by Morrissey
"Surf's Up Tonight" by Midnight Oil
"Prince Caspian" by Phish
"Wave Of Mutilation" by Pixies
@jeremyf
jeremyf / stack.rb
Last active January 13, 2016 02:01
non_implemented_stack.rb
class LinkedListNode
attr_accessor :value, :points_to_node
def initialize(value, points_to_node=nil)
@value = value
@points_to_node = points_to_node
end
end
class Stack
@jeremyf
jeremyf / image_blur3.rb
Created November 24, 2015 22:08
image_blur_3.rb
class Image
def initialize(two_dimensional_array, marker = 1)
@data = two_dimensional_array
@marker = marker
end
attr_reader :data, :marker
def output_image
data.each { |row| puts row.join }
end
class Numbers
def initialize(list)
@list = list
end
attr_reader :list
def includes?(a_number)
return true if list.detect { |element| element.to_i == a_number.to_i }
return false
end
@jeremyf
jeremyf / processing_queries.rb
Created September 11, 2015 18:25
farewell-my-arel-friend.rb
# @api public
#
# An ActiveRecord::Relation scope that meets the following criteria:
#
# * Users that are directly associated with the given entity through on or
# more of the given roles
# * Users that are indirectly associated with the given entity by group
# and role.
#
# @param roles [Sipity::Models::Role]