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
# 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 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
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 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
dscacheutil -flushcache |
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
# 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 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
# 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 |
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
# syntax | |
curl -s https://api.github.com/repos/<org>/<repo> | jq .created_at | |
# example | |
curl -s https://api.github.com/repos/PRQL/prql | jq .created_at |
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
# get list all domains support by `defaults` and present as a list | |
defaults domains | sed 's/, /\n/g' |
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
# may or may not work | |
dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com | |
curl icanhazip.com | |
curl ifconfig.me |
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
# syntax to read | |
# defaults read <bundle-identifier> ApplePressAndHoldEnabled | |
# syntax to write | |
# defaults write <bundle-identifier> ApplePressAndHoldEnabled -bool false | |
# example command | |
defaults write com.electron.replit ApplePressAndHoldEnabled -bool false |