Skip to content

Instantly share code, notes, and snippets.

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();
}
@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
app.controller( 'AppCtrl', function ($scope, socket) {
socket.onopen(
function(){
console.log('Socket is connected :D')
}
)
socket.onclose(
function(){
console.log('Socket is disconnected :(')
}
test
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)) {
$ 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>
const client = sanityClient({
projectId: 'p354jyup',
dataset: 'main',
useCdn: true,
});
// needs polyfill
const origin = window.location.origin
client.clientConfig.cdnUrl = `${origin}/sanity`;
@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',
@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 / 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(() =>