Skip to content

Instantly share code, notes, and snippets.

@delirehberi
Created October 12, 2023 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save delirehberi/02f07be62e73078c0143dee58e0b7abf to your computer and use it in GitHub Desktop.
Save delirehberi/02f07be62e73078c0143dee58e0b7abf to your computer and use it in GitHub Desktop.
functions.sh
#find and replace in directory or file
#usage example frf ./where search replace
frf() {
echo "find $1 -type f -exec sed -i \"s+$2+$3+g\" {} \;";
}
#git push activebranch to origin
gpo() {
activeBranch=$(git branch|grep '*'|tr -d '* ')
git push origin $activeBranch
}
#git pull activebranch from origin
gup() {
activeBranch=$(git branch|grep '*'|tr -d '* ')
git pull origin $activeBranch
}
#Git diff master with active branch
gdm() {
activeBranch=$(git branch|grep '*'|tr -d '* ')
git diff master $activeBranch
}
latlon() {
curl -s -XGET "https://nominatim.openstreetmap.org/search?q=$1&format=json&polygon=1&addressdetails=1"|jq '(.|first)."lat" , (.|first)."lon"'|tr -d '"'|xargs echo|tr ' ' ','
}
did(){
local bskyhandle="https://${1}/.well-known/atproto-did"
local customhandle="https://dns.google/resolve?name=_atproto.${1}&type=TXT"
# Check if the domain is "bsky.social" and choose the appropriate URL
if [[ $1 == *bsky.social* ]]; then
curl "$bskyhandle"
else
curl -s "$customhandle"|jq '.Answer[0].data'|tr -d '"'|tr '=' ' '|awk '{print $2}'
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment