Skip to content

Instantly share code, notes, and snippets.


Mat Wood thepacketgeek

View GitHub Profile
thepacketgeek / .zshrc
Created January 6, 2022 18:20
Git checkout branch w/ fzf
View .zshrc
gch() {
git checkout $(git for-each-ref refs/heads/ --format='%(refname:short)' | fzf)
gchr() {
git checkout --track $(git branch --remotes | fzf)
thepacketgeek /
Created January 4, 2022 22:00
Host `cargo doc` in HTTP server
set -o errexit
pushd `BROWSER=echo cargo doc --open | sed "s/\/doc\/.*/\/doc\//"` && python -m http.server; popd
thepacketgeek / gist:6f00c7d2e2d9e4ba8df20b9adf214067
Created June 25, 2021 17:59
Telegraf Syslog with "source" tag
View gist:6f00c7d2e2d9e4ba8df20b9adf214067
./telegraf --test --config /etc/telegraf/telegraf.conf --input-filter syslog --test-wait 15
2021-06-25T17:55:06Z I! Starting Telegraf
> syslog,appname=docker-compose,facility=daemon,host=bb8,hostname=droplet,location=home,severity=info,source= facility_code=3i,message="<redacted>",severity_code=6i,timestamp=1624643706396113000i,version=1i 1624643706400667198
> syslog,appname=tailscaled,facility=daemon,host=bb8,hostname=dev,location=home,severity=info,source= facility_code=3i,message="<redacted>",severity_code=6i,timestamp=1624643706403394000i,version=1i 1624643706407850408
> syslog,appname=docker-compose,facility=daemon,host=bb8,hostname=droplet,location=home,severity=info,source= facility_code=3i,message="<redacted>",severity_code=6i,timestamp=1624643706675853000i,version=1i 1624643706679251683
> syslog,appname=multipathd,facility=daemon,host=bb8,hostname=droplet,location=home,severity=info,source= facility_code=3i,message="<redacted>",severity_code=6i,timestamp=162464370
thepacketgeek / gist:24dc4665cc4045d730ca032ed4b8aaa1
Created November 24, 2020 14:28
Influx Query for showing delta of cumulative iface counts
View gist:24dc4665cc4045d730ca032ed4b8aaa1
non_negative_derivative(mean("ifHCInOctets"), 1s) * 8 AS "Rx",
non_negative_derivative(mean("ifHCOutOctets"), 1s) * 8 AS "Tx"
FROM "interface"
WHERE ("ifAlias" = 'Some if here')
AND $timeFilter GROUP BY time($__interval) fill(null)

Diving into Rust

If you're wanting to get involved with Rust projects and see what the magic is all about, here are some great starting points!


  • A Gentle Introduction
    • A little more focused on the main concepts, only takes an hour or so
  • The Book
    • This is the first and foremost (albiet most time consuming) way to get familiar
  • Py2Rs
View pcapng ->
extern crate pcarp;
use std::fs::File;
use std::io::{Cursor, Read};
use std::net::IpAddr;
use std::path::Path;
use std::result::Result;
use bgp_rs::{Header, Message, Reader};
use byteorder::{NetworkEndian, ReadBytesExt};
View gist:d7ff94bdce21fe073124fc3ec142a648
Update {
withdrawn_routes: [],
attributes: [
ASPath {
segments: []
thepacketgeek /
Created July 24, 2015 15:19
Convert Subnet Mask to CIDR length
def calc_mask_length(mask):
""" Convert subnet mask ( to CIDR mask length (/24) """
return sum([bin(int(x)).count('1') for x in mask.split('.')])
print calc_mask_length('')
# 24
#!/usr/bin/env python
## Tiny Syslog Server in Python.
## This is a tiny syslog server that is able to receive UDP based syslog
## entries on a specified port and save them to a file.
## That's it... it does nothing else...
## There are a few configuration parameters.
LOG_FILE = 'youlogfile.log'
import paramiko
import re
from time import sleep
# Router connection details (could be read in from file or argparse)
peer = ''
username = 'admin'
password = 'admin'
def collect_output(shell, command):