Skip to content

Instantly share code, notes, and snippets.

View laduke's full-sized avatar

Travis LaDuke laduke

  • zerotier
  • California
View GitHub Profile
@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
@laduke
laduke / rules.md
Last active December 17, 2020 17:39
zerotier rules engine - examples

Whitelist by port

drop
  not ethertype ipv4
  and not ethertype arp
  and not ethertype ipv6
;

accept
 dport 6445
@laduke
laduke / zerotier-rpi-bridge.md
Last active January 26, 2024 13:01
Various Network Configuration Output

Motivation

Use a Raspberry Pi as a bridge into my home LAN. The pi is plugged into a switch, which is plugged into an airport express, which is plugged into a cable modem; Nothing fancy.

This isn't a tutorial. Just some example output from a working setup.

steps

off the top of my head, here's the order I would do it in:

  • make sure plain old device to device zerotier is working with my LAN/Router/Firewall/ISP
var daggy = require('daggy')
const Machine = daggy.taggedSum('Timer', {
Yellow: [],
Green: [],
Red: []
})
Machine.prototype.timer =
function () {
@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)
))
@laduke
laduke / zerotier - client isolation.md
Last active December 17, 2020 17:39
ZeroTier Rules Engine - Hub and Spoke - Client Isolation

Common ZeroTier Rules Engine question

  • Non-servers can talk to servers, but not each other
  • Kind of like Client Isolation on some WiFi controllers

Rules

# Allow only IPv4, IPv4 ARP, and IPv6 Ethernet frames. Typical default
drop
not ethertype ipv4
and not ethertype arp
// 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 / maybeToFuture.js
Created August 17, 2017 16:52
Maybe to Future
// Courtesy https://gitter.im/sanctuary-js/sanctuary
// maybeToFuture :: a -> Maybe b -> Future a b
const maybeToFuture = S.curry2((x, maybe) =>
S.maybe(Future.reject(x), Future.of, maybe)
);
// Collapse a `Future String (Maybe Integer)` into a `Future String Integer`.
S.chain(maybeToFuture('parseInt: "XXX" does not represent an integer'),
Future.of(S.Nothing));

mix phoenix.new --no-ecto hello_phoenix

If I remember correctly, letting ecto in makes it look for postgres on the pi. Could probably easily set it up for sqlite?

cd hello_phoenix

cp ../nerves_examples/hello_network/Bakefile .

Add to server: true to config section in config/prod.exs and change http to a specific port (It didn't seem to work setting PORT env variable, but I only tried once. )

@laduke
laduke / plsync.sh
Last active December 16, 2015 18:09 — forked from mkaito/plsync.sh
#!/usr/bin/env zsh
# Takes all my playlists from ~/.mpd/playlists, fixes them up, and creates a
# folder for each, along with the music they reference.
# The sync stage requires an sshd server to run on your phone, as well as the rsync executable.
# - http://linux.wxs.ro/2011/08/05/rsync-your-android/
MPD_MUSIC_ROOT="${HOME}/Music" # Root of your MPD library
MPD_PLAYLIST_ROOT="${HOME}/.mpd/playlists" # MPD playlist folder