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>
function getElementsByAttribute(attrName, root) {
root = root || document;
if (root.querySelectorAll) {
return root.querySelectorAll("[" + attrName + "]");
}
else {
var ret = [];
var elems = root.getElementsByTagName("*");
for (var n = 0, ele; ele = elems[n++];) {
if (ele.hasAttribute(attrName)) {
test
app.controller( 'AppCtrl', function ($scope, socket) {
socket.onopen(
function(){
console.log('Socket is connected :D')
}
)
socket.onclose(
function(){
console.log('Socket is disconnected :(')
}
@runeh
runeh / git-loglive
Last active December 14, 2015 05:49 — forked from githubteacher/git-loglive
#!/bin/bash
while :
do
clear
lines=`tput lines`
lines=`expr $lines - 2`
git --no-pager log --graph --pretty=oneline --abbrev-commit --decorate --all --color $* | head -n $lines
sleep 1
done