Skip to content

Instantly share code, notes, and snippets.

View phette23's full-sized avatar
🌹
"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
phette23 / broken link format.js
Last active December 12, 2018 21:15
format a support ticket for reporting a broken link in Summon (paste into dev tools)
@phette23
phette23 / equella bulk download.js
Created December 6, 2018 00:31
bulk download attachments from a list of item UUIDs (openEQUELLA)
#!/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 November 30, 2018 18:39
g suite services customizations
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()
// 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 April 26, 2018 18:44
a utility script for CCA to check for duplicate syllabi in VAULT
#!/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 August 29, 2016 18:00
proxy ByWater's Coce cover image cache server (for use on an HTTPS domain)
<?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 August 12, 2015 00:11
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
read
@phette23
phette23 / sum-majors.py
Last active July 17, 2017 20:41
script to take an Informer report of degree code totals & map them into our human-friendly major terms
#!/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
@phette23
phette23 / randpw.js
Created April 3, 2015 22:05
Simple Node Random Password Script
#!/usr/bin/env node
// usage:
// > randpw
// IKS1L2H1AMOx
// > randpw --length 22
// IKS1L2H1AMOxBs4d8qxDXY
// > randpw | pbcopy # pipe to Mac clipboard
var chance = new require('chance')()
var args = require('minimist')(process.argv.slice(2))
var pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
@phette23
phette23 / wp-edits.js
Created March 11, 2015 23:11
Count Wikipedia Edits by List of Users
// see also: https://gist.github.com/phette23/5575987
// used to count edits at California College of the Arts
// during Art+Feminism edit-a-thon on March 7, 2015
var uns = [
"Phette23",
"Circa73",
"Flyingpanther",
"Tericlaude",
"Berylbev",
"Cd heaven",