Skip to main content

Delete Git Branches

Mar 10, 2023Helper
Loading...

More Shell Posts

Update Prefixed Dependencies

Oct 9, 2023C S

0 likes • 114 views

# 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

installVulkanUbuntu.sh

Jul 16, 2023LeifMessinger

0 likes • 5 views

#!/bin/bash
sudo apt install build-essential vulkan-tools libvulkan-dev vulkan-validationlayers-dev spirv-tools libglfw3-dev libglm-dev libtinyobjloader-dev
#The rest of this downloads the Vulkan Tutorial project and its dependencies.
#Comment this out to keep going
exit
sudo apt install git cmake cmake-gui
sudo mkdir /usr/lib/stb
pushd /usr/lib/stb
sudo wget https://raw.githubusercontent.com/nothings/stb/master/stb_image.h
popd
cd ~/Documents
git clone https://github.com/Overv/VulkanTutorial.git
cd VulkanTutorial/code
cmake -S . -B build -DCMAKE_INSTALL_PREFIX:PATH="/usr/local" -DSTB_INCLUDEDIR:PATH="/usr/lib/stb"
cd build
make

BackBlaze Backup Script

Dec 23, 2024AustinLeath

0 likes • 16 views

#!/bin/bash
# RCLONE BACKUP SCRIPT (using ionice)
# Type crontab -e and copy the line below without the #
# 0 0 * * * ionice -c 3 /home/owner/backup.sh >/dev/null 2>&1
nowdate=$(date -u)
# OPTIONS
WEBHOOK="YOUR_DISCORD_WEBHOOK_LINK_HERE"
LOGFILE="/root/backup.log"
FROM="/path/where/you/backup/from"
TO="backblaze:BucketName/FolderName"
SERVERNAME="Server Name"
echo "$SERVERNAME started a backup - $nowdate" | tee -a $LOGFILE
curl --data "content=$SERVERNAME started a backup - $nowdate" $WEBHOOK | tee -a $LOGFILE && echo "" >> $LOGFILE
if pidof -o %PPID -x "backup.sh"
then
echo "Failed backup attempt on $SERVERNAME - $nowdate (rclone already running)" | tee -a $LOGFILE
curl --data "content=Failed backup attempt on $SERVERNAME - $nowdate (rclone already running)" $WEBHOOK | tee -a $LOGFILE
exit 1
fi
rclone sync $FROM $TO -P --b2-hard-delete --stats 5s --progress | sed 's/Transferred:/\n\nTransferred:/' | tee -a $LOGFILE
enddate=$(date -u)
endtime=$(date +'%T')
echo "Completed backup on $SERVERNAME - $enddate" | tee -a $LOGFILE
curl -F "content=Completed backup on $SERVERNAME - $enddate" -F upload=@"$LOGFILE" $WEBHOOK | tee -a $LOGFILE
if [ -f $LOGFILE ]
then
rm $LOGFILE
fi

makeHeaderTags.sh

Feb 5, 2024LeifMessinger

0 likes • 10 views

#!/bin/bash
# Recursively find all .svelte files in the current directory and its subdirectories
find . -type f -name "*.svelte" -o -name "*.html" -o -name "*.htm" | while read file; do
# Replace all h1 tags with the specified format
sed -i 's/<h1>\(.*\)<\/h1>/<h1 id="\1">\1<\/h1>/g' "$file"
# Replace all h2 tags with the specified format
sed -i 's/<h2>\(.*\)<\/h2>/<h2 id="\1">\1<\/h2>/g' "$file"
# Remove whitespace from the id attribute value
for i in {0..10} ; do
sed -i 's/\(id="[^"]*\)\W\([^"]*"\)/\1\2/g' "$file"
done
done

cppToStdout.sh

Nov 17, 2021LeifMessinger

0 likes • 6 views

#!/bin/bash
#Takes command line arguments and pulls the header files.
#Good for checking if the function you want is in the header or not.
#cppToStdout.sh "time.h"
while [ "$1" != "" ]; do
echo "#include<$1>" | g++ -x c++ -E -
shift
done

Nginx Serve Storybook

Oct 17, 2023C 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