Skip to main content

Delete Git Branches

Mar 10, 2023Helper
Loading...

More Shell Posts

NPM Workspaces Commands

Aug 16, 2023CHS

0 likes • 2 views

# Run "test" script on all packages
npm run test --workspaces
# Tip - this also works:
npm run test -ws
----------------------------------------------------
# Runs "test" only on package-a
npm run test --workspace package-a
# Tip - this also works:
npm run test -w package-a
----------------------------------------------------
# Install `lodash` on `package-a`
npm install lodash --workspace package-a
# Install `tap` on `package-b` as a dev dependency
npm install tap --workspace package-b --save-dev
# Install `package-a` on `package-b`
npm install package-a --workspace package-b
# Install `eslint` in all packages
npm install eslint --workspaces

upload_key.sh

Jan 12, 2023LeifMessinger

0 likes • 0 views

#!/bin/bash
#Originally made by Isaac Cook https://gist.github.com/icook/5400173
#Modified by Leif Messinger
#upload_key.sh [server_ip [server2_ip [...]]]
#To be run locally on a linux computer
if [ -e ~/.ssh/id_rsa.pub ];
then
echo "SSH Key already exists on local machine"
else
echo "Generating SSH key on local machine"
ssh-keygen -t rsa #generates id_rsa and id_rsa.pub
chmod -R 700 ~/.ssh #Sets permissions of ssh folder
ssh-add #Adds keys (and passwords?) to ssh_agent. (hopefully doesn't require password)
fi
echo "Loading client public key into memory"
pubKey=$(<~/.ssh/id_rsa.pub)
for server
do
echo "Adding client public key to $server remote server authorized keys"
#Idiot Isaac Cook didn't know about ssh-copy-id
#ssh-copy-id even checks if your key already exists
#In fairness, I didn't either until researching ssh-add
ssh-copy-id -i ~/.ssh/id_rsa.pub $server #In theory, this should prompt for a username
#ssh $server "mkdir -p ~/.ssh; #Make the folder if not already made
# echo \"$pubKey\" >> ~/.ssh/authorized_keys; #Append your public key to the server's authorized_keys
# chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys" #Set the correct permissions of those files
#echo "Adding server public key to local authorized keys"
#ssh $server "ssh-copy-id -i ~/.ssh/id_rsa.pub \$SSH_CLIENT" #this might need some awk, as $SSH_CLIENT spits out clientip portnumber
echo "Displaying server public key"
ssh $server "cat ~/.ssh/id_rsa.pub"
#Though, he did give me a good idea
echo "Displaying keys authorized on $server (you can paste them in your authorized_keys file)"
ssh $server "cat ~/.ssh/authorized_keys"
#echo "Appending keys authorized on $server to your local authorized_keys"
#ssh $server "cat ~/.ssh/authorized_keys" >> ~/.ssh/authorized_keys
done
echo "SSH keys schronized successfully!"

abuseipdb config

Nov 18, 2022AustinLeath

0 likes • 1 view

#for ssh abuse attempts
action = %(action_)s
%(action_abuseipdb)s[abuseipdb_apikey="", abuseipdb_category="18,22"]
actionban = curl --fail --ciphers ecdhe_ecdsa_aes_256_sha --data 'key=<abuseipdb_apikey>' --data-urlencode 'comment=<matches>' --data 'ip=<ip>' --data 'category=<abuseipdb_category>' "https://www.abuseipdb.com/report/json"

stealNFTs

Nov 23, 2021LeifMessinger

0 likes • 1 view

#!/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

codecatch.sh

Nov 14, 2021LeifMessinger

0 likes • 0 views

#!/bin/bash
#Takes all the c and h files in the current directory and prints them
#Yup, it's that easy
for file in *.h *.hpp *.c *.cpp; do
#If it exists
if [ -f "$file" ]; then
echo "//===============$file==============="
cat $file
fi
done

Search file with word list fast

Feb 22, 2022LeifMessinger

0 likes • 1 view

#Leif Messinger
#For when you want to search a lot of words in a file fast
#Arg 1 is the argument the list of words you want to search
#Arg 2 is the file you want to search
#-z means that it looks at the file as a whole, just treating newlines a characters.
#-r is regex. Needed for $, even tho the documentation says you don't need it. They are liars.
#First command replaces all . with \. and all - with \-
#Second command takes all newlines and replaces them with )|(
#Third command takes the trailing |( and deletes it
#Forth command puts a /( at the start
#Fith command puts /!d at the end. This tells it to not delete any lines that match the pattern.
#The second sed takes the output of the first sed as a command that searches any of the combined words
#-f - takes a command from the input
sed -z -r -e 's/\./\\\./g ; s/\-/\\\-/g' -e 's/\n/\)\|\(/g' -e 's/\|\($//' -e 'i/\(' -e 'a/!d' $1 | sed -r -f - $2