Skip to main content

Nginx Serve Storybook

Oct 17, 2023C S
Loading...

More Shell Posts

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

List all AWS EC2 Instances in all regions

Jul 29, 2024AustinLeath

0 likes • 6 views

for region in `aws ec2 describe-regions --output text | cut -f4`
do
echo -e "\nListing Instances in region:'$region'..."
aws ec2 describe-instances --query 'Reservations[*].Instances[*].{Instance:InstanceId,Subnet:SubnetId}' --region $region
done
#This script is to be used with any AWS CLI configured environment, it will list any EC2 instances and their associated subnet network ID's in JSON format

AWS CLI Locate ClientVPN

Sep 23, 2024AustinLeath

0 likes • 3 views

CLIENT_VPN_ID="cvpn-endpoint-xxxxxxxxxxxx"
for region in $(aws ec2 describe-regions --query "Regions[].RegionName" --output text); do
echo "Searching in region: $region"
aws ec2 describe-client-vpn-endpoints --region $region --query "ClientVpnEndpoints[?ClientVpnEndpointId=='$CLIENT_VPN_ID']" --output table
done

Symlink Desktop

Nov 18, 2022AustinLeath

0 likes • 0 views

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

unexpandDirectory.sh

May 13, 2023LeifMessinger

0 likes • 7 views

#!/bin/bash
# Turns 4 spaces into tabs.
# Mostly stolen from AI
# Define the directory to process
DIRECTORY=$1
TabCount=${2:-'4'} #Defaults to 4
# Check if directory is specified
if [ -z "$DIRECTORY" ]; then
echo "Error: Directory not specified."
exit 1
fi
# Check if directory exists
if [ ! -d "$DIRECTORY" ]; then
echo "Error: Directory does not exist."
exit 1
fi
# Find all files in directory and subdirectories
FILES=$(find "$DIRECTORY" -type f)
# Loop through each file and unexpand it
for FILE in $FILES; do
unexpand -t "$TabCount" "$FILE" > "$FILE.tmp"
mv "$FILE.tmp" "$FILE"
done
echo "Done!"

Find data-testids

Jul 8, 2024C S

0 likes • 16 views

#!/bin/bash
# Set the directory to search
DIRECTORY="src"
# Set the output file
OUTPUT_FILE="testids.txt"
# Clear the output file
> "$OUTPUT_FILE"
# Find all .tsx files in the specified directory and its subdirectories
find "$DIRECTORY" -type f -name "*.tsx" | while read -r FILE
do
# Search for instances of 'data-testid="testid"' and append them to the output file
grep -o 'data-testid="[^"]*"' "$FILE" >> "$OUTPUT_FILE"
# Search for instances of "'data-testid': 'testid'" and append them to the output file
grep -o "'data-testid': '[^']*'" "$FILE" >> "$OUTPUT_FILE"
done
echo "Search complete. Test IDs written to $OUTPUT_FILE."