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 | |
| set -euo pipefail | |
| usage() { cat >&2 <<'EOF' | |
| usage: zip2rar [options] FILE.zip | |
| --delete-source remove source zip after success | |
| --keep-mac-metadata keep .DS_Store, ._*, __MACOSX, etc. | |
| --no-sandbox skip sandbox-exec (debug only) | |
| -f, --force overwrite destination |
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
| ds() { n=$(echo $1 | sed -e 's/^S/s/'); mv $1 $n; } |
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 replaceChars(str, repl, with string) string { | |
| var oldnew []string | |
| for _, char := range repl { | |
| oldnew = append(oldnew, string(char), with) | |
| } | |
| return strings.NewReplacer(oldnew...).Replace(str) | |
| } |
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" | |
| "os" | |
| "path" | |
| "github.com/blevesearch/bleve/v2" | |
| ) |
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 funcName() string { | |
| pc, _, _, _ := runtime.Caller(1) | |
| nm := runtime.FuncForPC(pc).Name() | |
| dt := strings.Split(nm, ".") | |
| return dt[len(dt)-1] | |
| } |
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
| // the most simple web server in go | |
| package main | |
| import ( | |
| "net/http" | |
| ) | |
| func main() { | |
| http.Handle("/", http.FileServer(http.Dir("/tmp"))) | |
| http.ListenAndServe(":8080", 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
| #!/bin/bash -e | |
| src="${1?:No filename specified}" | |
| dst="${src%.*}.$(basename ${0})" | |
| echo "Converting '${src}' to '${dst}'" | |
| [ -f "${src}" ] || { echo "Source file '${src}' not found"; exit 1; } | |
| some_command "${src}" "${dst}" | |
| [ -f "${dst}" ] || { echo "Destination file '${dst}' not found"; exit 1; } | |
| rm -f "${src}" |
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 ( | |
| "math" | |
| "time" | |
| "github.com/faiface/pixel" | |
| "github.com/faiface/pixel/imdraw" | |
| "github.com/faiface/pixel/pixelgl" | |
| "golang.org/x/image/colornames" |
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
| // get cert from acme / letsencrypto auto cert manager | |
| // usage: go run getacme.go hostname | |
| package main | |
| import ( | |
| "crypto/tls" | |
| "crypto/x509" | |
| "fmt" | |
| "log" | |
| "net/http" |
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
| eval "$(go tool dist list | awk -v FS=/ -v BIN=stc '{ print "GOOS=" $1 " GOARCH=" $2 " go build -o out/" BIN "-" $2 "-" gensub(/windows/, "windows.exe", "g", $1) }' )" |
NewerOlder