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 / 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()
})
(function ( $ ) {
// run after document is loaded so ga.js is available
$( document ).ready( setTracking );
function setTracking () {
// class is specific to databases subject list
$( '.view-clone-of-databases-subject-list a' ).click( databaseTracking );
}
function databaseTracking ( event ) {
@phette23
phette23 / doaj.php
Last active February 9, 2023 17:32
Web Scraping Examples in a Few Languages
<?php
// need to download simple_html_dom.php from SourceForge
// http://sourceforge.net/projects/simplehtmldom/files/
// and place it in the same directory as this script
require_once( 'simple_html_dom.php' );
// http://simplehtmldom.sourceforge.net/manual_api.htm
$base = 'http://www.doaj.org/doaj?func=search&template=&uiLanguage=en&query=';
$query = urlencode( 'librarianship' );
@phette23
phette23 / lfm-recent-tracks.html
Created February 19, 2012 22:32
Last.fm Recent Tracks API
<h3>Last.fm Scrobbles</h3>
<!-- div below will be filled in with formatted contents of API response -->
<div id="recent-tracks" style="display:none;"><a href="http://last.fm/">Last.fm</a> data hasn't loaded yet.</div>
<!-- leave as display:none for the fade in effect -->
@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 / csv2patron-marc.py
Last active August 7, 2022 01:18
Converting CSV into Patron Records for III Millennium
#!/usr/bin/env python
# note final, more robust version at https://github.com/cca/millennium_patron_import
import sys
import csv # https://docs.python.org/2/library/csv.html
# PCODE mappings, etc.
from mapping import *
import datetime
import re
@phette23
phette23 / hide-pdf-urls.js
Last active February 19, 2022 16:18
hide 856$u PDFs in Koha if users aren't logged in
// run 1) on opac-detail pages & 2) if no user is signed in
if (!!location.pathname.match('/cgi-bin/koha/opac-detail.pl') && !$('.loggedinusername').length) {
// replace 856$u links with a link to login instead
// this would need to be tweaked if there are multiple URLs per record
$('.results_summary.online_resources a')
.replaceWith('<a href="/cgi-bin/koha/opac-user.pl">login to view PDF</a>')
}