Skip to content

Instantly share code, notes, and snippets.

💭
On leave; new baby 😱

Brad Fitzpatrick bradfitz

💭
On leave; new baby 😱
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 gist:0fc1ba369159d297cd9469a72c1892f7
bradfitz@gdev:~/go/src$ git rev-parse HEAD
b44cd15464a87be57446a7573f76846088826606
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/setup-ipv6.sh (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
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)
return
}
@bradfitz
bradfitz / hasswrap.go
Created Aug 17, 2018
Home Assistant wrapper
View hasswrap.go
package main
import (
"flag"
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"syscall"
View gist:8c60707ab12240b7e5842ce156b81553
./vendor
./vendor/golang_org
./vendor/golang_org/x
./vendor/golang_org/x/crypto
./vendor/golang_org/x/crypto/internal
./vendor/golang_org/x/crypto/internal/chacha20
./vendor/golang_org/x/crypto/chacha20poly1305
./vendor/golang_org/x/crypto/cryptobyte
./vendor/golang_org/x/crypto/cryptobyte/asn1
./vendor/golang_org/x/crypto/curve25519
@bradfitz
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")},
View gist:0dbdd7471b2e52606fd35a29aff9d68d
root@debian:~# dd if=/dev/sda of=out bs=1M count=1
1+0 records in
1+0 records out
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.00404595 s, 259 MB/s
root@debian:~# hd out
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000001c0 01 00 ee fe ff ff 01 00 00 00 ff ff 9f 00 00 00 |................|
000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
View setting-dos.go
package main
import (
"crypto/tls"
"flag"
"io"
"log"
)
var once = flag.Bool("once", false, "just send one settings fame")
View transport.diff
func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFrame) (*http.Response, error) {
if f.Truncated {
return nil, errResponseHeaderListSize
@@ -1750,15 +1762,6 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra
return nil, errors.New("malformed response from server: malformed non-numeric status pseudo header")
}
- if statusCode == 100 {
- traceGot100Continue(cs.trace)
- if cs.on100 != nil {
You can’t perform that action at this time.