From c476cab7d0d314bab206681ac43d56907dc5951b Mon Sep 17 00:00:00 2001 From: thomasabishop Date: Wed, 13 Aug 2025 16:58:17 +0100 Subject: [PATCH] chore: remove unnecessary scripts --- scripts/auto_save.sh | 34 --------------------------------- scripts/tidy_filenames.sh | 21 -------------------- utils/flatten_md_link_paths.py | 35 ---------------------------------- utils/random_revision_topic.sh | 19 ------------------ utils/remove_frontmatter.py | 28 --------------------------- utils/rename_img_links.sh | 11 ----------- 6 files changed, 148 deletions(-) delete mode 100755 scripts/auto_save.sh delete mode 100755 scripts/tidy_filenames.sh delete mode 100644 utils/flatten_md_link_paths.py delete mode 100755 utils/random_revision_topic.sh delete mode 100644 utils/remove_frontmatter.py delete mode 100755 utils/rename_img_links.sh diff --git a/scripts/auto_save.sh b/scripts/auto_save.sh deleted file mode 100755 index fd55424..0000000 --- a/scripts/auto_save.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -# Automatically pull and commit changes to remote after generating Neuron static -# site - -# USER=thomas -# export XDG_RUNTIME_DIR=/run/user/1000 -# source /home/thomas/.env - -SLACK_NOTIFIER="${HOME}/repos/utilities/slack_notifier.sh" -NEURON_GENERATOR="${HOME}/repos/neuron-zk-generator/dist/neuron-zk-generator" - -cd "${HOME}/repos/eolas" - -echo "Checking for changes..." -git pull >/dev/null 2>&1 -changes_exist="$(git status --porcelain | wc -l)" - -# If no changes, exit. Else commit and push with timestamp -if [ "$changes_exist" -eq 0 ]; then - echo "No changes, exiting" - exit 0 -fi - -# Run Neuron generator -$NEURON_GENERATOR - -echo "Changes exist. Updating remote..." -git pull >/dev/null 2>&1 -git add . -git commit -q -m "Autosave: $(date +"%Y-%m-%d %H:%M:%S")" -git push - -$SLACK_NOTIFIER "eolas" 'success' 'eolas: auto-save executed' diff --git a/scripts/tidy_filenames.sh b/scripts/tidy_filenames.sh deleted file mode 100755 index 7e2e9dd..0000000 --- a/scripts/tidy_filenames.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# Convert hypens in file names to underscores - -main() { - find . -depth -name '*.md' | while read fname; do - new_fname=$(echo "$fname" | tr " -" "_") - if [ -e "$new_fname" ]; then - continue - echo "No filename change needed" - else - echo "Creating new file $new_fname to replace $fname" - mv "$fname" "$new_fname" - fi - done -} - -# Run and pipe errors and feedback to logfile - -# &>/dev/null -main diff --git a/utils/flatten_md_link_paths.py b/utils/flatten_md_link_paths.py deleted file mode 100644 index e121e48..0000000 --- a/utils/flatten_md_link_paths.py +++ /dev/null @@ -1,35 +0,0 @@ -# Flatten markdown links such that depth is reduced to /link.md - -import os -import re - - -def trim_markdown_links(filepath): - with open(filepath, "r") as file: - content = file.read() - - # Regular expression to match Markdown links - pattern = r"\[([^\]]+)\]\(([^)]+)\)" - links = re.findall(pattern, content) - - # For each link, extract the filename and replace the link - for text, link in links: - link_filename = os.path.basename(link) - content = content.replace(f"[{text}]({link})", f"[{text}]({link_filename})") - - # Write the modified content back to the file - with open(filepath, "w") as file: - file.write(content) - - -def process_directory(directory): - for filename in os.listdir(directory): - if filename.endswith(".md"): - trim_markdown_links(os.path.join(directory, filename)) - - -# Usage -# process_directory('/path/to/your/directory') - -# Usage -process_directory("/home/thomas/repos/eolas/zk") diff --git a/utils/random_revision_topic.sh b/utils/random_revision_topic.sh deleted file mode 100755 index 6f27324..0000000 --- a/utils/random_revision_topic.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# This script returns a random topic for me to revise - -# It is aliased to cs-revise in .zshrc - -# Choose source directories... -directories_to_parse="../Computer_Architecture ../Databases ../Electronics_and_Hardware ../Operating_Systems ../Programming_Languages ../DevOps" - -# Return array of all files belonging to source dirs... -for ele in $directories_to_parse; do - file_matches+=( $(find $ele -name "*.md" -type f) ) -done - -# Generate a random integer between 0 and the match array length... -random_file_index=$(( $RANDOM % ${#file_matches[@]} + 0 )) - -# Return file matching that index... -echo "Revise this topic: ${file_matches[$random_file_index]}" diff --git a/utils/remove_frontmatter.py b/utils/remove_frontmatter.py deleted file mode 100644 index 373b37c..0000000 --- a/utils/remove_frontmatter.py +++ /dev/null @@ -1,28 +0,0 @@ -# Remove 'title' and 'categories' from Yaml frontmatter of old entries -import os -import re - -# Define the directory -directory = "/home/thomas/repos/eolas/zk" - -# Define the regex patterns -title_pattern = re.compile(r"title:.*\n") -categories_pattern = re.compile(r"categories:.*\n(\s*-.*\n)*") - -# Iterate over all files in the directory -for filename in os.listdir(directory): - # Check if the file is a markdown file - if filename.endswith(".md"): - # Open the file - with open(os.path.join(directory, filename), "r+") as file: - # Read the file content - content = file.read() - # Remove the 'title' and 'categories' sections - content = title_pattern.sub("", content) - # content = categories_pattern.sub("", content) - # Seek to the beginning of the file - file.seek(0) - # Write the modified content back to the file - file.write(content) - # Truncate the file to remove any remaining old content - file.truncate() diff --git a/utils/rename_img_links.sh b/utils/rename_img_links.sh deleted file mode 100755 index dfb6229..0000000 --- a/utils/rename_img_links.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# Replace all instances of `img` in Markdown image links with `_img` (to reflect new directory structure) - -find /home/thomas/repos/eolas/ -type f -name "*.md" | while -read file; do - sed -i 's/\/_img\//\/img\//g' $file -done - - -