Skip to content

Instantly share code, notes, and snippets.

View jmartin-sul's full-sized avatar

Johnathan Martin jmartin-sul

  • Stanford University Libraries
View GitHub Profile
@jmartin-sul
jmartin-sul / more_playing_with_promises.js
Created July 9, 2019 22:53
more test code to illustrate Promise, await, and async
timeout = 5000
promiseKeeper = (id) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(`${id} resolved at ${new Date()}`)
}, timeout);
})
}
// you'll want to run the below manually by separately pasting each chunk into e.g. a node console
// declare some globals that we can use to get insight into the workings of slowFunction
preAwaitDate = null
postAwaitDate = null
awaitResult = null
slowFunction = async () => {
preAwaitDate = new Date()
awaitResult = await new Promise(function(resolve, reject) {
@jmartin-sul
jmartin-sul / Java REPL
Last active April 26, 2018 21:31
how to get a REPL for a Java project
Java 9 includes a native REPL now!
https://en.wikipedia.org/wiki/JShell
what if i'm stuck on an older version of java?
you might try the JavaREPL plugin: https://github.com/jburwell/gradle-javarepl-plugin
a web based REPL: http://www.javarepl.com/term.html
the advantage of a non-web REPL being that you can play around with your own local code, which is often what you want a REPL for.
@jmartin-sul
jmartin-sul / manifest.json
Created June 28, 2017 22:25
pdf manifest
{
"@context": [
"http://www.w3.org/ns/anno.jsonld",
"http://iiif.io/api/presentation/3/context.json"
],
"id": "http://localhost:3000/bb132pr2055/iiif3/manifest",
"label": "How does politics affect central banking? : evidence from the Federal Reserve",
"attribution": "(c) Copyright 2015 by Lucas Llanso Puente",
"logo": {