To delete merged branches git branch --merged | grep -Ev "(^\*|master|main|dev)" | xargs git branch -d To retrieve commits between dates git log --after="2020-03-17" --before="2020-03-19" To retrieve full commit history of a file Note: works even for deleted files
If you know path to the file.
git log --all --full-history -- <path-to-file> If you do not know the path to the file.
git log --all --full-history -- "**/thefile.*" Reset a file to it’s state in master git checkout origin/master -- <path-to-file> Script to pull latest changes from master and rebase the current branch Filename: pull_and_rebase.sh
#! /bin/zsh # Pull from latest master and rebase # the current branch on master current_branch=$(git rev-parse --abbrev-ref HEAD) echo "### Rebasing $current_branchon master" git checkout master echo "### Pulling latest master" git pull -r echo "### Switching back to $current_branch" git checkout $current_branch git rebase master echo "### Rebase complete" chmod a+x pull_and_rebase.
…
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)