Skip to content

Instantly share code, notes, and snippets.

Josh Weisman jweisman

Block or report user

Report or block jweisman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jweisman / webhook-listener.js
Created Jul 14, 2019
Node.js listener for Alma webhooks
View webhook-listener.js
const express = require('express')
const bodyParser = require('body-parser');
const crypto = require('crypto');
const app = express()
const port = 8000
const webhook_secret = process.env.WEBHOOK_SECRET || '1234'
app.use(bodyParser.urlencoded({ extended: false }));
jweisman /
Last active Jul 14, 2019
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 /
Created May 2, 2019
Automating fulltext extraction in the Alma Digital Repository
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 /
Created May 2, 2019
Automating Alma API-based integration with ERP
IFS=$'\n' # break on newline only
echo "Getting invoices ready for payment"
invoices=`curl -s --fail -H "Authorization: apikey $ALMA_APIKEY" -H "Accept: application/json" "" | jq -c '.invoice | .[]'`;
for id in $invoices; do
echo "Marking invoice $(echo $id | jq -r '.number') as sent to ERP"
curl -s -o /dev/null -X POST -H "Authorization: apikey $ALMA_APIKEY" -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{}' "$(echo $id | jq -r '.id')?op=mark_in_erp"
jweisman /
Last active Apr 30, 2019
Swagger Codegen with Alma APIs
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 / parallel.js
Last active Jan 16, 2019
Ex Libris Alma - Parallel API Calls
View parallel.js
const { PerformanceObserver, performance } = require('perf_hooks');
const alma = require('almarestapi-lib');
const records = 10000;
const limit = 25;
const url = '/users?view=brief';
const arrayName = 'user';
var offset = 0, total = 0, processed = 0;
jweisman / Program.cs
Last active May 1, 2018
Refit for Alma APIs
View Program.cs
using Newtonsoft.Json;
using Refit;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace refitalma
[Headers("Accept: application/json")]
public interface IAlmaApi
jweisman / bibcard.html.erb
Last active May 10, 2019
Linked Data example - Alma JSONLD and BibCard
View bibcard.html.erb
<!doctype html>
<html lang="en">
<!-- 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="" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title><%= viewmodel[:title] %></title>
jweisman /
Last active Oct 18, 2017
Process Orchestration in Alma with the Job and Set APIs
echo "Creating new set"
SET_ID=`curl -s --fail -X POST -H "Authorization: apikey $API_KEY" -H "Content-type: application/xml" -H "Accept: application/xml" --data @set.xml "" | xmllint --xpath '/set/id/text()' -`
if test $res != 0; then
echo "HTTP request failed with return code $res"
exit $res
jweisman / workflow.json
Last active Apr 17, 2018
Azure Logic App for Alma Webhooks
View workflow.json
"$connections": {
"value": {
"sftp": {
"connectionId": "/subscriptions/78e1da39-3d31-4b09-8636-f49b6fc5223b/resourceGroups/DefaultResourceGroup/providers/Microsoft.Web/connections/sftp-1",
"connectionName": "sftp-1",
"id": "/subscriptions/78e1da39-3d31-4b09-8636-f49b6fc5223b/providers/Microsoft.Web/locations/eastus/managedApis/sftp"
You can’t perform that action at this time.