Instantly share code, notes, and snippets.

😒
not everything needs a status

Eric Phetteplace phette23

View GitHub Profile
@phette23
phette23 / uptaxo.py
Created Feb 7, 2019
upload a taxonomy to openEQUELLA using a specially-formatted CSV
View uptaxo.py
#!/usr/bin/env python2
# ################################# #
# UploadTaxonomy.py #
# #
# added CLI by Eric Phetteplace #
# California College of the Arts #
# vault.cca.edu | libraries.cca.edu #
# 2014-07-32 #
# #
# Pearson's notes below #
@phette23
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 be.id = 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 i.id = a.item_id
WHERE i.institution_id = 1165188
@phette23
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
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
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++) {
log(stagingFilesAndDirs.get(i));
@phette23
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
phette23 / cover.php
Created Aug 29, 2016
proxy ByWater's Coce cover image cache server (for use on an HTTPS domain)
View cover.php
<?php
// this proxies ByWater Solutions' "COCE" cover image service
// which does not work over HTTPS, so fill in our libraries.cca.edu
// 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
phette23 / remove-leading-zeroes.fish
Created Aug 12, 2015
remove leading zeroes Fish script
View remove-leading-zeroes.fish
#!/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
read
@phette23
phette23 / sum-majors.py
Last active Jul 17, 2017
script to take an Informer report of degree code totals & map them into our human-friendly major terms
View sum-majors.py
#!/usr/bin/env python
# usage:
# sum-majors.py "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