Skip to content

Instantly share code, notes, and snippets.

View dch's full-sized avatar
🛋️

Dave Cottlehuber dch

🛋️
View GitHub Profile
@dch
dch / openssh.erl
Created February 27, 2018 13:19 — forked from maxlapshin/openssh.erl
#!/usr/bin/env escript
%%
%%
-mode(compile).
-compile(export_all).
main([Port]) ->
{ok, _} = application:ensure_all_started(ssh),
@dch
dch / tips.md
Created February 26, 2018 08:33 — forked from ferd/tips.md
  • plan for code that is easy to delete/replace rather than code that is easy to extend or reuse. As needs change, you're more likely to change the assumptions about what the system should do than in how many ways it should do it. If the code needs extending, it's then easy to replace it with a bit that's easy to extend
  • planning for code that is easy to throw away is the best way I've found to properly bake in abstraction and isolation. The question is always "if I take this shit out or change its implementation entirely, do I need to replace anything else?". If the answer is "yes", then you may be leaking into other components. Fix it. turns out when you have that, it's also suddenly easier to reuse code.
  • write a prototype of whatever significant task you have to do, and consider it a draft. Use it to figure out requirements or to make your first mistakes in. Throw it away. Try again. As I gain more experience I find my prototypes smaller and individually more solid, but anything where I lack experience t
@dch
dch / gaelic.md
Last active November 15, 2017 15:23
Oró Sé do Bheatha 'Bhaile (Welcome Home)
Oh-roe shay duh vah-ha wall-ya,
Oh-roe shay duh vah-ha wall-ya,
Oh-roe shay duh vah-ha wall-yaaa,
[everyone] Ah-nish air hawkt un tauw-rEE!

[chorus]
Oh-roe shay duh vah-ha wall-ya,
Oh-roe shay duh vah-ha wall-ya,
Oh-roe shay duh vah-ha wall-yaaa,
@dch
dch / recover.sh
Last active February 9, 2024 06:23
tarsnap hacky parallel restore script
#!/bin/sh
# recover all files in parallel from the most recent archive
# MIT license
# https://git.io/vdrbG
# "works on my machine"
# lots of assumptions notably path length (strip-component)
# get the latest archive as our names can be sorted by time
ARCHIVE=`tarsnap --keyfile /tmp/tarsnap.key --list-archives | sort | tail -1`
#!/usr/bin/perl -w
# recover rsyslog disk queue index (.qi) from queue files (.nnnnnnnn).
#
# See:
# runtime/queue.c: qqueuePersist()
# runtime/queue.c: qqueueTryLoadPersistedInfo()
#
# [email protected] 2012-03-14
#
use strict;
@dch
dch / rsyslog.md
Created September 18, 2017 18:00
how to debug rsyslog

debugging rsyslog

export RSYSLOG_DEBUG=NoStdOut
export RSYSLOG_DEBUGLOG=/var/log/rsyslog/debug.log
/usr/local/sbin/rsyslogd -i /var/run/syslog.pid -f /usr/local/etc/rsyslog.conf -dn
tee -a /var/log/rsyslog/debug.log
@dch
dch / _zerotier_vpn_on_freebsd.md
Last active November 25, 2022 08:26
how to set up FreeBSD as a zerotier.com vpn

I'm using [PORT]net/zerotier[/PORT] for quite some time as a way of getting to my systems from other networks very happily. It works in airports, cafes, and all the usual hostile places we travel to.

It provides a L2 encrypted mesh (a bit like VXLAN I suppose) via a tap interface.

What I'd like to do is to use the ZT network as a VPN - routing all traffic from my FreeBSD laptop and phone through the zerotier layer out to my appointed ZT "VPN Gateway". Basically, translating the linux doc here: https://support.zerotier.com/knowledgebase.php?entry=show&search-for=full&article=ZWFhNWMyMTZjODY1ODcwNmFhZmJjYmRhN2I5MjRhOGQ_ -- into FreeBSD config. BTW https://www.zerotier.com/manual.shtml has a lot of background detail if you're interested.I can get the iphone working, but not the laptop.

What works after configuring zerotier to provide the "default route" is different on each device:

  • the iphone works
  • an apple imac works
[ 394.896]
X.Org X Server 1.18.4
Release Date: 2016-07-19
[ 394.896] X Protocol Version 11, Revision 0
[ 394.896] Build Operating System: FreeBSD 12.0-CURRENT amd64
[ 394.896] Current Operating System: FreeBSD wintermute.skunkwerks.at 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r320546+9ecc1769c831(drm-next): Sun Jul 2 00:10:54 UTC 2017 root@wintermute:/usr/obj/usr/src/sys/GENERIC amd64
[ 394.896] Build Date: 27 May 2017 01:35:38PM
[ 394.896]
[ 394.897] Current version of pixman: 0.34.0
[ 394.897] Before reporting problems, check http://wiki.x.org
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let colors_name = "kraihlight"
# https://raw.githubusercontent.com/basarevych/ansible-sshjail/1de8015b5d0f3bb9c9c9569106f35e6fe378decc/sshjail.py
# https://github.com/basarevych/ansible-sshjail 1de8015 on Dec 19, 2016
from __future__ import (absolute_import, division, print_function)
import os
import pipes
from ansible.errors import AnsibleError
from ansible.plugins.connection.ssh import Connection as SSHConnection
from contextlib import contextmanager