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 / backup-db-table.sh
Last active December 14, 2023 21:54
retroactively add db entries to group
# backup the mdl_data_records table before we modify it
gcloud sql export sql mysql-prod-1 gs://cca-manual-db-dumps/(dt)-mdl_data_records.sql -d m_prod1 -t mdl_data_records
@phette23
phette23 / download.fish
Created October 27, 2023 23:01
download all VAULT items
#!/usr/bin/env fish
# download ALL live vault items to item.json and metadata.xml files
# 47283 total items, we can download 50 at a time
set total (eq search -l 1 | jq '.available')
set length 50
set pages (math floor $total / $length)
for i in (seq 0 $pages)
set start (math $i \* $length)
echo "Downloading items $start to" (math $start + $length)
eq search -l $length --info metadata --start $start > .tmp/$i.json
@phette23
phette23 / syllabi-section-check.js
Created October 20, 2023 15:54
check if sections syllabi are on VAULT search results page
// check if these sections appear on EQUELLA search results page
const sections = [
'GELCT-6700-2',
'LITPA-2000-10',
'WRITE-6000-2',
]
console.log(`Checking for ${sections.length} section codes`)
// return list of missing sections
const missing = sections.filter(s => {
@phette23
phette23 / warc-download.sh
Created October 20, 2023 15:40
download Archive-It WARCs to backup
#!/usr/bin/env fish
# used for Art Practical site
# fill in credentials
set USER username
set PASS password
set COLLECTION 15633
# destination files
set JSONFILE data.json
@phette23
phette23 / crcheckall.js
Created March 1, 2023 18:56
select all checkboxs on chrome's history page chrome://history
document
.querySelector('history-app').shadowRoot
.querySelector('history-list').shadowRoot
.querySelectorAll('history-item').forEach((hi, i) => {
const cbox = hi.shadowRoot.querySelector('cr-checkbox')
// merely setting checked = true doesn't work, chrome wants you to click them
if (!cbox.checked) cbox.click()
})
@phette23
phette23 / homebrew bump.md
Created December 1, 2022 17:34
bumping a homebrew formula version in brief

The How to Open a Homebrew Pull Request documentation is great. This doc assumes you've already created a fork of homebrew-core named after your user and a branch tracking the master of the fork.

cd (brew --repository homebrew/core)
brew update
git checkout phette23 # tracks master branch of fork
git pull # might need to sync fork to homebrew?
set FORMULA marcli # name of the project you're bumping
set VERSION 1.1.0 # semantic version
brew bump-formula-pr --no-fork --url https://github.com/account/$FORMULA/archive/refs/tags/v$VERSION.tar.gz project
@phette23
phette23 / html-email.py
Created November 22, 2022 00:29
demo of sending HTML email in syllabus reminders project
from email.message import EmailMessage
import smtplib
from reminders.config import config
from_address = 'ephetteplace@cca.edu'
to_address = 'ephetteplace@cca.edu'
msg = EmailMessage()
@phette23
phette23 / git-license.fish
Created October 26, 2022 23:43
add ECL-2.0 license to current repo
#!/usr/bin/env fish
if ! git status 2&>/dev/null
echo "Must be run inside a git repo, run 'git init' first if need be" >&2
exit 1
end
begin
if ! test -f LICENSE.txt
echo "Downloading license text"
wget https://raw.githubusercontent.com/cca/koha_snippets/main/LICENSE.txt
@phette23
phette23 / convert.py
Created September 16, 2022 18:22
Convert KBART to Serials Solution 360 Core database template
'''
Translate KBART file from OAPEN into Serials Solutions Client Center aka 360
Core database format. See the DatabaseTemplate.txt file for details.
'''
import csv
def get_first_isbn(isbns):
""" return the first in a list of semicolon-separated ISBNs
@phette23
phette23 / nso-groups.sh
Created August 27, 2021 22:03
create a CSV to populate NSO groups in Moodle > Upload Users
#!/usr/bin/env bash
# accepts three files that are just the copy-pasted email column from a Google Sheet
# some of the rows can be empty, also note that the course shortnames change year to year
FRESH=$1
GRAD=$2
TRSFR=$3
# delete empty lines, remove "cca.edu" from emails
sed -e '/^$/d' -e 's|@cca\.edu||' -i '.bak' $FRESH
sed -e '/^$/d' -e 's|@cca\.edu||' -i '.bak' $GRAD