To create a virtualenv pyenv virtualenv <python_version> <env_name> To activate a virtualenv pyenv activate python_3.7.17 To list virtualenvs pyenv virtualenvs To remove a virtualenv pyenv virtualenv-delete <env_name>
Know the size of the uncompressed file without extracting gzip -l <file_name> | awk 'NR==2 {print $2}' | numfmt --to=iec-i --suffix=B Enddate of ssl certificate cho | openssl s_client -servername <domain> -connect <domain> 2>/dev/null | openssl x509 -noout -enddate Find a file recursively find needs a starting point, . is the current directory
find . -name "*.py"
Golang provides two types of timers: time.Timer and time.Ticker. Each have different use Case.
time.Timer is used to create a timer that fires once after the specified duration, while time.Ticker is used to create a timer that fires periodically at the specified interval.
Example 1: Timer https://goplay.tools/snippet/tSGKq126doi
package main import ( "fmt" "time" ) func main() { timer := time.NewTimer(2 * time.Second) go func() { fmt.Println("Inside go routine. Sleeping for 10 seconds") time.Sleep(10 * time.Second) }() <-timer.C fmt.Println("Exited after two seconds") } Example 2: Ticker https://goplay.tools/snippet/MiiE4p4fLjb
package main import ( "time" "fmt" ) func main() { ticker := time.NewTicker(1 * time.
…
Testing # To get coverage report # -v is for verbose go test -v ./... --cover # To know which lines are covered go test ./... --coverprofile=coverage.out go tool cover -html="coverage.out" Delve debugging # To print large outputs configure the following config max-string-len 200000 p string(byteSlice)
Create User and Database Create user webapp, database webappdb and grant all privileges to user.
To generate random passwords I use: https://passwordsgenerator.net/
CREATE DATABASE webappdb; CREATE USER 'webapp'@'%' identified by "LbAh52s6MnKQZasH"; GRANT ALL PRIVILEGES ON webappdb.* TO 'webapp'@'%' Grant read-only permission Grant read-only permission to user webapp_ro to database webappdb
GRANT SELECT ON webappdb.* TO 'webapp_ro'@'%'; Export to CSV from mysql shell SELECT * FROM <> WHERE <> INTO OUTFILE '/tmp/output.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'; Load CSV from mysql shell LOAD DATA LOCAL INFILE '<path-to-csv-file>' INTO TABLE <table_name> enclosed by '"' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'; Create index CREATE INDEX <index_name> ON <table_name>(<column_name>); Get size of tables SELECT TABLE_SCHEMA AS `Database`, TABLE_NAME AS `Table`, ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size (MB)` FROM information_schema.
…