Skip to content

Instantly share code, notes, and snippets.

View bradfitz's full-sized avatar

Brad Fitzpatrick bradfitz

View GitHub Profile
@bradfitz
bradfitz / hasswrap.go
Created August 17, 2018 04:28
Home Assistant wrapper
package main
import (
"flag"
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"syscall"
./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 July 23, 2018 15:28
Sonos amp control
// 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")},
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 |................|
package main
import (
"crypto/tls"
"flag"
"io"
"log"
)
var once = flag.Bool("once", false, "just send one settings fame")
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 {
root@ss1:~# pveceph createosd /dev/sda --wal_dev=/dev/sdc1 --journal_dev=/dev/sdc2
create OSD on /dev/sda (bluestore)
using device '/dev/sdc2' for block.db
using device '/dev/sdc1' for block.wal
Creating new GPT entries.
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
Creating new GPT entries.
The operation has completed successfully.
Setting name!
(*mbr.Table)(0xc000088360)({
Partitions: ([]*mbr.Partition) (len=4 cap=4) {
(*mbr.Partition)(0xc000092160)({
Bootable: (bool) true,
Type: (mbr.Type) 131,
Start: (uint32) 2048,
Size: (uint32) 497664,
StartCylinder: (uint8) 0,
StartHead: (uint8) 32,
StartSector: (uint8) 33,
@bradfitz
bradfitz / gist:8d803135606c3a222fdb6d9fb666b962
Created April 18, 2018 02:31
failing to enlarge a partition
Trying to enlarge a VM's LVM partition from 400GB to 800GB.
I gave it more disk from the hypervisor and had the kernel rescan the SCSI bus, which worked:
dmesg:
[3879444.655318] sd 0:0:0:0: [sda] 1677721600 512-byte logical blocks: (859 GB/800 GiB)
[3879444.655447] sda: detected capacity change from 429496729600 to 858993459200
Old values:
Box: type "ftyp", size 24
- *heif.FileTypeBox: &{box:0xc0000941e0 MajorBrand:heic MinorVersion: Compatible:[mif1 heic]}
Box: type "meta", size 3956
- *heif.MetaBox, 8 children:
Box: type "hdlr", size 34
- *heif.HandlerBox: &{FullBox:{box:0xc0000942d0 Version:0 Flags:0} HandlerType:pict Name:}
Box: type "dinf", size 36
- *heif.DataInformationBox
Box: type "dref", size 28
- *heif.DataReferenceBox