Remove obsolete

This commit is contained in:
Jeffrey Serio 2024-07-19 20:21:05 -05:00
parent bc2bb06d6f
commit 01f8853737
13 changed files with 0 additions and 336 deletions

View File

@ -1,15 +0,0 @@
#!/usr/bin/env bash
SYNC_DIR="${HOME}/sync"
archive_maybe=(
"${HOME}/sync/org"
"${HOME}/sync/org-roam"
"${HOME}/sync/sites"
)
for dir in "${archive_maybe[@]}"; do
if [ "$(find "$dir" -type f -mtime -1 | wc -l)" -gt 0 ]; then
create-archive "$dir"
mv -v "$dir-$(date '+%Y%m%d').tar.gz" "${SYNC_DIR}/archived/"
fi
done

View File

@ -1,133 +0,0 @@
#!/usr/bin/env python3
#
# This little script makes it easy to Archive All The Things.
# It prints a list of URLs from fandom wiki pages to stdout.
#
# Stdout can then be redirected to a plaintext file with e.g:
# `get-fandom-wiki-urls cyberpunk > ~/downloads/cyberpunk-wiki-urls.txt`
#
# These URLs can then be imported directly into ArchiveBox. Each URL will
# be a page of the local sitemap. The local sitemap is a list of wiki pages
# in alphabetical order. Importing the URLs scraped by the script into
# ArchiveBox with a depth of '1' will pull every URL one hop away, so every
# wiki page listed in the local sitemap will be archived.
#
# This script wouldn't be necessary if there was a way to view the entire
# local sitemap in one html page. Then all you'd have to do is import the
# URL for the local sitemap into ArchiveBox with a depth of '1'. As far I
# know there is no way to get this view of the local sitemap. For some
# unknown reason the Wiki fandom site developers didn't design the frontend
# to enable that.
#
# LICENSE
# This is free and unencumbered software released into the public domain.
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
# THE SOFTWARE IS PROVIDED \AS IS\, WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# For more information, please refer to <https://unlicense.org>
import sys
import requests
from bs4 import BeautifulSoup
def get_hop0_urls(fandom: str) -> list():
starting_url = "https://" + fandom + ".fandom.com/wiki/Local_Sitemap"
hop0_urls = [starting_url]
while True:
reqs = requests.get(starting_url)
soup = BeautifulSoup(reqs.text, "html.parser")
mw_allpages_nav = soup.find_all("div", {"class": "mw-allpages-nav"})[0]
if (
len(mw_allpages_nav.find_all("a")) < 2
and "Next page" not in mw_allpages_nav.find_all("a")[0].get_text()
):
break
else:
if len(mw_allpages_nav.find_all("a")) < 2:
starting_url = (
"https://"
+ fandom
+ ".fandom.com"
+ mw_allpages_nav.find_all("a")[0].get("href")
)
else:
starting_url = (
"https://"
+ fandom
+ ".fandom.com"
+ mw_allpages_nav.find_all("a")[1].get("href")
)
hop0_urls.append(starting_url)
return hop0_urls
def get_hop1_urls(hop0_urls: list) -> list():
hop1_urls = list()
for url in hop0_urls:
reqs = requests.get(url)
soup = BeautifulSoup(reqs.text, "html.parser")
fandom = url.split(sep="/wiki")[0]
for item in soup.find_all("a"):
if item.get("href") and item.get("href").startswith("/wiki"):
hop1_urls.append(fandom + item.get("href"))
return hop1_urls
def help_message():
supported_wikis = ["cyberpunk", "dishonored", "dragonage", "forgottenrealms", "masseffect", "residentevil"]
print("Supply a fandom wiki name as arg1.\n")
print("Currently supported wikis:")
for wiki in supported_wikis:
print("- %s" % wiki)
if __name__ == "__main__":
if len(sys.argv) > 1:
match sys.argv[1]:
case "cyberpunk":
urls = get_hop1_urls(get_hop0_urls("cyberpunk"))
case "dishonored":
urls = get_hop1_urls(get_hop0_urls("dishonored"))
case "dragonage":
urls = get_hop1_urls(get_hop0_urls("dragonage"))
case "forgottenrealms":
urls = get_hop1_urls(get_hop0_urls("forgottenrealms"))
case "masseffect":
urls = get_hop1_urls(get_hop0_urls("masseffect"))
case "residentevil":
urls = get_hop1_urls(get_hop0_urls("residentevil"))
case _:
help_message()
for url in urls:
print(url)
else:
help_message()

39
hn
View File

@ -1,39 +0,0 @@
#!/usr/bin/env bash
# LICENSE
# Copyright 2022 Jeffrey Serio <hyperreal@fedoraproject.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
if ! test -x "$(command -v gum)"; then
echo "Missing dependency: gum"
echo "See github.com/charmbracelet/gum"
exit 1
fi
selection=$(python3 <(cat <<EOF
import feedparser
HNFeed = feedparser.parse("https://hnrss.org/newest")
class bcolors:
HEADER = "\033[34m"
ENDC = "\033[0m"
for item in HNFeed.entries:
print(f"[{item.title}]({item.links[0].href})")
EOF
) | gum format -t "markdown" | gum choose --limit=1)
xdg-open "$(echo "$selection" | grep -o 'http[s]\?://[^ ]\+')" >/dev/null || echo "$selection"

