Skip to content

Instantly share code, notes, and snippets.

{
"include": [
"node_modules/tdesign-vue-next/global.d.ts"
]
}
{
"compilerOptions": {
"types": ["tdesign-vue-next/global"]
}
}
@vikyd
vikyd / README.md
Last active January 16, 2019 09:18
Golang build with custom tags, run `go build`, run `go build -tags abc`

go build directly

run:

go build

then run binary file, expected print:

def
@vikyd
vikyd / main.go
Created November 28, 2018 08:06
Golang context cancel multiple sleep
package main
import (
"context"
"fmt"
"time"
)
func main() {
ctx, cancel := context.WithCancel(context.Background())
@vikyd
vikyd / getVal.sh
Last active September 12, 2018 03:07
Shell: get value from key=value file with value trim and key trim, and allow `=` ` space` in value
#!/bin/sh
# These vars and func are used to get value from a key=value file
# It will also trim the leading and trailing whitespace, tab
# Key with space after or before is supported
getVal(){
# cut `=` in val: https://unix.stackexchange.com/a/53315/207518
# grep: allow space after or before of key
# awk trim space after and before of value: https://unix.stackexchange.com/a/205854/207518
declare val=$(cat ${1} | grep "^ *${2} *=" | cut -d '=' -f 2- | awk '{$1=$1}1')
@vikyd
vikyd / getVal.bat
Last active September 12, 2018 03:08
Windows Batch: get value from key=value file with value trim, not allow `=` in value, not allow space after or before the key
@ECHO OFF
REM https://stackoverflow.com/a/9681923/2752670
SET myKey=abc2
SET myFile=keyval.txt
CALL :GetVal %myFile% %myKey% myVal
REM is string empty https://stackoverflow.com/a/2541820/2752670
IF [%myVal%] == [] (
ECHO no key: %myKey% in file: %myFile%
) ELSE (