Skip to content

Instantly share code, notes, and snippets.

Avatar

Rune runeh

  • Oslo
View GitHub Profile
View machine.js
const stiftemaskinenMachine = Machine({
id: 'stiftemaskinen',
initial: 'pristine',
states: {
pristine: {
on: {
TOUCH_FORM: {
target: 'open',
View client.js
const client = sanityClient({
projectId: 'p354jyup',
dataset: 'main',
useCdn: true,
});
// needs polyfill
const origin = window.location.origin
client.clientConfig.cdnUrl = `${origin}/sanity`;
View mark console error test
$ 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>
View unleashstream.js
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();
}
View h2o_http2_proxy.yaml
listen:
port: 443
ssl:
certificate-file: /tmp/h2o/localhost.crt
key-file: /tmp/h2o/localhost.key
hosts:
"localhost":
paths:
"/":
View cowsaycow.js
"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) {
View cow.js
"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;
View cowstream.js
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++}}));
View gist:9c57dd997a46f0953c8a
const request = require('request-promise');
const highland = require('highland');
const promiseToStream = highland;
const arrayToStream = highland;
const pollerToStream = highland;
function seenRecently(timeGetter, mostRecentTime=0) {
return (e) => {
let then = timeGetter(e).getTime();
View fetch a bunch of ads with bacon
var fs = require("fs");
var Bacon = require("baconjs");
var lifestyle = require("lifestyle");
var root = "https://api.finn.no/iad/"
var adListPath = "adids.txt";
var client = new lifestyle.FinnClient(root);
function fetchAd(id) {
You can’t perform that action at this time.