View File

@ -1,16 +0,0 @@
#!/usr/bin/env bash
source /usr/local/etc/matrix-webhook-env
for url in "${site_urls[@]}"; do
status_code=$(curl -o /dev/null -s -w "%{http_code}" "$url")
if [ "$status_code" = 200 ] && ! [ "$status_code" == "302" ]; then
if ! /usr/local/bin/send-matrix-webhook "$room_id" "$url: ✅ UP"; then
echo "Error sending webhook to Matrix"
exit 1
fi
else if ! /usr/local/bin/send-matrix-webhook "$room_id" "$url: ❌ DOWN"; then
echo "Error sending webhook to Matrix"
exit 1
fi
done

View File

@ -1,8 +0,0 @@
#!/usr/bin/env bash
go install golang.org/x/tools/gopls@latest
go install github.com/fatih/gomodifytags@latest
go install github.com/cweill/gotests/...@latest
go install github.com/x-motemen/gore/cmd/gore@latest
go install golang.org/x/tools/cmd/guru@latest
go install github.com/gohugoio/hugo@latest

View File

@ -1,9 +0,0 @@
#!/usr/bin/env bash
pipx install --include-deps ansible
pipx install black
pipx install pyflakes
pipx install isort
pipx install pipenv
pipx install nose
pipx install pytest

View File

@ -1,8 +0,0 @@
#!/usr/bin/env bash
sudo npm install -g @catppuccin/inkcat
sudo npm install -g prettier
sudo npm install -g js-beautify
sudo npm install -g stylelint
sudo dnf install -y tidy

32
lispify
View File

@ -1,32 +0,0 @@
#!/bin/bash
# Check for an argument
if [ $# -eq 0 ]; then
echo "Usage: $0 filename"
exit 1
fi
# A function to convert a string to Lisp case, including converting spaces to a single dash
to_lisp_case() {
echo "$1" | awk '{ gsub(/[ _]+/, "-"); print tolower($0) }' | sed 's/[A-Z]/-\L&/g' | sed 's/^-//'
}
# The filename is the first argument
file="$1"
# Check if the file exists
if [ ! -f "$file" ]; then
echo "Error: File does not exist."
exit 1
fi
# Convert the filename to Lisp case
new_name=$(to_lisp_case "$file")
# Rename the file if the new name is different from the original
if [ "$file" != "$new_name" ]; then
mv -- "$file" "$new_name"
echo "File renamed to $new_name"
else
echo "File name is already in the desired format."
fi

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
FORWARDED_LOGS=$(sudo find /var/log -type f -name "forwarded-logs.log")
if [[ -n "$FORWARDED_LOGS" ]]; then
echo "$FORWARDED_LOGS" | xargs sudo lnav
else
echo "No forwarded logs found in /var/log"
exit 1
fi

View File

@ -1,7 +0,0 @@
#!/usr/bin/env bash
# Sometimes things get weird and you just have to do this
rm -rf "${HOME}/.config/emacs"
git clone --depth 1 https://github.com/doomemacs/doomemacs "${HOME}/.config/emacs"
"${HOME}/.config/emacs/bin/doom" install --force --verbose

View File

@ -1,3 +0,0 @@
#!/usr/bin/env bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

View File

@ -1,49 +0,0 @@
#!/usr/bin/env python
import json
import sys
import requests
def send_matrix_webhook(access_token, room_id, message, user_id_to_ping, matrix_server):
"""
Send a message to a Matrix room using a webhook.
:param access_token: The access token for Matrix API authentication.
:param room_id: The ID of the room where the message will be sent.
:param message: The message to be sent.
:param user_id_to_ping: The user to ping in the message.
:param matrix_server: The URL of the Matrix homeserver.
"""
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json",
}
full_message = f"{user_id_to_ping}: {message}"
data = {
"msgtype": "m.text",
"body": full_message,
"format": "org.matrix.custom.html",
"formatted_body": f'<a href="https://matrix.to/#/{user_id_to_ping}">{user_id_to_ping}</a>: {message}',
}
url = f"{matrix_server}/_matrix/client/r0/rooms/{room_id}/send/m.room.message"
response = requests.post(url, headers=headers, data=json.dumps(data))
if response.status_code == 200:
print("Message sent successfully.")
else:
print(f"Failed to send message. Status code: {response.status_code}")
if __name__ == "__main__":
access_token = ""
room_id = sys.argv[1]
message = sys.argv[2]
user_id_to_ping = ""
matrix_server = ""
send_matrix_webhook(access_token, room_id, message, user_id_to_ping, matrix_server)

View File

@ -1,7 +0,0 @@
#!/usr/bin/env bash
if ping -c 1 "$1"; then
autossh -M 0 "$1"
else
echo "Host not reachable"
fi