kubectl api-resources --verbs=list -o name | xargs -n 1 -t kubectl get --ignore-not-found --all-namespaces
This file contains 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
go build -gcflags=all=-trimpath=c:\path\to\trim -asmflags=all=-trimpath=c:\path\to\trim -ldflags=all="-s -w" | |
upx ... |
This file contains 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
// Initialize an empty image | |
dest := image.NewRGBA(image.Rect(0, 0, 800, 300)) | |
// Draw a white background | |
draw.Draw(dest, dest.Bounds(), &image.Uniform{color.White}, image.ZP, draw.Src) | |
// Read the font | |
fontBytes, err := ioutil.ReadFile(exeDir + "/DejaVuSans.ttf") | |
if err != nil { |
This file contains 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
# ZIP: | |
wget --header="PRIVATE-TOKEN: $GITLAB_TOKEN" "https://<gitlab>/<group>/<project>/builds/artifacts/master/download?job=<jobname>" | |
or | |
wget --header="PRIVATE-TOKEN: $GITLAB_TOKEN" "https://<gitlab>/<group>/<project>/-/jobs/artifacts/master/download?job=<jobname>" | |
# Single file: | |
wget -O /path/to/file --header="PRIVATE-TOKEN: $GITLAB_TOKEN" "https://<gitlab>/<group>/<project>/builds/artifacts/master/raw/<filename>?job=<jobname>" |
This file contains 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
var exeDir = getExeDir() | |
func getExeDir() string { | |
if os.Getenv("EXEDIR") != "" { | |
return os.Getenv("EXEDIR") | |
} else { | |
return filepath.Dir(os.Args[0]) | |
} | |
} |
This file contains 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
// While the Go documentation promotes the context package for keeping track of request context and cancelation, to | |
// actually use it for canceling work in http requests some plumbing is necessary: | |
// getCancelableContextFromResponseWriter gets a context.Context that is canceled when the client (browser) closes the connection | |
func getCancelableContextFromResponseWriter(w http.ResponseWriter) context.Context { | |
// Create a context that can be handed down to the workers to relay cancellation | |
ctx, cancelContext := context.WithCancel(context.Background()) | |
// Get a channel that receives a value when the request is canceled |
This file contains 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 | |
// Trigger ensures a worker runs once after it has been triggered, no matter how many trigger events happened during | |
// its last run. | |
// | |
// Usage: | |
// trigger := NewTrigger() | |
// go func() { | |
// for _ = range trigger { | |
// do_work() |
This file contains 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
// (I prefer "Two channels wrapped" and "Anonymous struct" over the other two) | |
// Two channels | |
resultCh := make(chan Result) | |
errorCh := make(chan Result) | |
go func(resultCh chan Result, errorCh chan errpr) { | |
errorCh <- errors.New("Does not compute")} | |
resultCh <- result | |
}(resultCh, errorCh) |
This file contains 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
func handleRequest(w http.ResponseWriter, r *http.Request) { | |
cn := w.(http.CloseNotifier) | |
cc := cn.CloseNotify() | |
go func() { | |
<-cc | |
log.Println("Closed!") | |
}() |
This file contains 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
DROP TABLE IF EXISTS public.with_enum; | |
DROP TABLE IF EXISTS public.with_text; | |
DROP TYPE IF EXISTS my_enum; | |
CREATE TYPE public.my_enum AS ENUM ('axyzxyz', 'bxyzxyz', 'cxyzxyz', 'dxyzxyz'); | |
CREATE TABLE public.with_enum ( | |
id serial NOT NULL PRIMARY KEY, | |
blah integer, | |
thecolumn my_enum |