Skip to content

Instantly share code, notes, and snippets.

View laduke's full-sized avatar

Travis LaDuke laduke

  • zerotier
  • California
View GitHub Profile
const after = t => x => cont => {
const id = setTimeout (cont, t, x)
return () => clearTimeout (id)
}
const map = f => run => cont => run(x => cont (f (x)))
const chain = f => run => cont => run(x => f (x) (cont))
const run = chain (x => after (2000) (`${x}C`))
(map (x => `${x}B`)
@patrickarlt
patrickarlt / README.md
Last active January 23, 2018 17:12
Browser testing with Tape, Selenium and Webdriver IO.
@i-am-tom
i-am-tom / ReaderTFuture.js
Created November 21, 2017 12:12
Config-dependent Future.
const Future = require('fluture')
// I can't guarantee this will work out of the box - it's quite old... but
// you should hopefully be able to see how this fits together!
const { ReaderT } = require('fantasy-readers')
// First of all, you're going to need to "lift" all your `Future` operations
// to work within ReaderT. Basically, you just need to call `ReaderT.lift` on
// any `Future` values.
const doAjaxThing_ = x => ReaderT.lift(doAjaxThing(x))
// https://medium.com/@WebReflection/dom-handleevent-a-cross-platform-standard-since-year-2000-5bf17287fd38
export default class DOMEventHandler {
constructor(ctx, node) {
if (!ctx) throw new Error("DOMEventHandler: A context is required.");
this.ctx = ctx;
if (node) this.addEventListeners(node);
}
get events() {
return (
even_letters = "bcdfghlmnprstwx"
odd_letters = "aeiou"
def format_uid_digit (n, level):
if n != 0:
letters = odd_letters if (level & 1) else even_letters
base = len(letters)
s = format_uid_digit(n / base, level + 1)
return s + letters[(n % base)]
return ""
@alexvorobiev
alexvorobiev / configuration.nix
Last active February 10, 2019 06:10
NixOS on rpi3
{ config, pkgs, lib, ... }:
{
# NixOS wants to enable GRUB by default
boot.loader.grub.enable = false;
# Enables the generation of /boot/extlinux/extlinux.conf
boot.loader.generic-extlinux-compatible.enable = true;
# !!! If your board is a Raspberry Pi 1, select this:
# boot.kernelPackages = pkgs.linuxPackages_rpi;
# !!! Otherwise (even if you have a Raspberry Pi 2 or 3), pick this:
@tornqvist
tornqvist / example-memo.js
Last active May 19, 2020 19:02
A series of examples illustrating a new component API I've been working on in conjunction with changes to nanohtml
var { html, render } = require('nanohtml')
var { Component, memo, onupdate } = require('nanohtml/component')
// This example illustrates how memo can be used to maintain form state.
// On first render, getInitialValues is called and read values either
// from the fields argument or from local storage.
// Whenever a field changes its value is persisted to local storage.
var Form = Component(function (fields, values = memo(getInitialValues)) {
var update = onupdate(function (fields, values) {
@creationix
creationix / rpc.md
Last active December 30, 2020 03:58
Simple RPC design

I've designed a lot of RPC protocols in my career. One pattern that's worked well basically goes as follows:

// Client calls: print('Hello World\n')
-> [1, "print", "Hello World!\n"]
// Server sends return value (or lack of return vvalue)
<- [-1]

// Client calls: add(1, 2)
-> [2, "add", 1, 2]
@WebReflection
WebReflection / how-to-file-a-github-issue.md
Created November 25, 2019 19:34
How to file a GitHub/Lab issue

How to file a GitHub/Lab issue

helping each others


Original Medium post


Filing an issue is not about delegating your problem to another developer, it’s about helping maintainers solve issues they haven’t encountered yet.

@DrBoolean
DrBoolean / three_envs.js
Last active May 24, 2021 02:31
Tail of three envs
const compose = (f, g) => x => f(g(x))
const Id = x =>
({
fold: f => f(x),
map: f => Id(f(x))
})
Id.of = Id
const Tuple = (_1, _2) =>