Skip to main content

codecatch.sh

Nov 14, 2021LeifMessinger
Loading...

More Shell Posts

LeetCode #192: Word Frequency

Oct 15, 2022CodeCatch

0 likes • 60 views

awk '\
{ for (i=1; i<=NF; i++) { ++D[$i]; } }\
END { for (i in D) { print i, D[i] } }\
' words.txt | sort -nr -k 2

unexpandDirectory.sh

May 13, 2023LeifMessinger

0 likes • 1 view

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

cpcmd.sh

Sep 29, 2021LeifMessinger

0 likes • 20 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
while [ -n "$1" ]; do
printf "scp \"$(whoami)@$(hostname):"
printf `readlink -f $1`
printf "\" .\n"
shift
done
else
echo "scp \"$(whoami)@$(hostname):$PWD/*\" ."
fi
#-----------EDIT:
#On the UNT cell machines, you have to do this script instead
#if [ -n "$1" ]; then
# while [ -n "$1" ]; do
# printf "scp $(whoami)@$(hostname).eng.unt.edu:"
# printf `readlink -f $1`
# printf " .\n"
# shift
# done
#else
# echo "scp $(whoami)@$(hostname).eng.unt.edu:$PWD/* ."
#fi

installVulkan.sh

Nov 8, 2021LeifMessinger

0 likes • 0 views

#!/bin/bash
#Installs the Vulkan library and other goodies. Works on Arch and Arch based distros. Needs pacman and makepkg
installVulkan(){
#Tries installing every linux package in existence
packages=( vulkan-tools libvulkan-dev vulkan-loader-devel vulkan-validation-layers spirv-tools mesa-vulkan-devel vulkan-validation-layers-devel )
for package in ${packages[*]}; do
sudo pacman --noconfirm -S $package
done
}
installLibraries(){
#All of these packages don't exist, so we have to download and install the AUR packages
#packages=( libglfw3-dev glfw-devel libglm glm-devel )
#for package in ${packages[*]}; do
# sudo pacman --noconfirm -S $package
#done
sudo git clone https://aur.archlinux.org/glfw-git.git /tmp/glfw-git
sudo chmod 777 /tmp/glfw-git
cd /tmp/glfw-git
makepkg -si
sudo git clone https://aur.archlinux.org/glm-git.git /tmp/glm-git
sudo chmod 777 /tmp/glm-git
cd /tmp/glm-git
makepkg -si
}
installShaderCompiler(){
#Basically installs glslc
sudo pacman -S shaderc
}
while true; do
select bruh in installVulkan installLibraries installShaderCompiler "exit"; do
$bruh
done
done

getDependencies.sh

Oct 30, 2020LeifMessinger

0 likes • 2 views

#!/bin/bash
#getDependencies.sh by Leif Messinger
grep -Po '#include\s*"\K.+(?=")' | while read -r line ; do
echo -n " $line"
./getDependencies.sh < $line
done

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