# Debian
# Without sudo won't show pids and process names
sudo netstat -tlpn|grep LISTEN
# macOS
# Increase +c for better names visibility
# Without sudo only shows processes of the current user
sudo lsof -i -nP +c 30|grep LISTENAll sorts of cases of undoing pushed and unpushed work in Git: https://sethrobertson.github.io/GitFixUm/fixup.html
Most frequently used:
# Undo unpushed commit, keep the work
git reset --soft HEAD~1
# Unstage everything
git reset
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
| to_timestamp(timestamp_in_milliseconds::numeric/1000) |
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
| ```bash | |
| # Get credentials from GCP | |
| gcloud container clusters get-credentials $CLUSTER --zone $ZONE --project $PROJECT | |
| echo Current context: $(kubectl config current-context) | |
| SOURCE="<POD>:/tmp/dump.sql" | |
| TARGET="./$CLUSTER.dump.compressed.sql" | |
| # Create a dump inside a container running in k8s | |
| kubectl exec -n $NAMESPACE --stdin --tty $POD -c $CONTAINER -- pg_dump -f /tmp/dump.sql -F c -Z 9 -U <USER> <DATABSE> |
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
| import ( | |
| "regexp" | |
| ) | |
| // The original W3C email regular expression taken from: | |
| // https://html.spec.whatwg.org/multipage/input.html#email-state-(type=email) | |
| // It is modified to include a domain zone at the end (in JavaScript it works fine without modifications). | |
| // This expression doesn't support addresses with UTF characters. | |
| var emailRegex = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\\.[a-zA-Z]{2,}$") |
Bash to a running docker container, dump Postrgres, copy the dump from the container, restore it to a local db.
# Get the name of the container
docker ps
# Bash to it
docker exec -it <DB CONTAINER NAME> /bin/bash
# Create a compressed dumpSwitching between Node.js version on macOS and pinning the one installed.
# Node 12 -> 14
brew unpin node@12
brew uninstall --force --ignore-dependencies node
brew install node@14
brew pin node@14
# Node 14 -> 12
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
| gcloud container clusters get-credentials $CLUSTER --zone europe-west2-a --project $PROJECT | |
| kubectl config get-clusters | |
| echo Current context: $(kubectl config current-context) | |
| kubectl get ns |
OlderNewer