Skip to content

Instantly share code, notes, and snippets.

const highland = require('highland');
const request = require('request-promise')
const promiseToStream = highland;
const arrayToStream = highland;
const pollerToStream = highland;
function cowPageGenerator(url) {
let page = 1;
return (push, next) => {
push(null, request(url, {qs: {page: page++}}));
"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;
"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) {
listen:
port: 443
ssl:
certificate-file: /tmp/h2o/localhost.crt
key-file: /tmp/h2o/localhost.key
hosts:
"localhost":
paths:
"/":
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();
}
$ 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(() =>