Instantly share code, notes, and snippets.

not everything needs a status

Eric Phetteplace phette23

View GitHub Profile
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
phette23 / g-suite-news.js
Last active Nov 30, 2018
g suite services customizations
View g-suite-news.js
document.querySelector('.about-us-image-wrapper .about-us-image').src = '/media/images/GSuite_service.width-404.jpg'
document.addEventListener('DOMContentLoaded', main)
function main() {
var url = '/services/instructional-services-technology/g-suite-service/g-suite-news-updates/'
fetch(url).then((resp) => resp.text())
.then((text) => {
// parse text of page to HTML we can navigate
var parser = new DOMParser()
View staging-persistent-comparison.js
// check if an item's staging directory contains the same files as its persistent storage does
function log(msg) {
logger.log(currentItem.getUuid() + "/" + currentItem.getVersion() + " LOGGER: " + msg);
// use staging API to check those files
if (staging.isAvailable()) {
var stagingFilesAndDirs = staging.listFiles("", "**");
for(var i = 0; i < stagingFilesAndDirs.size(); i++) {
phette23 / dedupe-syllabi.js
Last active Apr 26, 2018
a utility script for CCA to check for duplicate syllabi in VAULT
View dedupe-syllabi.js
#!/usr/bin/env node
// a utility script for CCA to check for duplicate syllabi in VAULT
let defaults = {
uuid: '9ec74523-e018-4e01-ab4e-be4dd06cdd68',
// 50 is max length
length: 50,
term: 'Spring 2018',
// .equellarc file with credentials for API use
let options = require('rc')('equella', defaults)
phette23 / cover.php
Created Aug 29, 2016
proxy ByWater's Coce cover image cache server (for use on an HTTPS domain)
View cover.php
// this proxies ByWater Solutions' "COCE" cover image service
// which does not work over HTTPS, so fill in our
// server as our COCE server & it intercepts requests, sending along
// data from ByWater's COCE server
// we're sending JS
header( 'Content-Type:application/javascript; charset=utf-8' );
// requests look like
phette23 /
Created Aug 12, 2015
remove leading zeroes Fish script
#!/usr/bin/env fish
# remove leading zeroes from JPG file names
# e.g. page001.jpg => page1.jpg
set start (pwd)
for dir in (ls)
echo "About to rename files in $dir"
# optional, makes me less afraid when I step through one folder at a time
phette23 /
Last active Jul 17, 2017
script to take an Informer report of degree code totals & map them into our human-friendly major terms
#!/usr/bin/env python
# usage:
# "LI - Library students per term.csv" > "YEAR majors total.csv"
import csv
import fileinput
import sys
majors = csv.DictReader(fileinput.input(mode='rb'))
# mapping of degree codes to majors will change over time
# as will the "totals" dict below listing our majors