Skip to content

Instantly share code, notes, and snippets.

@pmgreen
pmgreen / gist:519ce8ed009c58a472bc
Created September 15, 2014 21:13
Get a random sample of n records per Voyager location
/* Relates to Ex Libris' Voyager ILS. Used in Toad for Oracle Freeware and SQL Developer (not MS Access) */
SELECT * FROM (
SELECT b.BIB_ID, m.MFHD_ID, m.LOCATION_ID, ROW_NUMBER()
OVER (
PARTITION BY m.LOCATION_ID ORDER BY m.LOCATION_ID
) SampleCount FROM BIB_TEXT b LEFT JOIN BIB_MFHD bm ON b.BIB_ID = bm.BIB_ID
LEFT JOIN MFHD_MASTER m ON bm.MFHD_ID = m.MFHD_ID
WHERE m.LOCATION_ID IN
(
'1', '6', '7'
@pmgreen
pmgreen / cache_dump.py
Last active September 3, 2015 19:03
Get Hathi URLs
#!/usr/bin/env python
#-*- coding: utf-8 -*-
"""
Just get a csv report from the db that's populated by checky_urls.py
from 20150903
pmg
"""
import csv
import sqlite3 as lite
@pmgreen
pmgreen / openrefine_regexp.md
Last active November 21, 2022 21:49
Quick primer on using regular expressions in OpenRefine.

Using regular expressions in OpenRefine

A regular expression is a string that describes a text pattern occurring in other strings, m'kay.

Basic concepts

With which one can go quite far.

* metacharacters
* character escapes \
* anchors \A\Z or ^$
@pmgreen
pmgreen / strawn_vger_test.md
Created March 18, 2016 15:38
Getting Gary Strawn's programs to work with Voyager Test db at PUL

How to get Gary Strawn's programs to work with Test db

Tested with Record Reloader and VgerSelect on Windows 7 machine, Voyager BatchCat2009-11 (C:\Voyager\System)

  • Edit tnsnames.ora (indentation is important!). Under VGER config put:
TEST =
 (DESCRIPTION = 
   (ADDRESS_LIST =
 (ADDRESS = (PROTOCOL = TCP)(HOST = test.ip.addr)(PORT = 1521))
#!/bin/bash
# update marcedit on Ubuntu
rm ~/Downloads/marcedit.bin.zip # remove any previous downloads
wget -P ~/Downloads/ http://marcedit.reeset.net/software/marcedit.bin.zip
unzip ~/Downloads/marcedit.bin.zip -d /opt/local/ # unzip to /opt/local/
rm ~/Downloads/marcedit.bin.zip
#!/usr/bin/env python
#-*- coding: utf-8 -*-
"""
Query dbpedia. Input is csv which includes authorized names ...
...
96,"Abdelamir, Chowki"
9,"Abraham, Nicolas"
31,"Abraham, Nicolas"
...
Queries local copy of LCNAF, then viaf for viaf uri, then dbpedia for various values (sparql).
@pmgreen
pmgreen / peter_ward_report.py
Created August 13, 2018 17:13
Get simple reports from Peter Ward files, reading LDR/05.
#!/usr/bin/env python
#-*- coding: utf-8 -*-
"""
Get simple reports from Peter Ward files, reading LDR/05.
Peter Ward files come from a paid subscription as of 201808, processed by ke, jeb, pmg.
Run like this: python peter_ward_report.py -f 'unname18.01'
It produces a csv file like this ...
ldr05,status,lccn
c,changed,n 00004614
#!/usr/bin/env python
#-*- coding: utf-8 -*-
"""
Simple test script to get a list of ids from bibs containing given subject headings
pmg
"""
import os
import pymarc
import re
@pmgreen
pmgreen / rednotebook on macOS
Last active September 6, 2019 19:05
Install Rednotebook on macOS Mojave
https://rednotebook.sourceforge.io
Of the three mac installation methods listed on the Rednotebook downloads page, these got the closest:
https://jarrousse.org/installing-rednotebook-from-source-on-mac-os-x/
Here's a summary of modified steps ...
$ git clone https://github.com/jendrikseipp/rednotebook
$ brew install gtk # <= using brew to install gtk worked
$ brew install pygobject3 glib libffi cairo gtksourceview3
$ brew install atk librsvg # <= don't install gdk-pixbuf at this step
$ brew install gsettings-desktop-schemas adwaita-icon-theme
@pmgreen
pmgreen / valva2marc.rb
Last active February 7, 2020 17:41
Rough script for generating MARC records from tabular data for the Valva music collection: https://library.princeton.edu/music/valva
#!/usr/bin/env ruby
# For the Valva project
# Creates marc records from a spreadsheet
# 201911
require 'csv'
require 'marc'
require 'optparse'
require 'facets/string/titlecase'