Skip to content

Instantly share code, notes, and snippets.

View jeremyf's full-sized avatar

Jeremy Friesen jeremyf

View GitHub Profile
@jeremyf
jeremyf / embarkation_and_journey_scenarios_for_aime.rb
Last active December 19, 2018 16:30
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/
#!/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"),
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 / README.md
Last active January 24, 2018 15:57
Rails runner friendly script to associate pids with a collection

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 / padwg.timeline.mermaid
Last active December 8, 2017 17:06
Permission Analysis and Design Working Group Timeline
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jeremyf
jeremyf / cibuild
Created November 21, 2017 19:53
Cibuild proposal that includes indication on what is starting and stopping
#!/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 November 8, 2017 20:35
Assigning a person to review a submission based on properties of the work

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
# 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 / compare-new-and-not-new.sh
Created June 2, 2017 16:59
Diff two files using gorn
# Transform JSON (from a file, URL, or stdin) into discrete assignments to make it greppable
for file in new-*; do diff <(gron "`echo $file | sed  's/new-//'`") <(gron $file) >> diffs.txt; done
{
"@context": {
"xsd": "http://www.w3.org/2001/XMLSchema#",
"deri": "http://sindice.com/vocab/search#",
"und": "http://localhost:3000/show/",
"dc": "http://purl.org/dc/terms/",
"deri:first": {
"@type": "@id"
},
"deri:last": {
@jeremyf
jeremyf / dcc-retiring-procedure.rb
Last active April 22, 2017 03:52
A script for transitioning characters to retirement, yet not allowing them off of the hook.
require 'logger'
ABILITY_SCORE_MODIFIER = {
0 => :dead,
1 => -3, 2 => -3, 3 => -3,
4 => -2, 5 => -2,
6 => -1, 7 => -1, 8 => -1,
9 => 0, 10 => 0, 11 => 0, 12 => 0,
13 => 1, 14 => 1, 15 => 1,
16 => 2, 17 => 2,
18 => 3,