Skip to content

Instantly share code, notes, and snippets.

@rwd
rwd / .env.example
Last active October 24, 2022 09:18
IBM Cloud Compose for Redis to Databases for Redis migration
# Source Redis database
SRC_HOST=
SRC_PASSWORD=
SRC_PORT=
# Destination Redis database
DST_HOST=
DST_PASSWORD=
DST_PORT=
@rwd
rwd / nuxt-auth-v4-access-token-refresh-plugin.js
Created November 11, 2020 16:41
Nuxt Auth v4 access token refresh plugin
/* eslint-disable camelcase */
export default ({ $auth, redirect }) => {
const redirectUrl = $auth.options.redirect.login;
const axiosInstance = $auth.ctx.app.$axios;
const refreshAccessToken = async(requestConfig) => {
const refreshToken = $auth.getRefreshToken($auth.strategy.name);
const options = $auth.strategy.options;
// Nuxt Auth stores token type e.g. "Bearer " with token, but refresh_token
@rwd
rwd / jenkins-blue-green-cf-push.sh
Last active June 9, 2021 06:54
CF app blue/green deployment from Jenkins
# Given an app with mirrors web-blue and web-green in the CF test space with hostname www.example.org...
# Find which mirror is already active, which to switch to
export OLD_MIRROR=$(cf routes | sed -nr 's/^(test\s+)?www\s+example\.org\s+web-(blue|green).*$/\2/p')
if [ "$OLD_MIRROR" = "blue" ]; then
export NEW_MIRROR="green"
elif [ "$OLD_MIRROR" = "green" ]; then
export NEW_MIRROR="blue"
else
export OLD_MIRROR="green"
@rwd
rwd / jenkins-cf-login-example.sh
Created October 11, 2017 11:49
Jenkins CF login example using env vars
set +x && cf login -a ${BLUEMIX_CF_API} -u ${CF_USER} -p ${CF_PASS} -o ${BLUEMIX_CF_ORG} -s test && set -x
@rwd
rwd / jenkins-cf-home-example.sh
Created October 11, 2017 11:40
Jenkins shell script CF_HOME example
mkdir -p ${HOME}/.cf/${JOB_NAME} && export CF_HOME=${HOME}/.cf/${JOB_NAME}
@rwd
rwd / europeana-iiif-record-request.sh
Created November 15, 2016 15:27
cURL request for a Europeana item with IIIF service
curl https://www.europeana.eu/api/v2/record/9200211/en_list_one_vad_0342.json?wskey=YOUR_API_KEY
@rwd
rwd / europeana-leaflet-iiif-example.html
Last active November 16, 2016 10:45
Europeana Leaflet-IIIF example
<!doctype html>
<!--
A minimal example showing how to display a IIIF manifest for a Europeana record
in the Leaflet-IIIF viewer.
Before running this, you need to change "YOUR_API_KEY" to your actual Europeana
API key. Get one at <http://labs.europeana.eu/api/registration>.
This example builds on Jack Reed's Leaflet-IIIF plugin example at
<http://mejackreed.github.io/Leaflet-IIIF/examples/iiif-manifest-example.js>
@rwd
rwd / 9200211-en_list_one_vad_0342.json
Created October 20, 2016 12:50
IIIF in EDM: "St. Gallen, Kantonsbibliothek, Vadianische Sammlung, VadSlg Ms. 342 : Vaticinia de pontificibus (Prophecies about the Papacy)"
{
"object": {
"services": [
{
"about": "http://www.e-codices.unifr.ch/loris/vad/vad-0342/vad-0342_008.jp2",
"id": {
"inc": -312135832,
"timeSecond": 1473424540,
"machine": -458205733,
"timestamp": 1473424540,
@rwd
rwd / benchmark-fog-connection.rb
Created April 4, 2016 08:02
Benchmark Fog connection requests
require 'fog/core/connection'
# Place this in a Rails initializer
module Fog
module Core
class Connection
include ActiveSupport::Benchmarkable
alias_method :super_request, :request
def request(params, &block)
@rwd
rwd / merge-multiple-rdf-descriptions.rb
Created August 13, 2014 10:20
Merge multiple rdf:Description elements with the same rdf:about attribute
#!/usr/bin/env ruby
#
# @file
# This script takes an RDF file containing multiple rdf:Description elements
# with the same rdf:about attribute, combines them into a single
# rdf:Description for each rdf:about, and outputs the resultant RDF.
#
require 'nokogiri'