Skip to content

Instantly share code, notes, and snippets.

View MagnusEnger's full-sized avatar

Magnus Enger MagnusEnger

View GitHub Profile
@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
@MagnusEnger
MagnusEnger / marctt.pl
Created September 4, 2012 10:32
POC for using Template Toolkit to display MARC data
#!/usr/bin/perl
use MARC::Batch;
use Template;
use Modern::Perl;
my $batch = MARC::Batch->new('USMARC', 'test.mrc');
my $record = $batch->next();
# Set up Template Toolkit
@MagnusEnger
MagnusEnger / koha-cover.sh
Created February 28, 2012 11:01
Generate and publish test coverage reports for Koha with Devel::Cover and App::ArchiveDevelCover
#!/bin/bash
cd /home/user/kohaclone
git checkout master
git pull
export PERL5LIB=/home/user/kohaclone; export KOHA_CONF=/home/user/koha-dev/etc/koha-conf.xml
export HARNESS_PERL_SWITCHES=-MDevel::Cover
prove -l
cover
archive_devel_cover.pl --from cover_db/ --to /var/www/coverage_reports/koha/
@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>
@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 / phosort.sh
Created October 23, 2011 19:15
Sort pictures into year/month/date folders based on the filename yyyymmdd_x.jpg
#!/bin/bash
# Read a directory of image files with names on this form:
# 20110113_001.jpg
# 20110113_002.jpg
# 20110113_003.jpg
#
# Create folders as needed and move the images into them, in this way
# 2011
# |__01
@MagnusEnger
MagnusEnger / linesort.pl
Created October 21, 2011 11:01
Read through a file and pick out lines that contain one of a number of "trigger" strings. Print the lines grouped by the string they matched, then print the remaining lines.
#!/usr/bin/perl -w
# Read through a file and pick out lines that contain one of a number of
# "trigger" strings. Print the lines grouped by the string they matched, then
# print the remaining lines.
#
# Usage: linesort.pl myfile.txt
use File::Slurp;
use Array::Each qw( rewind );
@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/");