Skip to content

Instantly share code, notes, and snippets.

@jweisman
jweisman / add_file.sh
Created May 2, 2019 17:39
Automating fulltext extraction in the Alma Digital Repository
#!/bin/sh
AWS_BUCKET="na-st01.ext.exlibrisgroup.com"
FILENAME=`basename "$1"`
FOLDER=$((1 + RANDOM % 32767))
if [ $# -lt 2 ]; then
echo "Usage: `basename $0` file-name representation-id institution [file-label]"
exit 0
@jweisman
jweisman / ValidateSignature.java
Last active July 14, 2019 18:17
Validate Alma webhook signature in Java
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
public class ValidateSignature {
public static String encode(String key, byte[] data) throws Exception {
@jweisman
jweisman / Dockerfile
Last active March 29, 2020 19:29
Dockerfile to build dependencies for serverless-iiif in AWS Lambda
FROM lambci/lambda:build-nodejs12.x
RUN yum install -y \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
https://rpms.remirepo.net/enterprise/remi-release-7.rpm
RUN yum install -y \
ImageMagick-devel openjpeg-devel jasper-devel glib2-devel \
expat-devel libtiff-devel openslide-devel giflib-devel libpng-devel \
libjpeg-turbo-devel libgsf-devel poppler-glib librsvg2-devel libimagequant \
libgsf-devel libexif-devel wget nodejs python3 && \
@jweisman
jweisman / GetUser.java
Created April 30, 2020 11:57
Alma User API with a Swagger CodeGen Java client SDK
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
@jweisman
jweisman / invoices.py
Last active May 25, 2020 11:42
Alma Invoice Attachments API
import os, sys, requests, base64, re
import xml.etree.ElementTree as ET
NS = {'exl': 'http://com/exlibris/repository/acq/invoice/xmlbeans'}
URL = 'https://api-na.hosted.exlibrisgroup.com'
def process_invoice( invoice ):
id = invoice.find('exl:unique_identifier', NS).text
number_of_attachments = invoice.find('exl:number_of_attachments', NS)
if (number_of_attachments is None or int(number_of_attachments.text) > 0):
@jweisman
jweisman / proxy.component.html
Last active September 4, 2020 12:26
Ex Libris Cloud App Angular Component for use with an API Proxy
<h1>Using a Proxy to Access Data from Other Institutions</h1>
<div class="loading-shade" *ngIf="loading"><mat-spinner diameter="50"></mat-spinner></div>
<mat-form-field appearance="fill">
<mat-label>Intitution</mat-label>
<mat-select #instcode>
<mat-option *ngFor="let inst of instcodes" [value]="inst">{{inst}}</mat-option>
</mat-select>
</mat-form-field>
<button mat-flat-button color="primary" (click)="test(instcode.value)">Test connection</button>
@jweisman
jweisman / bibcard.html.erb
Last active October 9, 2020 18:03
Linked Data example - Alma JSONLD and BibCard
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title><%= viewmodel[:title] %></title>
</head>
@jweisman
jweisman / LambdaPublicIP.yaml
Last active November 9, 2020 11:22
CloudFormation template to create resources necessary to run a Lambda function with a static public IP
####
# Based on https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html
# and https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/templates/vpc-privatepublic.yaml
####
pubPrivateVPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 172.31.0.0/16
Tags:
@jweisman
jweisman / files.csv
Last active November 13, 2020 13:07
Upload digital files programmatically using Alma APIs
99509041500561 logo.png
99509041400561 logo.png
99509041300561 logo.png
99509041200561 logo.png
99508941400561 logo.png
99509041100561 logo.png
99508841400561 logo.png
@jweisman
jweisman / settings.component.html
Last active November 16, 2020 09:58
Saving an image in Cloud App Settings
<div class="eca-actions">
<button mat-flat-button color="secondary" [routerLink]="['/']">Back</button>
<button mat-flat-button color="primary" (click)="save()">Save settings</button>
</div>
<div class="loading-shade" *ngIf="loading">
<mat-progress-spinner mode="indeterminate" diameter="50"></mat-progress-spinner>
</div>
<h1>Settings</h1>
<h2>Logo</h2>
<div><img src="{{logoUrl}}" style="max-width: 100%;"/></div>