This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "bytes" | |
| "crypto/aes" | |
| "crypto/cipher" | |
| "encoding/hex" | |
| "encoding/json" | |
| "flag" | |
| "fmt" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| var d = StubDoer(() { | |
| print("Also doing..."); | |
| }); | |
| d = wrapWithTimes(100)(d); | |
| d = wrapWithMetrics()(d); | |
| d = wrapWithTracing()(d); | |
| doStuff(d); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export MUSIC_PATH=/media/pi/CC72-D726 | |
| docker network create koel | |
| docker run \ | |
| -d \ | |
| --name mysql \ | |
| --network koel \ | |
| -e MYSQL_ROOT_PASSWORD=123456 \ | |
| -e MYSQL_USER=koel \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "net" | |
| "net/http" | |
| "strings" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type wrapHandlerFunc func(hn http.Handler, pattern string) http.HandlerFunc | |
| // mwLogs is used to wrap a handler so that it will emit HTTP logs for every request | |
| func mwLogs(logger *zap.Logger, hn handlerWithError) handlerWithError { | |
| return func(w http.ResponseWriter, r *http.Request) *apiError { | |
| // Track time | |
| startTime := time.Now() | |
| // Track response status code | |
| t := status.Track(w) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import shutil | |
| KB = 1024 | |
| MB = 1024 * KB | |
| GB = 1024 * MB | |
| shutil.disk_usage('/').free / GB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "encoding/json" | |
| "errors" | |
| "fmt" | |
| "log" | |
| "reflect" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package rename | |
| // renameFile renames a file | |
| // it can be used instead of os.Rename in cases where we attempt | |
| // to move files between partitions (e.g when using Docker volumes) | |
| func renameFile(src string, dst string) error { | |
| err := os.Rename(src, dst) | |
| if err == nil { | |
| return nil | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package x | |
| type InitializeFunc func() (io.Writer, error) | |
| type Writer struct { | |
| initFn InitializeFunc | |
| backoff Backoff | |
| w io.Writer | |
| mu *sync.Mutex |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package transaction | |
| import ( | |
| "bytes" | |
| "io" | |
| "io/ioutil" | |
| "net/http" | |
| "sync" | |
| ) |