Run /usr/local/bin/k3s-uninstall.sh
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 openBrowser(url string) { | |
var err error | |
switch runtime.GOOS { | |
case "linux": | |
err = exec.Command("xdg-open", url).Start() | |
case "windows": | |
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start() | |
case "darwin": | |
err = exec.Command("open", url).Start() |
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
#!/usr/bin/env bash | |
FOLDER=$1 | |
MAX_WIDTH=1400 | |
MAX_HEIGHT=1000 | |
# resize, strip metadata and save in a lower quality | |
# aspect ratio will be kept. | |
find ${FOLDER} \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' \) -exec convert \{} -verbose -strip -quality 75 -resize "${MAX_WIDTH}x${MAX_HEIGHT}>" \{} \; |
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
// geoOffset 计算从 (lon0, lat0) 经纬度(单位 °)移动 dx, dy 米后的新的经纬度 | |
// | |
// 这个算法在100km以内有良好精度。 | |
// | |
// source: https://stackoverflow.com/questions/2839533/adding-distance-to-a-gps-coordinate | |
func geoOffset(lon0, lat0, dx, dy float64) (lon, lat float64) { | |
lon = lon0 + (180/math.Pi)*(dx/6378137)/math.Cos(lat0/180*math.Pi) | |
lat = lat0 + (180/math.Pi)*(dy/6378137) | |
return |
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
echo | openssl s_client -servername www.github.com -connect www.github.com:443 2>/dev/null | openssl x509 -noout -dates |
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
// QueryParams every key is a query param | |
type QueryParams map[string]QueryParam | |
// Scan satisfies SQL scanner interface | |
func (q *QueryParams) Scan(src interface{}) error { | |
b, ok := src.([]byte) | |
if !ok { | |
return errors.New("type assertion to []byte failed") | |
} |
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
apiVersion: elasticsearch.k8s.elastic.co/v1beta1 | |
kind: Elasticsearch | |
metadata: | |
namespace: elastic-system | |
name: logging-eck | |
spec: | |
version: 7.4.2 | |
nodeSets: | |
- name: default | |
count: 1 |
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
# unique line | |
awk '{!seen[$0]++};END{for(i in seen) if(seen[i]==1)print i}' file | |
# second column of a csv, with white spaces and quotes stripped | |
awk -F',' '{gsub(/[ "]/, "", $0);print $2}' some.csv > dest.txt |
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
function isTouchDevice() { | |
return 'ontouchstart' in window | |
} |
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
// source: https://www.reddit.com/r/golang/comments/5ia523/idiomatic_way_to_remove_duplicates_in_a_slice/db6qa2e/ | |
func SliceUniqMap(s []int) []int { | |
seen := make(map[int]struct{}, len(s)) | |
j := 0 | |
for _, v := range s { | |
if _, ok := seen[v]; ok { | |
continue | |
} | |
seen[v] = struct{}{} | |
s[j] = v |