Skip to content

Instantly share code, notes, and snippets.

View mjlassila's full-sized avatar

Matti Lassila mjlassila

View GitHub Profile
@mjlassila
mjlassila / primo_matomo_example.js
Created April 18, 2023 10:49 — forked from gpeterso/primo_ga_example.js
Tracking Primo pageviews in Matomo Analytics
const gaTrackingId = '...';
class GoogleAnalytics {
constructor($rootScope, $location, $window) {
this.$rootScope = $rootScope;
this.$location = $location;
this.$window = $window;
this.loadAnalytics(this.$window);
}
@mjlassila
mjlassila / count-available-affiliation-data.xq
Last active February 8, 2023 13:04
Count affiliation data availability in Journal.fi data and create list for all relevant publications.
declare option output:method "csv";
declare option output:csv "header=yes, separator=;";
let $docs_with_affils:=
<records>{
for $record in //oai_marc
where $record/controlfield[@tag eq "001"] contains text {'article.*'} using wildcards
let $parent:=substring-before(substring-after(base-uri($record),"/journalfi-data/"),".xml")
let $affiliation_count:=count($record//datafield[@tag eq '100' or @tag eq '700']/subfield[@code eq 'u'])
let $orcid_count:=count($record//datafield[@tag eq '100' or @tag eq '700']/subfield[@code eq '0' and . contains text {"orcid.*"} using wildcards])
@mjlassila
mjlassila / create-simplestats-csv.xq
Created April 20, 2022 15:28
Convert DSpace Simplestats statistics to analysis-friendly CSV
declare option output:method "csv";
declare option output:csv "header=yes, separator=comma";
declare function local:to-datestamp($raw_date){
let $parts:=tokenize($raw_date," / ")
return $parts[2] || '-' || $parts[1] || '-1'
};
declare function local:not-total($string) {
@mjlassila
mjlassila / README.md
Created May 11, 2021 10:49
Konferenssien vakiintuneet nimet JUFO-tietokannasta

JUFO-konferenssit

Julkaisufoorumi-tietokannasta poistetut konferenssien vakiintuneet nimet. Muunnettu Julkaisufoorumin sivulta ladatusta PDF-tiedostosta käyttäen Tabula-työkalua ja merkistöt siivottu ftfy:llä.

# 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 October 29, 2019 06:39
Listaa niteiden tilat BIBID:n perusteella.
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 October 15, 2019 12:42 — forked from phochste/import_viaf.pl
Match authors against VIAF using Catmandu and Linked Data Fragments
#!/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 October 8, 2019 12:11
Asiakkaalla varaus jo hänellä lainassa olevaan nimekkeeseen
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 October 29, 2019 08:46
Koha-raporttikyselyitä
/*=============================================================
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 10:35
Importing coordinates using Omeka-S CSV import and Mapping
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