Skip to content

Instantly share code, notes, and snippets.

Dave Cottlehuber dch

Block or report user

Report or block dch

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dch
dch / recover.sh
Last active Oct 11, 2017
tarsnap hacky parallel restore script
View recover.sh
#!/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`
View recover_qi.pl
#!/usr/bin/perl -w
# recover rsyslog disk queue index (.qi) from queue files (.nnnnnnnn).
#
# See:
# runtime/queue.c: qqueuePersist()
# runtime/queue.c: qqueueTryLoadPersistedInfo()
#
# kaiwang.chen@gmail.com 2012-03-14
#
use strict;
@dch
dch / rsyslog.md
Created Sep 18, 2017
how to debug rsyslog
View rsyslog.md

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 Jan 20, 2019
how to set up FreeBSD as a zerotier.com vpn
View _zerotier_vpn_on_freebsd.md

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
View Xorg.0.log
[ 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
View kraihlight.vim
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let colors_name = "kraihlight"
View sshjail.py
# 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
View dtrace.md
# show the first argument passed to ether_input function 
dtrace -n 'fbt::ether_input:entry { print(*(args[0])); }'
# dump first 32 bytes of the dereferenced pointer to the actual data arriving on the wire
dtrace -n 'fbt:kernel:ether_input:entry { tracemem(args[1]->m_data, 32); }'
@dch
dch / mcorbin_config.clj
Last active May 24, 2017 — forked from faxm0dem/riemann-config.clj
riemann collectd watchdog
View mcorbin_config.clj
(streams
(with {:service "heartbeat" :ttl 120 } (index))
(where (service "heartbeat")
(by :host (...))))
@dch
dch / riemann-slack.clj
Created May 24, 2017
slack with rollups
View riemann-slack.clj
(defn format-slack-attachments
"Format attachments list from events."
[events mentions]
(let [event-count (count events)
event (last events)
description (:description event)
event-text (format-event-text event)
color (get-event-color event)]
(if (= event-count 1)
[{:text event-text
You can’t perform that action at this time.