Skip to content

Instantly share code, notes, and snippets.

View laduke's full-sized avatar

Travis LaDuke laduke

  • zerotier
  • California
View GitHub Profile
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 ""
@Jachimo
Jachimo / README.md
Created June 2, 2018 02:29
Using ZeroTier to route between two UniFi USG LANs

Routing between two UniFi USG based LANs with ZeroTier

Intro

This is a quick explanation of how to configure both ZeroTier and two Ubiquiti UniFi USGs to allow routing between two IPv4 networks. Both networks are in private (RFC1918) address space and each one has its own DHCP service. There is no need for NAT between them, only IP routing.

The two networks are 192.168.1.0/24 (call this the "left" network) and 192.168.10.0/24 (the "right" network) but they can be anything. Also, you can have multiple CIDR blocks on one side or the other of the ZeroTier route; if you do, you just have to create more routing table entries.

@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) =>
@lukechampine
lukechampine / monads.c
Last active November 14, 2023 18:22
Maybe and Either Monads in C
#include <stdio.h>
#include <stdbool.h>
// Maybe
typedef struct MaybeInt {
int just;
bool nothing;
} MaybeInt;
@spyesx
spyesx / rsync_backup.sh
Last active February 16, 2024 14:03
Rsync backup excluding node_modules
# Backup files
#https://explainshell.com/explain?cmd=rsync+-azuv+--delete+--progress+--exclude+%27node_modules%27
rsync -auvhp --delete --exclude=node_modules [source] [destination]
# Remove all node_modules folders
# https://explainshell.com/explain?cmd=find+.+-name+%22node_modules%22+-type+d+-prune+-exec+rm+-rf+%27%7B%7D%27+%2B
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
// 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 (
@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:
@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))
@themanifold
themanifold / node-prune.sh
Last active October 1, 2022 02:47
Pruning useless node_modules with bash userland tools (find etc)
#!/usr/bin/env bash
find node_modules \( -name '__tests__' -o \
-name 'test' -o \
-name 'tests' -o \
-name 'powered-test' -o \
-name 'docs' -o \
-name 'doc' -o \
-name '.idea' -o \
-name '.vscode' -o \
-name 'website' -o \
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`)