Skip to content

Instantly share code, notes, and snippets.

@jeff
jeff / README
Created June 18, 2015 20:07
Example of cleaning up / normalizing opac.default_phone values
Normalizes values such as:
" 9999999999"
"(999) 999-9999"
"(999) 9999999"
"(999)999-9999"
"9-(999)-999-9999"
"9-999-999-9999"
"999 999 9999"
"999 999-9999"
%%%
%%% Debian ejabberd configuration file
%%% This config must be in UTF-8 encoding
%%%
%%% The parameters used in this configuration file are explained in more detail
%%% in the ejabberd Installation and Operation Guide.
%%% Please consult the Guide in case of doubts, it is available at
%%% /usr/share/doc/ejabberd/guide.html
%%% This configuration file contains Erlang terms.
@jeff
jeff / generate.py
Created May 20, 2013 16:34
found via archive.org Wayback Machine, the generate.py Python script used to create marcdoc.xml by crawling the Library of Congress MARC documentation
#!/usr/bin/env python
"""
This is a scraper for the LoC website that will parse the human
readable HTML documentation for MARC tags, and generate machine
readable (XML) documentation.
You'll need to have python, elementtree [1] and elementtidy [2] installed
before running this script.
@jeff
jeff / reingest_apos.sql
Last active July 14, 2019 06:58
some examples of queries to queue then re-ingest records in an Evergreen 2.2 system which contain records which were indexed under an older normalization style.
-- queue bre records for a batch re-ingest
-- select bres with a title containing the string "'s "
-- which do not have a keyword index_vector
-- matching 's'
INSERT INTO tadl_batch.bre (bre,batch_name)
WITH apos_recs AS (select distinct mkfe.source id, mkfe.value title
from metabib.keyword_field_entry mkfe
join asset.call_number acn on (acn.record = mkfe.source and not acn.deleted)
join asset.copy acp on (acp.call_number = acn.id and not acp.deleted)
where mkfe.field = 122
@jeff
jeff / circs_by_week.sql
Last active July 14, 2019 06:58
Looking at grouping circ counts by "week" with some consideration given to avoiding partial weeks at the start of the data summarized.
-- This will show counts grouped by weeks, but will
-- likely include a partial week at the start
-- (check the "days_in_sample" column)
SELECT date_trunc('week',xact_start)::date week,
circ_lib,
count(distinct xact_start::date) days_in_sample,
count(*) circ_count
FROM action.circulation
WHERE xact_start > '2012-12-01'
GROUP BY 1,2
@jeff
jeff / iptables-save
Created January 4, 2013 18:46
Simple example of a "deny all incoming tcp/22 connection attempts except that from existing connections or from a list of source IPs in the "techs" chain. This is in format suitable for use with iptables-restore, which will overwrite your existing iptables rules. To create the techs chain from the command line, use "iptables -N techs"
# Generated by iptables-save v1.4.2 on Fri Jan 4 13:40:19 2013
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:techs - [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -m state --state RELATED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j techs
-A INPUT -p tcp -m tcp --dport 22 -j LOG
-- any way to write this so that i have 'c: donation' in only one place?
BEGIN;
UPDATE value.items
SET is_donated = true
WHERE id IN (SELECT copy FROM value.copynotes WHERE content = ': donation');
DELETE FROM value.copynotes
WHERE content = 'c: donation';
COMMIT;
@jeff
jeff / gist:978925
Created May 18, 2011 16:24
sql for Evette
-- revised to use a sub-select and to report only those records with BOTH a
-- matching 856$3 and 856$9 -- this sub-select may not be the most efficient way
-- to do this. also eliminated tag/subfield/value from the output
SELECT au.usrname, bre.tcn_value, bre.id, bre.create_date,
bre.edit_date
FROM metabib.real_full_rec as mrfr
LEFT JOIN biblio.record_entry as bre on bre.id = mrfr.record
LEFT JOIN actor.usr as au on au.id = bre.editor
WHERE bre.deleted = 'f'
AND mrfr.tag = '856'
#!/usr/bin/perl
use strict; use warnings;
while (<>) {
chomp;
my $bc = $_;
$bc =~ s/"//g;
next if (length($bc) != 14);
next if ($bc !~ m/^1\d+$/);
Enabling OpenILS::WWW::AddedContent to return cover images based on more than just ISBN
Supporting legacy without making the New Awesome have to bend over backward
* make AddedContent superclass look for a use-time argument to enable "legacy" lookup-by-isbn support
* change apache handler to use legacy option
* create new apache handler at new url to use new default of lookup-by-record-id
for records: AC_HOST/opac/extras/ac/jacket/small/r/RECORD_ID
for metarecords: AC_HOST/opac/extras/ac/jacket/small/m/METARECORD_ID