paulgorman.org

< ^ txt

Fri Feb 2 09:03:24 EST 2018 Slept from ten-thirty to six-thirty. Woke briefly around four. Woke up feeling rested about thirty seconds before my alarm went off. Nice. High of eighteen today. Partly sunny. Chance of flurries. Work: - Order two new boxes for Sage (ugh) Done. - Review invoices Done. - Email Derek at Central about fiber Done. - Ask Florida and WV for Sage and mail data Done. - Work on MECS A bit. https://www.reddit.com/r/linuxadmin/comments/7uk9u1/who_supports_desktoplaptop_linux_en_mass/ Comcast seems to be having some (regional?) network issues immediately upstream of us. Twenty-minute walk at lunch. Home: - Improve the Go ring log thing from yesterday Done. https://play.golang.org/p/7e1VoaozTy2 Played with the fish shell. Sort of neat, especially `fish_config`. https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf // ringlog uses Go's ring container to keep the latest log entries. package main import ( "container/ring" "fmt" "io" "log" "os" ) var errCount int = -1 type ringLog struct { *ring.Ring } func (r *ringLog) Write(p []byte) (int, error) { r.Ring.Value = string(p) r.Ring = r.Ring.Next() return len(p), nil } func getTestError() error { errCount++ return fmt.Errorf("test error %v", errCount) } func main() { errRing := &ringLog{ring.New(5)} log.SetOutput(io.MultiWriter(os.Stderr, errRing)) for i := 0; i < 10; i++ { err := getTestError() if err != nil { log.Println(err) } } fmt.Println("--- from the ring ---") for i := 0; i < errRing.Ring.Len(); i++ { fmt.Printf("%v", errRing.Ring.Value) errRing.Ring = errRing.Ring.Next() } } Lunch: coffee, gyro Dinner: left-over pizza

< ^ txt