Skip to content

Instantly share code, notes, and snippets.

View laduke's full-sized avatar

Travis LaDuke laduke

  • zerotier
  • California
View GitHub Profile
// maybeToFuture :: a -> Maybe b -> Future a b
const maybeToFuture = S.curry2((x, maybe) =>
S.maybe(Future.reject(x), Future.of, maybe)
);
//also
/*
Aldwin Vlasblom @Avaq Aug 14 05:12
I generally have two strategies for dealing with a Future(Just(x)):
Using maybeToFuture. @davidchambers just posted an implementation. I use this when Nothing represents an actual error in the code (one that can only be recovered from by my generic error recovery procedure, which usually reports the error and crashes the process).
@laduke
laduke / yo.el
Created December 20, 2017 17:42
Get web-mode inside of yo-yo/bel html template strings
(defun aj-javascript/post-init-mmm-mode ()
(with-eval-after-load 'rjsx-mode
(mmm-add-classes '((yo
:submode web-mode
:front "html`"
:back "`"
:face mmm-declaration-submode-face)))
(mmm-add-mode-ext-class 'rjsx-mode nil 'yo)
(setq mmm-parse-when-idle 't)
))
var daggy = require('daggy')
const Machine = daggy.taggedSum('Timer', {
Yellow: [],
Green: [],
Red: []
})
Machine.prototype.timer =
function () {
@laduke
laduke / html-index.js
Created July 10, 2018 17:45
simple html index
var http = require('http')
var { html, title, head, body, div } = require('hyperaxe')
var page = html(
head(title('hi')),
body(
div({ id: 'app' })
)
).outerHTML

Find your auth token

the authtoken.secret file

  • On Mac this is in "/Library/Application Support/ZeroTier/One". also, the installer copies it to ~/Library/Application
    Support/ZeroTier/One
  • Windows this is usually in "\ProgramData\ZeroTier\One". also, the installer copies it somewhere local to the installing user... I
@laduke
laduke / controller.org
Created February 25, 2019 18:41
controller.org

Set up a controller with curl

1 Find your auth token

the authtoken.secret file

  • On Mac this is in “/Library/Application Support/ZeroTier/One”. also, the installer copies it to ~/Library/Application\ Support/ZeroTier/One
  • Windows this is usually in “\ProgramData\ZeroTier\One”. also, the installer copies it somewhere local to the installing user… I forget
  • On Linux this is usually in “/var/lib/zerotier-one”.
function h(tag, as, xs) {
var attrs = Object.entries(as).map(([k, v]) => ` ${k}="${v}"`);
return `<${tag}${attrs}>${xs.join("")}</${tag}>`;
}
console.log(
h("div", { id: "foo" }, [
h("p", { class: "big" }, ["hi", h("p", {}, ["3"])]),
h("p", {}, ["bye"])
@laduke
laduke / machine.js
Last active September 19, 2019 23:15
Generated by XState Viz: https://xstate.js.org/viz
const myMachine = Machine({
type: 'parallel',
context: {},
states: {
hi: {
initial: 'no',
states: {
yes: {},
no: { on: { CLICK_ME: 'yes' } }
@laduke
laduke / network-via-fs.md
Last active December 17, 2020 17:39
zerotier network join via fs

Typically, you use zerotier-cli to join and leave networks, but you can also write files to the filesystem to do this.

The networks.d subdirectory of the ZeroTier working directory keeps track of which networks are joined and their settings.

The ZeroTier working directory can be found...

  • On Windows: \ProgramData\ZeroTier\One
  • On Mac: /Library/Application Support/ZeroTier/One
  • On Linux: /var/lib/zerotier-one