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
View hellspawn.js
// stupid Node.js tricks
// accepts JS object literal of commands & their args
// executes each in series, pipes child process output to parent
// e.g. `node hellspawn.js '{"ls": "-al", "pwd": null, "echo": "Hello world!"}'`
var spawn = require('child_process').spawn
, cmds = JSON.parse(process.argv[2])
, cmd
, key
, val;
phette23 / clip.js
Created Jun 18, 2014
Pipe to Clipboard in Node.js (Mac OS X only)
View clip.js
var clipboard = require('child_process').spawn('pbcopy')
, data = 'put whatever data here';
phette23 /
Last active Aug 29, 2015
Converting CSV into Patron Records for III Millennium
#!/usr/bin/env python
# note final, more robust version at
import sys
import csv #
# PCODE mappings, etc.
from mapping import *
import datetime
import re
phette23 /
Created Aug 20, 2014
Convert all tif files in a directory to jpg
for f in *.tif
convert $f (basename -s .tif $f).jpg
phette23 / wrapper.ftl
Created Aug 27, 2014
EQUELLA - Expose User Role to JavaScript
View wrapper.ftl
<#-- NOTE this style should be removed for home page portlet
also should really use an ID rather than hide all portlet headings -->
/* hide header */
.portlet_freemarker_content .box_title_wrapper h3 {
display: none !important;
<#-- these role IDs will need to be researched & changed -->
<#if user.hasRole('490b1b93-10cd-b8fa-3291-93c357efe57b')>
View a-unix-use-case.mdown

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"


View unt-json-to-equella-taxonomy.js
// take
// 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 / wp-edits.js
Created Mar 11, 2015
Count Wikipedia Edits by List of Users
View wp-edits.js
// see also:
// used to count edits at California College of the Arts
// during Art+Feminism edit-a-thon on March 7, 2015
var uns = [
"Cd heaven",
phette23 / randpw.js
Created Apr 3, 2015
Simple Node Random Password Script
View randpw.js
#!/usr/bin/env node
// usage:
// > randpw
// > 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 /
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