Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeremy Friesen jeremyf

View GitHub Profile
@jeremyf
jeremyf / latin1-to-utf8.rb
Last active Aug 19, 2019
A ruby script to help automate getting a Rails application out of MySQL's character encoding hell.
View latin1-to-utf8.rb
# The below script attempts to automate the character encoding challenges
# encountered with mysql, latin1 and UTF8
# http://www.bluebox.net/news/2009/07/mysql_encoding/
# ==============================================================================
# Copyright © 2013 University of Notre Dame
# Additional copyright may be held by others, as reflected in the commit history.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
View build-probabilities-for-bitd.rb
# Prerequisites: You need Ruby 2.4.4 or greater. My recommendation is to install ruby via rbenv (https://github.com/rbenv/rbenv)
# To run on the command line:
# 1) Download this gist
# 2) Run the following command: ruby /path/to/this/file.rb
class Scenario
attr_reader :failure, :compromised_success, :success, :critical, :total, :pool_size
def initialize(pool_size:)
@pool_size = pool_size
@total = 0
@failure = 0
@jeremyf
jeremyf / embarkation_and_journey_scenarios_for_aime.rb
Last active Dec 19, 2018
A script for running scenarios against Adventures in Middle-earth Embarkation and Journey rules; See http://takeonrules.com/2018/12/19/diving-further-into-embarkation/
View embarkation_and_journey_scenarios_for_aime.rb
#!/usr/bin/env ruby -wKU
ITERATIONS = 100_000
TERRAINS = %i(easy moderate hard severe daunting)
Guide = Struct.new(:survival_proficiency, :wisdom_modifier, :label) do
def to_s; label; end
end
GUIDES = [
Guide.new(0,-1, "naive level 1"),
Guide.new(2,2, "trained level 1"),
View random-table.rb
require 'forwardable'
gem 'dice_parser'
require 'dice'
# Responsible for registering random tables and exposing a means of rolling on those tables.
class TableRegistry
# @api public
# @example
# document = [{
# key: '1-a',
@jeremyf
jeremyf / tools-for-troubleshooting-ruby.md
Last active Feb 7, 2018
Tools for Troubleshooting Ruby
View tools-for-troubleshooting-ruby.md
@jeremyf
jeremyf / README.md
Last active Jan 24, 2018
Rails runner friendly script to associate pids with a collection
View README.md

The associated Ruby script is more of a proof of concept to demonstrate using pipes and parameters in conjunction with the Rails runner. I have not fully verified that it works.

echo '<work_pid>' | bundle exec rails runner associate_pids_with_collection.rb -c <collection_pid>
@jeremyf
jeremyf / run-hyrax.md
Last active Dec 19, 2017
Script to run the internal app of Hyrax (and thus ease testing a bit)
View run-hyrax.md
  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 / padwg.timeline.mermaid
Last active Dec 8, 2017
Permission Analysis and Design Working Group Timeline
View padwg.timeline.mermaid
gantt
# See documentation concerning Mermaid-based gantt charts https://mermaidjs.github.io/gantt.html
# The PNG was generated via Atom's mermaid plugin
# * Install atom (https://atom.io)
# * Install atom-mermaid (https://atom.io/packages/atom-mermaid)
# * Open atom and paste this document into an empty buffer
# * Set Syntax to Mermaid
# * Type Command+Shift+P to search for the "Atom Mermaid: Toggle" to view the mermaid preview
# * In the preview pane, right click and select "Save As PNG"
dateFormat YYYY-MM-DD
@jeremyf
jeremyf / cibuild
Created Nov 21, 2017
Cibuild proposal that includes indication on what is starting and stopping
View cibuild
#!/usr/bin/env bash
set -e # halt script on error
echo "=~=~=~=~=~= Starting jekyll build =~=~=~=~=~="
bundle exec jekyll build
echo "=~=~=~=~=~= Finished jekyll build =~=~=~=~=~="
echo "=~=~=~=~=~= Starting htmlproofer =~=~=~=~=~="
bundle exec htmlproofer ./_site
echo "=~=~=~=~=~= Finished htmlproofer =~=~=~=~=~="
@jeremyf
jeremyf / assigning-a-person-to-review-a-submission.md
Created Nov 8, 2017
Assigning a person to review a submission based on properties of the work
View assigning-a-person-to-review-a-submission.md

Goal

Assigning a person to review a submission based on properties of the work. And you don't need multiple admin sets to do this.

Whirlwind Workflow

Two primary concepts of the workflow in Hyrax 2.0:

  1. Permissions are assigned at two levels:
  2. [Sipity::WorkflowResponsibility][sipity_workflow_responsibility] - A person has permissions to all things using this workflow
You can’t perform that action at this time.