Skip to content

Instantly share code, notes, and snippets.

View mcritchlow's full-sized avatar

Matthew Critchlow mcritchlow

  • UC San Diego
  • San Diego
View GitHub Profile
@mcritchlow
mcritchlow / work.rb
Created August 29, 2018 23:28
Work rdms schema
# This is a crazy idea. but, do we really need a graph-based approach?
# Is this stuff really going to change that often?
# Could we use something like Single Table Inheritance to make this more sane since so much data is shared?
class Work < ApplicationRecord
has_many :subjects
has_namy :agents
delegate :topics, :names, :anatomies, to: :subjects
delegate :creators, :contributors, :publishers, to: :agents
@mcritchlow
mcritchlow / damspas-load.sh
Created May 25, 2018 18:47
DAMSPAS Load test
#!/bin/bash
files_to_download=(
"https://librarytest.ucsd.edu/dc/object/bb8022051s/_2.mp4/download"
"https://librarytest.ucsd.edu/dc/object/bb8977691g/_2.mp4/download"
"https://librarytest.ucsd.edu/dc/object/bb55983863/_1.pdf/download"
"https://librarytest.ucsd.edu/dc/object/bb38236288/_1.pdf/download"
"https://librarytest.ucsd.edu/dc/object/bb2015477n/_1.pdf/download"
)
# run tests
# setting jobs to 0 will run as many jobs as possible concurrently
@mcritchlow
mcritchlow / cil_csv.rb
Last active May 14, 2018 16:08
CIL Data Processing R&D
# Ruby script to test out parsing the CIL json data and dump to csv
#
# For now, we're concatenating the property hierarchy with colons
# So CIL: { "Image Files" [ "Mime_type": "application/zip" will be CIL:Image Files:Mime_type "application/zip"
require 'open-uri'
require 'json'
require 'byebug'
require 'csv'
# Hackety hacks, don't talk back
@mcritchlow
mcritchlow / a_summary.md
Last active March 28, 2018 21:11
Analytics Query Testing
@mcritchlow
mcritchlow / modeling.md
Last active February 27, 2018 16:56
Hyrax Analytics Modeling Options

Summary

The current model pattern for Google Analytics statistics support in Hyrax follows essentially the following database format:

  create_table "work_view_stats", force: :cascade do |t|
    t.datetime "date"
    t.integer "work_views"
    t.string "work_id"
    t.datetime "created_at", null: false
 t.datetime "updated_at", null: false
@mcritchlow
mcritchlow / terminus_install.sh
Last active April 1, 2023 04:43
Install terminus as console font for Solus
# install terminus console fonts (only)
wget https://sourceforge.net/projects/terminus-font/files/terminus-font-4.46/terminus-font-4.46.tar.gz/download -O terminus.tar.gz
tar -xvf terminus.tar.gz
cd terminus-font-4.46
./configure --prefix=/usr
make -j4 psf
sudo make install-psf
# add kernel parameter for vconsole.font
echo 'vconsole.font=ter-v32n' | sudo tee /etc/kernel/cmdline
@mcritchlow
mcritchlow / base.rb
Last active February 15, 2018 16:06
Hyrax::Analytics API Ideas
module Hyrax
module Analytics
# @abstract Base class for Analytics services that support statistics needs in Hyrax.
# Implementing subclasses must define `#connection` `#remote_statistics` and `#to_graph`
class Base
# Establish connection with the analytics service
def self.connection
raise NotImplementedError, "#{self.class}#connection is unimplemented."
end

At UC San Diego we have a few use cases that require us to make a distinction between access control on a source file (original file) and derivatives. Most of these are related to traditonal digitized library collections where there is a donor or content provider agreement that the source files cannot be made publicly available for view/download.

Our discussion started with a post on Samvera Tech [1]. Essentially the core use case is as follows:

  1. upload a source file (tiff, wav, etc.)
  2. mark that object with the visibility of "public"
  3. mark the source file with visibility of "private" does not exist

Current Behavior:

@mcritchlow
mcritchlow / braindump.md
Last active August 25, 2017 18:24
Google Calendar / Confluence Integration thoughts

Assumptions

From what I can gather, here are the desired outcomes of having a community google calendar for the intranet

  1. Quick access to entire calendar via LiSN home page (already exists)
  2. Ability to place single event instances in the weekly update with ability for staff to easily add a single event to their personal calendar

(2) is currently the pain point, as the steps involved are very tedious. I wonder if this should be thought of differently, either way we need to leverage the google calendar more imo.

Potential solution(s) - leverage Google Calendar API

A starting point for this might be to look into using the Google Calendar API as follows (via a Confluence macro):

@mcritchlow
mcritchlow / config.ru
Last active July 3, 2017 16:25
Slack Ruby Bot - Server Hooks
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'dotenv'
Dotenv.load
require 'slack_library_bot'
require 'web'
Thread.abort_on_exception = true