Skip to content

Instantly share code, notes, and snippets.

View MagnusEnger's full-sized avatar

Magnus Enger MagnusEnger

View GitHub Profile
@MagnusEnger
MagnusEnger / biblioteksok.xslt
Last active June 7, 2016 08:45
XSLT transformation to make Koha's OAI-PMH records comply with the harvesting for Biblioteksøk
<xsl:stylesheet version="1.0"
xmlns:marc="http://www.loc.gov/MARC21/slim"
xmlns:items="http://www.koha-community.org/items"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:package="info:srw/extension/13/package-v1.0">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
#!/usr/bin/perl
use Digest::SHA qw( sha512_hex );
use Test::More;
use Modern::Perl;
use utf8;
my $digest1 = uc sha512_hex( 'The quick brown fox jumps over the lazy dog' );
my $truth1 = '07E547D9586F6A73F73FBAC0435ED76951218FB7D0C8D788A309D785436BBB642E93A252A954F23912547D1E8A3B5ED6E1BFD7097821233FA0538F3DB854FEE6';
is( $digest1, $truth1, 'Fox OK' );
@MagnusEnger
MagnusEnger / doaj2koha.sh
Created November 8, 2011 22:35
Transform CSV data from DOAJ into MARC suitable for ingestion into Koha
#!/bin/bash
# doaj2koha.sh
#
# Get the DOAJ (http://www.doaj.org/) data in CSV format here:
# http://www.doaj.org/doaj?func=csv
# Save the data as doaj.csv
#
# If you are only interested in some of the journals in DOAJ you
# can probably use the grep command to extract only the lines that
@MagnusEnger
MagnusEnger / dvd.pl
Created September 6, 2016 11:30
Simple script to turn CSV records into MARCXML, using Catmandu
#!/usr/bin/perl
# Copyright 2015 Magnus Enger Libriotech
=head1 NAME
dvd.pl - Turn CSV into MARC.
=head1 SYNOPSIS
@MagnusEnger
MagnusEnger / tab2marc.pl
Created April 2, 2014 07:11
Tab separated to MARC via Catmandu
#!/usr/bin/perl
# Copyright 2013 Magnus Enger Libriotech
=head1 NAME
tab2marc.pl - Convert some tab-delimited data to MARCXML.
=head1 SYNOPSIS
@MagnusEnger
MagnusEnger / get_syspref.sh
Created October 30, 2013 08:46
This script is based on the commands made available by a package installation of Koha. It takes the name of a syspref as its argument, then prints the value of that syspref for every Koha instance on the server.
#!/bin/bash
# Check that the user is root
if [ "$(whoami)" != "root" ]; then
echo "Sorry, you are not root."
exit 1
fi
die() {
echo "$@" 1>&2
@MagnusEnger
MagnusEnger / kohastatus.pl
Created August 4, 2011 11:44
Snapshots of the most recent numbers for Koha's bug statuses
#!/usr/bin/perl -w
# Prints out the the most recent numbers for each status from:
# http://bugs.koha-community.org/cgi-bin/progress.pl?type=json
#
# Meant to be run hourly from cron during Global Bug Squashing Days:
# @hourly perl /path/to/kohastatus.pl >> /path/to/hourlynumbers.txt
#
# Based on http://beerpla.net/2008/03/27/parsing-json-in-perl-by-example-southparkstudioscom-south-park-episodes/
@MagnusEnger
MagnusEnger / Get data from Journa TOCs
Created June 10, 2010 11:32
Fetch TOCs with the Journal TOCs API and format as HTML
<?php
// Get an ISSN from the querystrin and build a URL for the Journal TOCs API
// http://www.journaltocs.hw.ac.uk/index.php?action=api
$URL = 'http://www.journaltocs.hw.ac.uk/api/journals/' . $_GET['issn'] . '?output=articles';
$xml = simplexml_load_file($URL);
$xml->registerXPathNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
$xml->registerXPathNamespace("prism", "http://prismstandard.org/namespaces/1.2/basic/");
@MagnusEnger
MagnusEnger / template.pl
Last active May 10, 2023 09:23
Perl script template
#!/usr/bin/perl
# Copyright 2019 Magnus Enger Libriotech
=head1 NAME
my_script.pl - Short description.
=head1 SYNOPSIS