Skip to content

Instantly share code, notes, and snippets.

View detj's full-sized avatar
🖥️
deep into work

Debjeet Biswas detj

🖥️
deep into work
View GitHub Profile
@detj
detj / git-log-since-midnight-for-author.sh
Created February 20, 2024 10:49
git log since midnight for one author
git log --author="Firstname Lastname" --since=midnight --oneline
@detj
detj / measure-func.go
Created December 19, 2023 14:19
measure go func execution time
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)
@detj
detj / flush-dns-cache.sh
Last active November 28, 2023 11:03
flush dns cache on macOS
dscacheutil -flushcache
@detj
detj / docker-rmi-pattern.sh
Created November 15, 2023 10:42
delete docker images based on a regex pattern
# syntax
docker rmi $(docker images -a | rg <pattern> | awk '{print $3}'
# example
docker rmi $(docker images -a | rg supabase | awk '{print $3}'
@detj
detj / get-docker-image-ids.sh
Created November 15, 2023 10:40
get docker image ids
# 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
@detj
detj / repo-created-at.sh
Created November 14, 2023 07:40
get github repository creation date
# 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
@detj
detj / default-domains.sh
Created November 5, 2023 13:28
Get list all domains supported by defaults
# get list all domains support by `defaults` and present as a list
defaults domains | sed 's/, /\n/g'
@detj
detj / public-ip.sh
Last active December 19, 2023 14:39
Get public IP
# may or may not work
dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com
curl icanhazip.com
curl ifconfig.me
@detj
detj / disable-press-and-hold.sh
Created October 21, 2023 19:12
Disable ApplePressAndHold
# 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
@detj
detj / identifier.sh
Last active November 1, 2023 21:58
Find bundle identifier of a macOS app
# find the bundle identifier of Numbers app
codesign -dv /Applications/Numbers.app/
# explanation of the flags used
#
# -d, --display Display information about the code at the path(s) given.
# -v, --verify Requests verification of code signatures
# one line to directly extract the bundle identifier using [rg](https://github.com/BurntSushi/ripgrep)
codesign -dv /Applications/Numbers.app/ 2>&1 | rg '^Identifier=' --replace ""