Skip to content

Instantly share code, notes, and snippets.

Avatar

Brad Fitzpatrick bradfitz

View GitHub Profile
View up-notes.txt
tailscale up
tailscale up --auth-key=xxxx
FIX:
tailscale up --advertise-tags=tag:foo
tailscale up --advertise-tags=tag:foo --shields-up=true
tailscale up --advertise-tags= --shields-up=true # explicitly mentioned good
tailscale up --shields-up=true # ERROR: unmentioned thing is changing value
tailscale up [--init] --advertise-tags= --shields-up=true # init is fine
View homerunner.go
// homerunner is Brad's shitty Docker wrapper after he got tired of running
// HA nine-VM Kubernetes clusters. Earlier versions of this tried to use podman
// and fancy cloud-init and CNI stuff but then I decided to go to the other
// extreme and write something super specific to what I need and super dumb:
// run my containers from gcr.io, and use my home Ceph cluster for mounts/state.
//
// This primarily runs Home Assistant, HomeSeer, an MQTT server, and some cameras.
// And some omitted misc stuff.
package main
@bradfitz
bradfitz / tailscale-acl.cue
Created May 2, 2021
Tailscale ACL schema WIP
View tailscale-acl.cue
import "net"
#Policy
#Policy: {
ACLs: [...#ACLRow]
Groups: #Groups
Hosts: #Hosts
TagOwners: [#TagName]: [...#TagOwner]
Tests: [...#ACLTest]
View gist:7493e5b4d88a78e6430338bd9bde90de
$ sqlite3
sqlite> .mode csv
sqlite> .import brad-2016-2020.csv items
sqlite> .import brad-2021-ytd.csv items
sqlite> .mode column
sqlite> .width 40
sqlite> .header on
sqlite> CREATE VIEW money_cat AS select Category, sum(Cast(Ltrim("Item Total", "$") as decimal)) as "Sum", count(*) from items group by Category;
sqlite> select category, round(100 * sum / (select sum(sum) from money_cat), 2) as "percent", "count(*)" from money_cat order by 2 desc limit 50;
Category percent count(*)
View update-netstack.sh
#!/bin/sh
set -e
set -x
cd $HOME
rm -rf netstack.bare netstack
git clone --bare $HOME/gvisor netstack.bare
cd netstack.bare
View go-runtime.sql
CREATE TABLE Space (Func varchar, Pkg varchar, What varchar, Size int64);
BEGIN TRANSACTION;
INSERT INTO Space VALUES ("go.buildid", "", "pcsp", 0);
INSERT INTO Space VALUES ("go.buildid", "", "pcfile", 0);
INSERT INTO Space VALUES ("go.buildid", "", "pcln", 0);
INSERT INTO Space VALUES ("go.buildid", "", "text", 112);
INSERT INTO Space VALUES ("go.buildid", "", "funcname", 11);
INSERT INTO Space VALUES ("internal/cpu.Initialize", "internal/cpu", "pcsp", 13);
INSERT INTO Space VALUES ("internal/cpu.Initialize", "internal/cpu", "pcfile", 5);
INSERT INTO Space VALUES ("internal/cpu.Initialize", "internal/cpu", "pcln", 21);
@bradfitz
bradfitz / pcfilesizes.txt
Created Apr 30, 2020
Finding functions with the largest pcfile tables
View pcfilesizes.txt
Got: {Magic:4277009103 Cpu:CpuArm64 SubCpu:0 Type:Exec Ncmd:29 Cmdsz:4528 Flags:2097285}
38 sections:
[0] {Name:__text Seg:__TEXT Addr:4294989976 Size:2401076 Offset:22680 Align:3 Reloff:0 Nreloc:0 Flags:2147484672}
[1] {Name:__gopclntab Seg:__DATA Addr:4298890048 Size:1821374 Offset:3922752 Align:5 Reloff:0 Nreloc:0 Flags:0}
[2] {Name:__rodata Seg:__DATA Addr:4297462176 Size:1417021 Offset:2494880 Align:5 Reloff:0 Nreloc:0 Flags:0}
[3] {Name:__noptrdata Seg:__DATA Addr:4300711456 Size:131552 Offset:5744160 Align:5 Reloff:0 Nreloc:0 Flags:0}
[4] {Name:__bss Seg:__DATA Addr:4300843008 Size:120184 Offset:0 Align:5 Reloff:0 Nreloc:0 Flags:1}
[5] {Name:__data Seg:__DATA Addr:4297414624 Size:47341 Offset:2447328 Align:5 Reloff:0 Nreloc:0 Flags:0}
[6] {Name:__noptrbss Seg:__DATA Addr:4300963200 Size:12520 Offset:0 Align:5 Reloff:0 Nreloc:0 Flags:1}
[7] {Name:__typelink Seg:__DATA Addr:4298879200 Size:8624 Offset:3911904 Align:5 Reloff:0 Nreloc:0 Flags:0}
@bradfitz
bradfitz / udp-off.sh
Created Mar 6, 2020
hacky scripts to toggle UDP access on a machine
View udp-off.sh
#!/bin/sh
set -e
set -x
./udp-on.sh
iptables -A INPUT -p udp --sport 53 -j ACCEPT
iptables -A INPUT -p udp -j DROP
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
@bradfitz
bradfitz / lj.tcl
Last active Feb 9, 2020
My original LiveJournal Tcl/Tk client
View lj.tcl
#!/bin/sh
# restart wish \
exec wish "$0" "$@"
#
# LiveJournal -- TCL/Tk client
# http://www.livejournal.com/
#
# Brad Fitzpatrick
# livejournal@bradfitz.com
View spin.go
package main
import (
"flag"
"fmt"
"runtime"
)
func main() {
var cpus = flag.Int("cpus", runtime.NumCPU()*2, "number of threads to spin")