Skip to main content

credit.sh

Oct 26, 2021LeifMessinger
Loading...

More Shell Posts

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

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."

Check For File

Aug 7, 2023C 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

Useful NVM Commands

Mar 20, 2023C S

0 likes • 0 views

// check version
node -v || node --version
// list installed versions of node (via nvm)
nvm ls
// install specific version of node
nvm install 6.9.2
// set default version of node
nvm alias default 6.9.2
// switch version of node
nvm use 6.9.1

NPM Workspaces Commands

Aug 16, 2023C S

0 likes • 6 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

githubSetSSH.sh

Sep 9, 2023LeifMessinger

0 likes • 3 views

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