Skip to main content

Delete Git Branches

1 like • Mar 10, 2023 • 0 views
Shell
Loading...

More Shell Posts

Symlink Desktop

0 likes • Nov 18, 2022 • 0 views
Shell
#
# Austin Leath
# checks for /Desktop symlink. Creates the symlink if it doesnt already exist
#
#Fetch the target user if desired, otherwise use the currently logged in user.
if [ "$4" != "" ]; then
TARGET_USER=$4
else
TARGET_USER=$3
fi
if [ "$5" != "" ]; then
DIRECTORY_NAME=$5
else
TARGET_USER="$3 Desktop"
fi
# Functions
CHECK_SYMLINK() {
if test -f "/Desktop"; then
echo "/Desktop exists"
else
echo "/Desktop does not exist"
fi
}
CHECK_SYNTHETIC_CONF() {
if test -f "/etc/synthetic.conf"; then
echo "/etc/synthetic.conf exists"
else
echo "/etc/synthetic.conf does not exist"
fi
}
CREATE_SYMLINK() {
if [[ $(CHECK_SYNTHETIC_CONF) != "/etc/synthetic.conf exists" ]]; then
echo "/etc/synthetic.conf does not exist. creating.."
touch /etc/synthetic.conf
chown -R root:wheel /etc/synthetic.conf
fi
if grep -q "$DIRECTORY_NAME" /etc/synthetic.conf; then
echo "$DIRECTORY_NAME already exists"
exit 1
else
echo "$DIRECTORY_NAME\t/Users/$TARGET_USER/Desktop" >> /etc/synthetic.conf
fi
echo "/Desktop symbolic link created"
}
if [[ $(CHECK_SYMLINK) != "/Desktop exists" ]]; then
CREATE_SYMLINK
fi
exit 0

Bash Basics

0 likes • Nov 19, 2022 • 1 view
Shell
name="John"
echo ${name}
echo ${name/J/j} #=> "john" (substitution)
echo ${name:0:2} #=> "Jo" (slicing)
echo ${name::2} #=> "Jo" (slicing)
echo ${name::-1} #=> "Joh" (slicing)
echo ${name:(-1)} #=> "n" (slicing from right)
echo ${name:(-2):1} #=> "h" (slicing from right)
echo ${food:-Cake} #=> $food or "Cake"

stealNFTs

0 likes • Nov 23, 2021 • 1 view
Shell
#!/bin/bash
#Makes a directory ./monkeys and puts every single bored bored ape yacht club monkey in there
#Leif Messinger
let OFFSET=0
let BATCHSIZE=50
let LIMIT=100
mkdir monkeys
function parseResults(){
sed 'y/,/\n/' | sed -e '/storage.opensea/d' -e '/https:\/\/lh3.googleusercontent.com\/Ju9CkWtV-1Okvf45wo8UctR-M9He2PjILP0oOvxE89AyiPPGtrR3gysu1Zgy0hjd2xKIgjJJtWIc0ybj4Vd7wv8t3pxDGHoJBzDB=s120/d' | egrep '"image_url":"(.*)"' | tr -d '\"' | sed 's/image_url://'
}
function downloadMonkeys(){
while read -r line; do
name=`echo "$line" | sed 's/https:\/\/lh3.googleusercontent.com\///'`
wget -q -O "./monkeys/$name.png" "$line" &
done
}
function queryMonkeys(){
let progress=($OFFSET*100)/$LIMIT
echo "Progress: $progress%"
result=`curl -s --request GET --url "https://api.opensea.io/api/v1/assets?order_direction=desc&offset=$OFFSET&limit=$BATCHSIZE&collection=boredapeyachtclub"`
if [[ "$result" =~ "Request was throttled" ]] || [ "$result" == "" ]; then
#Retry download
sleep 10
else
#Download Monkeys
echo "$result" | parseResults | downloadMonkeys
let OFFSET+=$BATCHSIZE
fi
#If not out of bounds, recurse
if [ "$OFFSET" -lt "$LIMIT" ] || [[ "$result" =~ '"assets":[]' ]]; then
queryMonkeys
fi
}
echo "Downloading your monkeys into ./monkeys asynchronously."
queryMonkeys

diskRipper.sh

0 likes • Apr 21, 2021 • 0 views
Shell
#diskRipper.sh by Leif Messinger
#For use on debian, where your cds aren't immediately mounted
wall "CD inserted boss"
set -x #echo on
cdDrivePath=$(ls -l /dev/cdrom | awk '{print $NF}')
#CD could have no label, so that's why I need awk
cdLabel=$(lsblk -n "/dev/$cdDrivePath" -o label)
if [[ ! -z "$cdLabel" ]]; then #CD has label
folderName=$cdLabel
echo "The cd label is ${folderName}"
if mkdir ./cds/"${folderName}"; then #Folder didn't exist before
sudo mount /dev/cdrom ./.cdmountpoint
sudo cp -r ./.cdmountpoint/* "./cds/${folderName}"
sudo chmod -R 777 "./cds/${folderName}"
sudo umount ./.cdmountpoint
eject
wall "CD done and ejecting"
else
wall "Already read that cd, skipped"
fi
else
wall "CD had no label, skipped"
fi

Update Prefixed Dependencies

CHS
0 likes • Oct 9, 2023 • 41 views
Shell
# Update all npm packages under the scope defined by the PREFIX variable ("foo").
PREFIX="foo"; npm ls | grep "$PREFIX" | awk -F/ '{print $NF}' | sed 's/@.*//' | xargs -I package npm update @"$PREFIX"/package

checkAndPush.sh

0 likes • Nov 4, 2023 • 6 views
Shell
#!/bin/bash
git status
echo "Do you want to add all changed files?"
select yn in "Yes" "No"; do
case $yn in
Yes ) break;;
No ) exit 1;;
esac
done
git add -u
git status
echo "Does this look right?"
select yn in "Yes" "No"; do
case $yn in
Yes ) break;;
No ) exit 2;;
esac
done
git commit
echo "Do you want to push?"
select yn in "Yes" "No"; do
case $yn in
Yes ) break;;
No ) exit 2;;
esac
done
git push