Skip to content

Instantly share code, notes, and snippets.

Avatar

Matti Lassila mjlassila

View GitHub Profile
View gist:73bec8543347efd0b977e50c33094b56
# vim:set ft=perl:ts=4:sw=4
#
# Ref.: http://librecat.org/Catmandu/
# https://github.com/LibreCat/Catmandu/wiki/Example%20Fix%20Script
# https://github.com/scriptotek/simplemarcparser/blob/master/src/BibliographicRecord.php
# For ElasticSearch 2.0
# See https://github.com/LibreCat/Catmandu-Store-Elasticsearch/commit/63795416d2585eab7af1d5263f5823b4cae94251
# <s>Note that we use _identifier over _id to cover deleted records which do not have _id</s>
# UPDATE: When importing from a MARC dump, we don't have OAI IDs, so use the simple _ids instead.
@mjlassila
mjlassila / item-status-query.sql
Created Oct 29, 2019
Listaa niteiden tilat BIBID:n perusteella.
View item-status-query.sql
SELECT
biblio.title as 'Nimeke',
CONCAT('<a href=\"/cgi-bin/koha/catalogue/moredetail.pl?',
'biblionumber=', biblio.biblionumber, '&itemnumber=', items.itemnumber,
'\">', items.barcode, '</a>' ) AS 'Viivakoodi',
items.datelastborrowed as 'Lainattu viimeksi',
items.datelastseen as 'Käsitelty viimeksi',
CONCAT(
'<a target="_blank" href=\"/cgi-bin/koha/members/moremember.pl?borrowernumber=',
borrower.borrowernumber,
@mjlassila
mjlassila / import_viaf.pl
Created Oct 15, 2019 — forked from phochste/import_viaf.pl
Match authors against VIAF using Catmandu and Linked Data Fragments
View import_viaf.pl
#!/usr/bin/env perl
#
# Match authors against VIAF
#
# License: http://dev.perl.org/licenses/artistic.html
#
# Author: Patrick Hochstenbach <Patrick.Hochstenbach@UGent.be>
#
# Apr 2015
$|++;
@mjlassila
mjlassila / reserve-on-already-issued.sql
Created Oct 8, 2019
Asiakkaalla varaus jo hänellä lainassa olevaan nimekkeeseen
View reserve-on-already-issued.sql
SELECT
RTRIM(REGEXP_REPLACE(biblio.title,'[/,:]$','')) as 'Nimeke',
DATE(issues.issuedate) AS 'Lainattu',
reserves.reservedate AS 'Varattu',
CONCAT(
'<a target="_blank" href=\"/cgi-bin/koha/members/moremember.pl?borrowernumber=',
borrowers.borrowernumber,
'\">',
borrowers.cardnumber,
'</a>'
@mjlassila
mjlassila / jyu-koha-queries.sql
Last active Oct 29, 2019
Koha-raporttikyselyitä
View jyu-koha-queries.sql
/*=============================================================
Koha-raporttikyselyitä
Matti Lassila, Avoimen tiedon keskus, Jyväskylän yliopisto.
Huomaa kyselyitä käyttäessäsi, että esimerkiksi URL-
osoitteet sisältävät parametreina JYU:n Kohan raporttien ID:t
joten kyselyitä ei voi useimmissa tapauksissa käyttää suoraan
ilman muokkausta.
==============================================================*/
@mjlassila
mjlassila / coordinate-import-sample.csv
Created May 21, 2019
Importing coordinates using Omeka-S CSV import and Mapping
View coordinate-import-sample.csv
identifier title lat lon
hdl_123456789_20498 Test 1 63.823611063 23.1313059559
hdl_123456789_20498 Test 2 63.765232199 23.2055593531
hdl_123456789_20498 Test 3 63.8274471817 23.1292173509
@mjlassila
mjlassila / export-log-snippet.log
Created Sep 13, 2018
Voyager bound records export
View export-log-snippet.log
This file has been truncated, but you can view the full file.
1107 bound MFHDs found!
Merging records '453393 453394' under a new parent '1'
ERROR: No delimeter found within record:
''!
Use of uninitialized value $nimeke in concatenation (.) or string at Exp/Strategy/BoundRecords.pm line 89.
Use of uninitialized value $boundChildId in concatenation (.) or string at Exp/Strategy/BoundRecords.pm line 89.
453394: Samlingar utgifna af Svenska fornskrift-sällskapet. 2, efter gamla handskrifter af George Stephens och J. A. Ahlstrand. KPStockholm : 1844.
ERROR: No delimeter found within record:
''!
@mjlassila
mjlassila / json-attach-external.json
Created May 3, 2018
Example JSON payload for attaching external HTML files to existing OmekaS items
View json-attach-external.json
{
"o:renderer": "html",
"o:is_public": true,
"@type": "cnt:ContentAsText",
"cnt:characterEncoding": "UTF-8",
"o:ingester": "url",
"o:item": {
"@id": "http://omekas:8888/api/items/5500",
"o:id": 5500
},
@mjlassila
mjlassila / omeka-add-html-media.json
Created May 3, 2018
Example JSON payload for attaching HTML media to existing items in Omeka-S
View omeka-add-html-media.json
{
"o:renderer": "html",
"o:is_public": true,
"@type": "cnt:ContentAsText",
"cnt:characterEncoding": "UTF-8",
"o:ingester": "html",
"o:item": {
"@id": "http://omekas:8888/api/items/5500",
"o:id": 5500
},
@mjlassila
mjlassila / export-refworks.phtml
Last active Jan 18, 2018
Modified Finna/Vufind Refworks export
View export-refworks.phtml
<?
function removeAccents( $s)
{
$original_string = $s;
$s = preg_replace( '@\x{00c4}@u' , "%", $s ); // umlaut Ä => AE
$s = preg_replace( '@\x{00d6}@u' , "#", $s ); // umlaut Ö => OE
$s = preg_replace( '@\x{00dc}@u' , "UE", $s ); // umlaut Ü => UE
$s = preg_replace( '@\x{00e4}@u' , "<>", $s ); // umlaut ä => ae
$s = preg_replace( '@\x{00f6}@u' , "><", $s ); // umlaut ö => oe