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 / 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",
@phette23
phette23 / unt-json-to-equella-taxonomy.js
Created January 27, 2015 18:46
UNT JSON to EQUELLA Taxonomy
// take http://digital2.library.unt.edu/vocabularies/agent-qualifiers/json/
// and insert into an EQUELLA taxonomy, preserving URL & definition info
// EQUELLA taxo format is CSV-like:
// term1/term/term2,key,value,key2,value2…
// can then upload with their included Python scripts or write your own
var fs = require('fs')
var data = JSON.parse(fs.readFileSync('agent-qualifiers.json'))
var terms = data.terms
var getDescription = function(term) {
@phette23
phette23 / a-unix-use-case.mdown
Last active August 29, 2015 14:10
A *NIX Use Case

Almost immediately after declaring a hiatus seems like a great time for a blog post.

Inspired by nina de jesus and Ruth Tillman's libtech level up project, here's something on the value of command-line text processing. Some of these common UNIX tools that have been around since practically the 1980s are great for the sort of data wrangling that many librarians find themselves doing, whether their responsibilities lie with systems, the web, metadata, or other areas. But the command prompt has a learning curve and if you already use text editor tools to accomplish some tasks, it might be tough to see why you should invest in learning. Here's one case I've found.

Scenario: our digital repository needs to maintain several vocabularies of faculty who teach in different departments. That information is, of course, within a siloed vendor product that has no viable APIs. I'm only able to export CSVs that looks like this:

"Namerer, Name","username"

"Othern

@phette23
phette23 / wrapper.ftl
Created August 27, 2014 18:50
EQUELLA - Expose User Role to JavaScript
<#-- NOTE this style should be removed for home page portlet
also should really use an ID rather than hide all portlet headings -->
<style>
/* hide header */
.portlet_freemarker_content .box_title_wrapper h3 {
display: none !important;
}
</style>
<#-- these role IDs will need to be researched & changed -->
<#if user.hasRole('490b1b93-10cd-b8fa-3291-93c357efe57b')>
@phette23
phette23 / tif2jpg.fish
Created August 20, 2014 16:38
Convert all tif files in a directory to jpg
for f in *.tif
convert $f (basename -s .tif $f).jpg
end