• Nov 14, 2021 •LeifMessinger
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
• Nov 23, 2021 •LeifMessinger
0 likes • 3 views
#!/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
• Sep 29, 2021 •LeifMessinger
0 likes • 29 views
#!/bin/bash #cpcmd.sh [file1 [file2...]] #Prints out the commands needed to copy the file to your local machine #This will work on any server that also has the same hostname as in your hosts file. #I should update this to detect if a file is a directory, and enable recursion for those commands. If you do it now, it will probably just warn you. if [ -n "$1" ]; then for arg; do recursive=$(if [[ -d $arg ]]; then printf " -r"; fi) printf "scp$recursive \"$(whoami)@$(hostname):" printf `readlink -f $arg` printf "\" .\n" done else echo "scp \"$(whoami)@$(hostname):$PWD/*\" ." fi #-----------EDIT: #On the UNT cell machines, you have to do this script instead ##!/bin/bash #if [ -n "$1" ]; then # for arg; do # recursive=$(if [[ -d $arg ]]; then printf " -r"; fi) # printf "scp$recursive $(whoami)@$(hostname).eng.unt.edu:" # printf `readlink -f $arg` # printf " .\n" # done #else # echo "scp $(whoami)@$(hostname).eng.unt.edu:$PWD/* ." #fi
• Aug 7, 2023 •C S
0 likes • 2 views
# Three ways of checking if a file exists in a shell script FILE=/etc/resolv.conf if test -f "$FILE"; then echo "$FILE exists." fi if [ -f "$FILE" ]; then echo "$FILE exists." fi if [[ -f "$FILE" ]]; then echo "$FILE exists." fi
• Sep 9, 2023 •LeifMessinger
#!/bin/bash #Changes the remote url from https to ssh. #Only works for github, because I'd have to store a dictionary of every https to ssh url otherwise. #Made using Bing Chat # Get the remote URL from the console REPO_URL=$(git config --get remote.origin.url) # Check that REPO_URL contains https://github.com if [[ $REPO_URL == *"https://github.com"* ]]; then # Replace https with ssh in the URL REPO_URL=${REPO_URL/https:\/\/github.com\//[email protected]:} # Change the remote URL to the SSH version git remote set-url origin "$REPO_URL" else echo "Error: REPO_URL does not contain https://github.com" >&2 exit 1 fi
• Oct 17, 2023 •C S
2 likes • 17 views
# ---------------- FIREWALL STEPS ---------------- # Check if firewalld is installed and running sudo systemctl status firewalld # If it's not running, you can start and enable it sudo systemctl start firewalld sudo systemctl enable firewalld # Add a rule to allow traffic on port 6006. Port 6006 is the default port that storybook runs on. sudo firewall-cmd --permanent --add-port=6006/tcp # Reload the firewall for the changes to take effect sudo firewall-cmd --reload # Check the list of allowed ports sudo firewall-cmd --list-ports # ---------------- NGINX STEPS ---------------- # Install Nginx (if not already installed) sudo yum install nginx # Start and enable Nginx sudo systemctl start nginx sudo systemctl enable nginx # Copy your storybook-static directory to a location that Nginx can serve from. # The default web root directory for Nginx is /usr/share/nginx/html. sudo cp -r /path/to/storybook-static /usr/share/nginx/html/ # Adjust file permissions if needed to ensure that Nginx can read the files sudo chown -R nginx:nginx /usr/share/nginx/html/storybook-static # Put the following server block in /etc/nginx/conf.d/storybook.conf server { listen 6006; server_name your_domain.com; location / { root /usr/share/nginx/html/storybook-static; index index.html; } } # Test the Nginx configuration for syntax errors sudo nginx -t # If there are no errors, reload Nginx to apply the changes sudo systemctl reload nginx