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 / master-to-main.fish
Last active July 1, 2020 22:06
git branches: master -> main
#!/usr/bin/env fish
# loop over repos and create local & remote "main" branches
set dirs (exa -D) # or could do the less elegant `ls -d */`
for dir in $dirs
set_color --bold
echo "Entering $dir"
set_color normal
cd $dir
# test for git repo
@phette23
phette23 / oak-legacy-subject.js
Created May 1, 2020 21:33
add OAK campus legacy MODS subject (openEQUELLA)
// only add if not already there, add as last subject with "local" authority
if (!xml.contains('mods/subject/topic', 'Oakland Campus Legacy')) {
var len = xml.count('mods/subject')
xml.set('mods/subject[' + len + ']/@authority', 'local')
xml.set('mods/subject[' + len + ']/topic', 'Oakland Campus Legacy')
}
@phette23
phette23 / new-mac.md
Last active October 17, 2023 18:09
setting up a new Macbook
  • xcode-select --install to make git work
  • download Google Drive or "Backup & Sync" or whatever they are calling it these days
  • download 1Password https://1password.com/
  • open 1P and sync the password VAULT
  • once XCode has finished, start doing command line things
    • git clone https://github.com/phette23/dotconfig.git
    • git clone https://github.com/phette23/bashrc.git
    • git clone https://github.com/phette23/fishrc.git
    • these all have bash ./copy.sh scripts to install them
  • run the set up scripts from dotconfig:
@phette23
phette23 / all_full_text.js
Last active February 12, 2020 20:35 — forked from mreidsma/all_full_text.js
Simple script to add link to link resolver in Summon results
setTimeout(() => {
libScope(angular.element('html').scope());
}, 1000);
function libScope(scope) {
// Watch results feed for changes...
scope.$watchCollection('feed', () => {
// give AngularJS time to update the DOM
// Probably need to wait a few seconds before running this to make sure the DOM loads
setTimeout(function() {
@phette23
phette23 / report2table.js
Created January 7, 2020 18:05
Koha public report -> HTML table
$.get('https://library.cca.edu/cgi-bin/koha/svc/report?id=130', function(data) {
// header row
let html = '<table><thead><th>Field One</th><th>Field Two</th><th>Field Three</th></thead><tbody>'
// content rows
data.forEach(row => {
html += '<tr>'
row.forEach(value => html += `<td>${value}</td>`)
html += '</tr>'
})
// close tags (optional), add to DOM
@phette23
phette23 / publication.sql
Created October 21, 2019 22:10
get people's publications from CCA portal
SELECT u.first_name, u.last_name, u.email, pub.title, pub.published_in, pub.url, pub.date, pub.description
FROM people_ppublication pub
JOIN people_portalprofile prof ON (pub.object_id = prof.id)
JOIN people_userprofile u ON (prof.user_id = u.id)
@phette23
phette23 / dublincore.xml
Created October 8, 2019 19:53
Complete MODS => OAI DC transformation
<?xml version="1.0"?>
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title>Do Re Mi</dc:title>
</oai_dc:dc>
@phette23
phette23 / hashcode.js
Last active April 14, 2025 18:56
find hash in openEQUELLA file storage path
#!/usr/bin/env node
//jshint node:true
// useful for finding location of files on server, for non-advanced storage config location is
// {{data dir}}/Institutions/{{institution name}}/Attachments/${hashCode(uuid)}/${uuid}/${version}
// for advanced storage config it's
// {{data dir}}/Institutions/{{institution name}}/Attachments/${collection UUID}/${hashCode(uuid)}/${uuid}/${version}
const readline = require('readline')
let hashCode = function(str){
let hash = 0
@phette23
phette23 / newbooks-report.sql
Last active September 18, 2019 18:19
example of displaying 20 most recent bibs from Koha public report
SELECT b.title, b.author, b.biblionumber
FROM biblio b
GROUP BY b.datecreated DESC
LIMIT 20
@phette23
phette23 / vlog.fish
Last active February 28, 2024 16:33
download all EQUELLA logs from a specified day on both app nodes
#!/usr/bin/env fish
# usage: vlog [date string] e.g. `vlog yesterday` or just `vlog` (for today's logs)
# requires SSH aliases for both app nodes (v1 & v2)
set today (gdate "+%Y-%m-%d")
if test -n "$argv[1]"
# need to use gnu date to get the human readable --date parameter
set d (gdate --date="$argv[1]" "+%Y-%m-%d")
# there can be multiple logs per day, rsync does this in only 1 ssh connection (requires rsync 3+)
rsync -ruzvhP v1:/opt/equella/logs/resource-centre/$d/ :/opt/equella/logs/tomcat/$d/ v1-$d
rsync -ruzvhP v2:/opt/equella/logs/resource-centre/$d/ :/opt/equella/logs/tomcat/$d/ v2-$d