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
Backup: | |
docker exec -t -u postgres your-db-container pg_dumpall -c > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql | |
Restore: | |
cat your_dump.sql | docker exec -i your-db-container psql -Upostgres |
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 | |
# Syntax | |
# awk '{gsub("\\n", "\n"}; print' <file> | |
# Example | |
awk '{gsub("\\n", "\n"}; print' some-file.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
for i in (seq 1 10) | |
go test ./... | |
end |
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
# Adding a key/value pair to an object based on a condition | |
# | |
# Let's say you have a sample object like: | |
# | |
# ```json | |
# { | |
# "session_id": "some-id-1", | |
# "timestamp": "some-timestamp", | |
# "events": [ | |
# { |
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 SomeFunction(list *[]string) { | |
defer TimeTrack(time.Now()) | |
// Do whatever you want. | |
} | |
func TimeTrack(start time.Time) { | |
elapsed := time.Since(start) | |
// Skip this function, and fetch the PC and file for its parent. | |
pc, _, _, _ := runtime.Caller(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
dscacheutil -flushcache |
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
# syntax | |
docker rmi $(docker images -a | rg <pattern> | awk '{print $3}' | |
# example | |
docker rmi $(docker images -a | rg supabase | awk '{print $3}' |
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
# grab list of image ids | |
docker images -a | tail -n+2 | awk '{print $3}' | |
# Explanation | |
# | |
# -n+2 removes the table header from the output | |
# awk '{print $3}' grabs the image column values | |
# Output |
NewerOlder