Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am runeh on github.
  • I am runefh (https://keybase.io/runefh) on keybase.
  • I have a public key whose fingerprint is 0364 1B02 B674 503C 1FBE C8E7 A979 D86F 0E49 13DB

To claim this, I am signing this object:

@runeh
runeh / json-as-runtypes.ts
Created March 28, 2021 21:11
Runtypes definition to match JSON
import * as rt from 'runtypes';
export type JSONPrimitive = string | number | boolean | null;
export type JSONValue = JSONPrimitive | JSONObject | JSONArray;
export type JSONObject = { [member: string]: JSONValue };
export type JSONArray = Array<JSONValue>;
type JSONRoot = JSONArray | JSONObject;
const JSONPrimitiveRt = rt.Intersect(rt.String, rt.Number, rt.Boolean, rt.Null);
const JSONValueRt: rt.Runtype<JSONValue> = rt.Lazy(() =>
@runeh
runeh / machine.js
Created March 12, 2021 13:34
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@runeh
runeh / machine.js
Created July 20, 2020 15:11
Generated by XState Viz: https://xstate.js.org/viz
const stiftemaskinenMachine = Machine({
id: 'stiftemaskinen',
initial: 'pristine',
states: {
pristine: {
on: {
TOUCH_FORM: {
target: 'open',
const client = sanityClient({
projectId: 'p354jyup',
dataset: 'main',
useCdn: true,
});
// needs polyfill
const origin = window.location.origin
client.clientConfig.cdnUrl = `${origin}/sanity`;
$ var personPromise = new Promise((resolve, reject) => {
setTimeout(function() {
reject('oh no');
}, 1000);
});
<await(person from personPromise)>
<div>Works</div>
<await-error>something went wrong</await-error>
</await>
var request = require('request-promise');
var highland = require('highland');
var promiseToStream = highland;
var arrayToStream = highland;
var pollerToStream = highland;
function eventTime(event) {
return new Date(event.createdAt).getTime();
}
listen:
port: 443
ssl:
certificate-file: /tmp/h2o/localhost.crt
key-file: /tmp/h2o/localhost.key
hosts:
"localhost":
paths:
"/":
"use strict";
var highland = require("highland");
var request = require("request-promise");
var cowsay = require("cowsay");
var promiseToStream = highland;
var arrayToStream = highland;
var pollerToStream = highland;
function cowPageGenerator(url) {
"use strict";
var highland = require("highland");
var request = require("request-promise");
var promiseToStream = highland;
var arrayToStream = highland;
var pollerToStream = highland;
function cowPageGenerator(url) {
var page = 1;