Skip to content

Instantly share code, notes, and snippets.

Brad Fitzpatrick bradfitz

Block or report user

Report or block bradfitz

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
View spin.go
package main
import (
func main() {
var cpus = flag.Int("cpus", runtime.NumCPU()*2, "number of threads to spin")
View httpmono.go
package main
import (
View iptables-legacy-save.txt
root@kc1b:~# iptables-legacy-save
# Generated by iptables-save v1.8.2 on Sun Sep 8 09:23:15 2019
:PREROUTING ACCEPT [88168023:13613243271]
:OUTPUT ACCEPT [86121993:13224156217]
:CILIUM_OUTPUT_raw - [0:0]
:CILIUM_PRE_raw - [0:0]
-A PREROUTING -m comment --comment "cilium-feeder: CILIUM_PRE_raw" -j CILIUM_PRE_raw
-A OUTPUT -m comment --comment "cilium-feeder: CILIUM_OUTPUT_raw" -j CILIUM_OUTPUT_raw
-A CILIUM_OUTPUT_raw ! -s -m mark --mark 0xa00/0xfffffeff -m comment --comment "cilium: NOTRACK for proxy return traffic" -j NOTRACK
View gist:0fc1ba369159d297cd9469a72c1892f7
bradfitz@gdev:~/go/src$ git rev-parse HEAD
bradfitz@gdev:~/go/src$ git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
bradfitz@gdev:~/go/src$ git clean -n
View gist:58a15a15d90fc176771215e5e67b45af
root@gw:/etc/ppp/peers# systemctl status centurylink
● centurylink.service - PPPoE to Centurylink
Loaded: loaded (/etc/systemd/system/centurylink.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2018-11-19 11:41:02 PST; 2min 14s ago
Process: 1136 ExecStartPre=/usr/local/bin/ (code=exited, status=0/SUCCESS)
Main PID: 1157 (pppd)
Tasks: 1 (limit: 4720)
CGroup: /system.slice/centurylink.service
└─1157 /usr/sbin/pppd call centurylink nodetach logfd 1
View gist:df43c90fd280c9d6c066869b7b9ed40c
FROM debian:stretch
RUN apt-get update
RUN apt-get install --yes subversion autoconf automake gcc
RUN apt-get install --yes libgmp-dev libmpfr-dev libmpc-dev
RUN apt-get install --yes make
RUN apt-get install --yes file cpp
RUN mkdir /opt/gccgo
RUN mkdir /src
bradfitz / ws.go
Created Nov 5, 2018
pre-Go1.12 websocket hijack+proxy
View ws.go
httpsServer := &http.Server{
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
hj, isHJ := w.(http.Hijacker)
if r.Header.Get("Upgrade") == "websocket" && isHJ {
c, br, err := hj.Hijack()
if err != nil {
log.Printf("websocket websocket hijack: %v", err)
http.Error(w, err.Error(), 500)
bradfitz / hasswrap.go
Created Aug 17, 2018
Home Assistant wrapper
View hasswrap.go
package main
import (
View gist:8c60707ab12240b7e5842ce156b81553
bradfitz / amp.go
Last active Jul 23, 2018
Sonos amp control
View amp.go
// turnAmp controls the mPower Mini unit in Barloga, which
// powers the rainbow Google Chord AMP hooked up to the speakers.
func turnAmp(on bool) bool {
c, err := ssh.Dial("tcp", "10.0.0.nnnn:22", &ssh.ClientConfig{
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
Config: ssh.Config{
Ciphers: []string{"aes128-cbc"},
User: "ubnt",
Auth: []ssh.AuthMethod{ssh.Password("xxxxx")},
You can’t perform that action at this time.