Skip to content

Instantly share code, notes, and snippets.

@mankind
mankind / binary_search_tree.rb
Created November 7, 2017 01:24
Valid Binary Search Trees
module BinarySearchTree
class Node
include Comparable
attr_reader :value
attr_accessor :left, :right, :nodes_tracker
def initialize(value)
@value = value
self.nodes_tracker = []
@mankind
mankind / _contributor_group.html.erb
Last active August 17, 2018 14:57
samvera multi-part field
<%=
f.input :contributor_group, as: :contributor_group_type,
wrapper_html: { class: 'multi_value' },
input_html: { class: 'form-control', multiple: true },
include_blank: true,
required: f.object.required?(key)
%>
@mankind
mankind / _attribute_rows.html.erb
Last active July 17, 2019 08:49
attempt to display samvera active-fedora json metatdata field using custom indexer approach
<%= presenter.attribute_to_html(:formatted_creator, render_as: :faceted) %>
@mankind
mankind / _attribute_rows.html.erb
Created August 22, 2018 15:12
attempt to use custom attribute renderere to display samvera active_fedora multi-part metadata json field
<%= presenter.attribute_to_html(:creator, render_as: :creator) %>
@mankind
mankind / create dropdown ie hyku authority or controlled vocabulary
Last active July 7, 2020 09:30
Add multipart metadata fields to samvera active_fedora models
Your next task is to turn the audience field into a dropdown and the dropdown options are 'particpant', 'spectator', 'graduate', 'apprentice'
See http://samvera.github.io/customize-metadata-controlled-vocabulary.html
1. Create a yaml file conatining vocabularies ie dropdown names in config/authorities with thesame name as your field. So if your field is funder, you will have
config/authorities/funder.yml eg https://github.com/ubiquitypress/hyku/blob/test/config/authorities/funder.yml
http://samvera.github.io/customize-metadata-controlled-vocabulary.html#create-a-vocabulary
In that file, add the values you want in your dropdown following the format above.
2. Create a service to load the dropdown names or vocabularies in app/services/
@mankind
mankind / _funder.html.erb
Created October 23, 2018 13:59
Enable autocomplete In Hyrax for funder's field
<%= f.input key,
as: :multi_value,
input_html: {
class: 'form-control',
id: 'ubiquity-funder',
data: { 'autocomplete-url' => "/authorities/search/local/funder",
'autocomplete' => key }
},
required: f.object.required?(key) %>
@mankind
mankind / mail_boxer_notes.rb
Last active October 26, 2018 10:03
rails Mail-boxer notes
#send a message between two users. This will create a Mailoxer::Conversation behind the scene.
user_1 = User.where(email: 'user email').first
user_2 = User.where(email: 'user email').first
message_subject = "Review of work"
message_body = "Kindly look at my submitted work"
user_1.send_message(user_2, message_body , message_subject)
#starting Mail_boxer::Conversation
a = Mailboxer::Conversation.find(1)
yy = a.mesages
@mankind
mankind / note
Last active January 2, 2019 10:19
hyku-kubernetes
sudo vim /etc/sudoers
https://docs.google.com/document/d/1cXS-hQ09_AXATTjcvpKqzrqVEwATsZHY9t2VfTkxRYg/edit#heading=h.wxbnbz4dhgpy
https://www.digitalocean.com/community/tutorials/how-to-install-software-on-kubernetes-clusters-with-the-helm-package-manager
https://docs.helm.sh/using_helm/#quickstart-guide
helm installed into /usr/local/bin/helm
tiller installed into /usr/local/bin/tiller
Run 'helm init' to configure helm.
@mankind
mankind / database.yml
Last active January 2, 2019 12:35
example docker-compose with netwroks
# PostgreSQL. Versions 9.1 and up are supported.
#
# Install the pg driver:
# gem install pg
# On OS X with Homebrew:
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
# On OS X with MacPorts:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
@mankind
mankind / add_file.rb
Last active January 30, 2019 09:21
general-notes
#app/services/ubiquity/add_file.rb
#this works as it is called whilr creating hte file, however all efforts to set the file_size field failed
module Ubiquity
module AddFile
#private
=begin
def attach_attributes(file)
puts "lagos"
::Ubiquity::DetermineFileSize.call(file)