Remove some now-unused scripts
- ID
0dba565- date
2023-11-26 01:47:02+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
8ede441- message
Remove some now-unused scripts- changed files
8 files, 267 deletions
Changed files
_file_by_year (349) → _file_by_year (0)
diff --git a/_file_by_year b/_file_by_year
deleted file mode 100755
index e9e40e0..0000000
--- a/_file_by_year
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/env bash
-# This is a shortcut for 'mv' that I use for filing documents.
-#
-# It files documents into per-year subdirectories of a given directory.
-#
-# See e.g. 'fun', 'screenshot', 'wellcome'
-
-set -o errexit
-set -o nounset
-
-DIRNAME="$1"
-YEAR="$(date +"%Y")"
-
-mkdir -p "$DIRNAME/$YEAR"
-
-for f in "${@:2}"
-do
- mv "$f" "$DIRNAME/$YEAR"
-done
ds (1308) → ds (0)
diff --git a/ds b/ds
deleted file mode 100755
index 89f7e75..0000000
--- a/ds
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/env bash
-# This is an alias for adding files to docstore
-# (https://github.com/alexwlchan/docstore)
-#
-# When I save a file, I have to supply four bits of information:
-#
-# 1) what's the path to the file?
-# 2) where did I download it from?
-# 3) what's the title of the file?
-# 4) what's it tagged with?
-#
-# This fills in (1) and (2) automatically, so I just have to fill in
-# (3) and (4).
-#
-# I get the frontmost URL from my web browser with https://github.com/alexwlchan/safari.rs;
-# I get my latest download with another script in this repo.
-
-set -o errexit
-set -o nounset
-
-LATEST_DOWNLOAD="$(latest_download)"
-MTIME=$(date -r "$LATEST_DOWNLOAD" "+%s")
-NOW=$(date +%s)
-
-echo "$LATEST_DOWNLOAD"
-
-# Do a sense check: is this a file I downloaded recently?
-#
-# If not, I may be running `ds` before I've downloaded the file, which
-# might mean I save the wrong thing -- warn against this.
-if (( NOW - MTIME > 1000 ))
-then
- echo "Latest download '$LATEST_DOWNLOAD' seems quite old, are you sure this is what you want?"
- exit 1
-fi
-
-if [[ "$LATEST_DOWNLOAD" == *.opml ]]
-then
- echo "Latest download '$LATEST_DOWNLOAD' doesn't look like a docstore file, are you sure this is what you want?"
- exit 1
-fi
-
-docstore add \
- "$(latest_download)" \
- --source_url=$(~/.cargo/bin/safari url) \
- "$@"
fix_scala_imports (3011) → fix_scala_imports (0)
diff --git a/fix_scala_imports b/fix_scala_imports
deleted file mode 100755
index 370ada5..0000000
--- a/fix_scala_imports
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/env python3
-"""
-This is to reduce diff churn in the Scala code I write at Wellcome.
-
-The autoformatter that runs against PRs prefers long imports to be split
-across multiple lines, e.g.
-
- import weco.messaging.typesafe.{
- AlpakkaSqsWorkerConfigBuilder,
- SNSBuilder,
- SQSBuilder
- }
-
-but whenever IntelliJ touches imports, it "fixes" them onto a single line:
-
- import weco.messaging.typesafe.{AlpakkaSqsWorkerConfigBuilder, SNSBuilder, SQSBuilder}
-
-This churn makes diffs harder to follow; this script splits imports back
-onto multiple lines.
-
-* Why not run autoformatting locally?
- Because Scala autoformatting is sloooooow and this is the main thing
- I usually want to fix.
-
-* Why not fix your IntelliJ settings?
- Because I have no idea how to; writing a simple text editing script
- was a time-bounded exercise in a way that editing IntelliJ settings isn't.
-
-"""
-
-
-import os
-import re
-import subprocess
-
-
-def git(*cmd):
- return subprocess.check_output(["git"] + list(cmd)).decode("utf8").strip()
-
-
-def changed_files():
- root = git("rev-parse", "--show-toplevel")
- for cmd in [
- ["diff", "--name-only"],
- ["diff", "--name-only", "--cached"],
- ]:
- for relpath in git(*cmd).split():
- yield os.path.join(root, relpath)
-
-
-if __name__ == "__main__":
- for path in changed_files():
- print(f"Editing {path}")
- try:
- with open(path) as srcfile:
- src_lines = list(srcfile)
- except FileNotFoundError:
- continue
-
- while True:
- has_edits = False
-
- for lineno, line in enumerate(src_lines):
- if not line.startswith("import"):
- continue
-
- if len(line.strip()) <= 80:
- continue
-
- if "{" not in line:
- continue
-
- if line.strip().endswith("{"):
- continue
-
- m = re.match(
- r"^import (?P<package>[a-zA-Z0-9\._]+)\{(?P<imports>[a-zA-Z0-9, ]+)\}",
- line,
- )
- if m is None:
- print("???", line)
- continue
- assert m is not None, (path, lineno, line)
-
- package = m.groupdict()["package"]
- imports = [im.strip() for im in m.groupdict()["imports"].split(",")]
-
- src_lines[lineno] = f"import {package}{{\n"
- for idx, im in enumerate(imports, start=1):
- if idx == len(imports):
- src_lines.insert(lineno + idx, f" {im}\n")
- else:
- src_lines.insert(lineno + idx, f" {im},\n")
-
- src_lines.insert(lineno + len(imports) + 1, "}\n")
-
- has_edits = True
- break
-
- if not has_edits:
- break
-
- with open(path, "w") as srcfile:
- srcfile.write("".join(src_lines))
fun (294) → fun (0)
diff --git a/fun b/fun
deleted file mode 100755
index 12af596..0000000
--- a/fun
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env bash
-# This is a shortcut for 'mv' that I use for filing documents.
-#
-# I have a 'fun' directory that's divided into years where I put fun stuff;
-# running `fun nameofdocument.pdf` will move it to the appropriate folder
-# for the current year.
-
-_file_by_year ~/Documents/fun "$@"
\ No newline at end of file
greedy_tar_gz (1400) → greedy_tar_gz (0)
diff --git a/greedy_tar_gz b/greedy_tar_gz
deleted file mode 100755
index ac7273c..0000000
--- a/greedy_tar_gz
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/env python3
-"""
-This is a "greedy" script to compress a directory into a tar.gz.
-
-I use it when I'm in a space-constrained environment (e.g. AWS CloudShell)
-where I have enough space to hold the uncompressed files OR the compressed
-archive, but not both. It compresses the directory and deletes the
-original files as it goes.
-
-Use with caution; I only use it when I can easily recreate the original.
-
-"""
-
-import os
-import sys
-import tarfile
-
-import tqdm
-
-
-def get_file_paths_under(root=".", *, suffix=""):
- """Generates the paths to every file under ``root``."""
- if not os.path.isdir(root):
- raise ValueError(f"Cannot find files under non-existent directory: {root!r}")
-
- for dirpath, _, filenames in os.walk(root):
- for f in filenames:
- if os.path.isfile(os.path.join(dirpath, f)) and f.lower().endswith(suffix):
- yield os.path.join(dirpath, f)
-
-
-if __name__ == '__main__':
- try:
- dirname = sys.argv[1]
- except IndexError:
- sys.exit(f"Usage: {__file__} <DIRNAME>")
-
- if not os.path.isdir(dirname):
- sys.exit(f"Usage: {__file__} <DIRNAME>")
-
- with tarfile.open(os.path.basename(dirname.strip('/')) + '.tar.gz', 'w:gz') as tar:
- for path in tqdm.tqdm(list(get_file_paths_under(dirname))):
- tar.add(path, arcname=os.path.relpath(path, dirname), recursive=True)
- os.unlink(path)
\ No newline at end of file
pip_add (555) → pip_add (0)
diff --git a/pip_add b/pip_add
deleted file mode 100755
index 0e73094..0000000
--- a/pip_add
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env bash
-
-set -o errexit
-set -o nounset
-
-for ARG in "$@"
-do
- case "$ARG" in
- # Although I import the package as 'import flask', the name of the
- # package that gets installed with pip is 'Flask'.
- flask)
- NAME="Flask"
- ;;
-
- *)
- NAME="$ARG"
- ;;
- esac
-
- # Add the new library to requirements.in
- pip freeze | grep "$NAME" >> requirements.in
-done
-
-# Now sort the file
-cat requirements.in | sort | uniq > requirements.in.tmp
-mv requirements.in.tmp requirements.in
-
-# And rebuild the requirements.txt
-pip-compile
screenshot (335) → screenshot (0)
diff --git a/screenshot b/screenshot
deleted file mode 100755
index bbdfe5c..0000000
--- a/screenshot
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env bash
-# This is a shortcut for 'mv' that I use for filing documents.
-#
-# I have a 'screenshots' directory that's divided into years; running
-# `screenshot image.png` will move it to the appropriate folder for
-# the current year.
-#
-# See also: 'fun', 'wellcome'
-
-_file_by_year "/Volumes/Media (Sapphire)/screenshots" "$@"
yt_dl_mp3 (158) → yt_dl_mp3 (0)
diff --git a/yt_dl_mp3 b/yt_dl_mp3
deleted file mode 100755
index bdc58a4..0000000
--- a/yt_dl_mp3
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env bash
-# A shortcut for downloading audio tracks using yt-dlp (or youtube-dl).
-
-set -o errexit
-set -o nounset
-
-yt-dlp -x --audio-format=mp3 "$@"