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
#!/bin/bash | |
# cp from https://twitter.com/b0rk/status/1312413117436104705 | |
trap '(read -p "[$BASH_SOURCE:$LINENO] $BASH_COMMAND?")' DEBUG |
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
sed '/^$/N;/^\n$/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
grep -E "^(\w+|\s+~|\s+\+|\s+\-|\s+#|\s+<=|$) |
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
# from https://github.com/docker/cli/blob/master/Makefile#L74-L76 found by @breml | |
.PHONY: help | |
help: ## print this help | |
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {gsub("\\\\n",sprintf("\n%22c",""), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) |
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" | |
) | |
func main() { | |
chain(a).chain(b).chain(c)() | |
} |
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
// normalizeLocalTime will normalize local time expressed in number of seconds | |
// from UNIX Epoch but not in UTC but counted in local location to the one | |
// counted correctly from UTC location. | |
func normalizeLocalTime(localNumOfSeconds int64, location *time.Location) time.Time { | |
t := time.Unix(localNumOfSeconds, 0).In(location) | |
_, offset := t.Zone() | |
// we apply offset in reverse to correct time | |
return t.Add(-1 * time.Duration(offset) * time.Second) | |
} |
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" | |
"fmt" | |
"log" | |
"os/exec" | |
"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
func contextWithSigterm(ctx context.Context) context.Context { | |
ctxWithCancel, cancel := context.WithCancel(ctx) | |
go func() { | |
defer cancel() | |
signalCh := make(chan os.Signal, 1) | |
signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM) | |
select { | |
case <-signalCh: |
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
man man | col -bx | |
col -b removes backspaces. | |
col -x replaces tabs with spaces |
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
wget -q -O- http://url | grep string |
NewerOlder