Skip to content

Instantly share code, notes, and snippets.

"you're right, no human being would stack books like this"

Eric Phetteplace phette23

"you're right, no human being would stack books like this"
View GitHub Profile
phette23 / hashcode.js
Last active Jul 21, 2021
find hash in openEQUELLA file storage path
View hashcode.js
#!/usr/bin/env node
//jshint node:true
// useful for finding location of files on server, for non-advanced storage config location is
// {{data dir}}/Institutions/{{institution name}}/Attachments/${hashCode(uuid)}/${uuid}/${version}
// for advanced storage config it's
// {{data dir}}/Institutions/{{institution name}}/Attachments/${collection UUID}/${hashCode(uuid)}/${uuid}/${version}
const readline = require('readline')
let hashCode = function(str){
let hash = 0
phette23 / newbooks-report.sql
Last active Sep 18, 2019
example of displaying 20 most recent bibs from Koha public report
View newbooks-report.sql
SELECT b.title,, b.biblionumber
FROM biblio b
GROUP BY b.datecreated DESC
phette23 /
Last active Sep 13, 2019
download all EQUELLA logs from a specified day on both app nodes
#!/usr/bin/env fish
# usage: vlog [date string] e.g. `vlog yesterday` or just `vlog` (for today's logs)
# requires SSH aliases for both app nodes (v1 & v2)
if test -n $argv[1]
# need to use gnu date to get the human readable --date parameter
set d (gdate --date="$argv[1]" "+%Y-%m-%d")
set d (gdate "+%Y-%m-%d")
phette23 /
Created May 15, 2019
custom function for Google Sheets to return data from VAULT (openEQUELLA) search API
// custom function for Google Sheets
// usage: TRANSPOSE(VAULTSEARCH("Student, Name")) returns data from Supplemental Portfolio Review collection
function VAULTSEARCH(query) {
var token = '...', // oauth access token
opts = {
contentType: 'application/json',
headers: { 'X-Authorization': 'access_token=' + token }
data = UrlFetchApp.fetch(',detail&q=' + encodeURIComponent(query), opts),
results = JSON.parse(data).results,
phette23 /
Created May 3, 2019
get Moodle course category information from API
import requests
# request URL looks like
def get_mdl_categories(filter):
""" obtain a list of JSON representations of Moodle course categories
returns an array of category dicts (see their fields below)
phette23 /
Created Apr 17, 2019
trying out a few methods of testing for inclusion in a large list
I tested a few options for testing for inclusion in a very large (millions of items) set. Results if you're curious:
¿ python3
> List took 71.93408012390137s time
> Heap took 160.27557826042175s time
> Sorted Containers took 0.004794120788574219s time
sortedcontainers is _real_ fast.
from heapq import *
phette23 /
Created Feb 7, 2019
upload a taxonomy to openEQUELLA using a specially-formatted CSV
#!/usr/bin/env python2
# ################################# #
# #
# #
# added CLI by Eric Phetteplace #
# California College of the Arts #
# | #
# 2014-07-32 #
# #
# Pearson's notes below #
phette23 / equella-disk-space.sql
Created Jan 28, 2019
how much disk space do the attachments for each openEQUELLA collection take up
View equella-disk-space.sql
-- attachment.value1 is the file size for "file" type attachments
-- does not capture a) zip files, b) generated thumbnails
-- but the item.total_file_size column which should include this is inaccurate
SELECT be.uuid, be_name.text AS collection, SUM(CAST(a.value1 AS bigint)) AS "disk space"
FROM item i
INNER JOIN base_entity be ON = i.item_definition_id
LEFT JOIN language_string i_name ON i.name_id = i_name.bundle_id
LEFT JOIN language_string be_name ON be.name_id = be_name.bundle_id
JOIN (SELECT * FROM attachment WHERE attachment.type = 'file') a ON = a.item_id
WHERE i.institution_id = 1165188
phette23 / broken link format.js
Last active Dec 12, 2018
format a support ticket for reporting a broken link in Summon (paste into dev tools)
View broken link format.js
phette23 / equella bulk download.js
Created Dec 6, 2018
bulk download attachments from a list of item UUIDs (openEQUELLA)
View equella bulk download.js
#!/usr/bin/env node
// given a set of item UUIDs, download all their attached files
// .equellarc file with credentials for API use
let options = require('rc')('equella', {})
let headers = { 'X-Authorization': 'access_token=' + options.token }
const fs = require('fs')
const request = require('request')
// construct API URL