From e2283c6d96b5ba1ee486e429fcd680d27aa86ac7 Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Tue, 26 Nov 2024 20:21:23 -0500 Subject: [PATCH 1/5] Theme update --- themes/pulp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/pulp b/themes/pulp index 70f42b3..864dce1 160000 --- a/themes/pulp +++ b/themes/pulp @@ -1 +1 @@ -Subproject commit 70f42b3d844d63b5833d983a9efa2dc55d145875 +Subproject commit 864dce1ff9a5ab3a3160a4ab835abadd9589d45a From 303a045f879da2c97a1545285d4e124fbf857f42 Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Tue, 26 Nov 2024 20:21:36 -0500 Subject: [PATCH 2/5] Added image --- static/files/images/blog/focalsets.svg | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 static/files/images/blog/focalsets.svg diff --git a/static/files/images/blog/focalsets.svg b/static/files/images/blog/focalsets.svg new file mode 100644 index 0000000..94bb5af --- /dev/null +++ b/static/files/images/blog/focalsets.svg @@ -0,0 +1,4 @@ + + + +
m(c) = .5
m({w, c}) = 0.25
m({w, c, g}) = 0.25
\ No newline at end of file From 6173816ab381cd4a028d18c060ce51be7266d9cc Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Tue, 26 Nov 2024 20:21:42 -0500 Subject: [PATCH 3/5] New post --- content/blog/please-monitor-disk-usage.md | 108 ++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 content/blog/please-monitor-disk-usage.md diff --git a/content/blog/please-monitor-disk-usage.md b/content/blog/please-monitor-disk-usage.md new file mode 100644 index 0000000..e07a02c --- /dev/null +++ b/content/blog/please-monitor-disk-usage.md @@ -0,0 +1,108 @@ +--- +title: "Please monitor disk usage" +date: 2024-11-26T19:59:10-05:00 +draft: false +tags: [] +math: false +medium_enabled: false +--- + +You know one of the worst errors to deal with on Linux? + +> No space left on device + +Why? Because recovery becomes really annoying. Depending on your luck, Linux may try to cache to disk even when it's not possible causing several commands to fail. + +If you're already in this situation, the best thing you can do is try to locate files to remove. You can run `du -sh *` in any given directory to see the sizes of files and subfolders. + +Common places that hold temporary files which can likely be removed are: + +- `/tmp` +- `~/.cache` + +An even better solution is to not get into this situation in the first place. For that, I introduce a bash script which sends a notification when the disk is getting full! + +In order to see the amount of available and total space for a given `$MOUNTPOINT` (for example, `/`), we run the following: + +```bash +available_space=$(df "$MOUNTPOINT" | awk 'NR==2 {print $4}') +total_space=$(df "$MOUNTPOINT" | awk 'NR==2 {print $2}') +``` + +Add a couple if statements and we have ourselves a full-blown script: + +```bash +#!/bin/sh + +set -o errexit +set -o nounset + +MAX_USAGE_PERCENT=90 + +if [ -z "$MOUNTPOINT" ]; then + echo "MOUNTPOINT variable not set or empty" + exit 1 +fi + +# Get the available and total disk space for the specified mount point +available_space=$(df "$MOUNTPOINT" | awk 'NR==2 {print $4}') +total_space=$(df "$MOUNTPOINT" | awk 'NR==2 {print $2}') + +# Check if the df command was successful +if [ -z "$available_space" ] || [ -z "$total_space" ]; then + echo "Error: Could not retrieve disk space for $MOUNTPOINT" + sendMsg "Error: Could not retrieve disk space for $MOUNTPOINT" + exit 1 +fi + +usage_percent=$(( (total_space - available_space) * 100 / total_space )) + +if [ $usage_percent -ge $MAX_USAGE_PERCENT ]; then + host_name=$(hostname) + echo "Low Disk on $host_name at mountpoint $MOUNTPOINT. Currently using ${usage_percent}% of available space." + sendMsg "Low Disk on $host_name at mountpoint $MOUNTPOINT. Currently using ${usage_percent}% of available space." +fi + +echo "Mountpoint $MOUNTPOINT is currently using ${usage_percent}% of available space." +``` + +The only part left undefined here is the `sendMsg` function. For me, I send a [webhook notification](https://brandonrozek.com/blog/webhook-notifications-on-systemd-service-failure/) to Zulip in order to both get notified and have a log of these messages. + +To have this check regularly automatically, we create a systemd service and timer files. + +`/etc/systemd/system/lowdiskcheck.service` + +```ini +[Unit] +Description=Check for low disk space +Requires=network-online.target +Wants= + +[Service] +Type=oneshot +# Feel free to change the mountpoint to one that you care about +Environment=MOUNTPOINT=/home +ExecStart=/usr/local/bin/lowdiskcheck.sh + +[Install] +WantedBy=multi-user.target +``` + +`/etc/systemd/system/lowdiskcheck.timer` + +```ini +[Unit] +Description=Check for low disk space daily +[Timer] +OnCalendar=daily +Persistent=true +[Install] +WantedBy=timers.target +``` + +Then enable the timer, + +```bash +sudo systemctl enable lowdiskcheck.timer +``` + From 0b58f4a59291fb49c25f6de3edac83385d8bd53a Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Tue, 26 Nov 2024 20:27:34 -0500 Subject: [PATCH 4/5] Vale copyedit --- content/blog/please-monitor-disk-usage.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/blog/please-monitor-disk-usage.md b/content/blog/please-monitor-disk-usage.md index e07a02c..4ecc597 100644 --- a/content/blog/please-monitor-disk-usage.md +++ b/content/blog/please-monitor-disk-usage.md @@ -11,18 +11,18 @@ You know one of the worst errors to deal with on Linux? > No space left on device -Why? Because recovery becomes really annoying. Depending on your luck, Linux may try to cache to disk even when it's not possible causing several commands to fail. +Why? Because recovery becomes really annoying. Depending on your luck, Linux may try to cache to disk even when it's impossible causing quite a few commands to fail. If you're already in this situation, the best thing you can do is try to locate files to remove. You can run `du -sh *` in any given directory to see the sizes of files and subfolders. -Common places that hold temporary files which can likely be removed are: +Common places that hold temporary files which may be removable are: - `/tmp` - `~/.cache` An even better solution is to not get into this situation in the first place. For that, I introduce a bash script which sends a notification when the disk is getting full! -In order to see the amount of available and total space for a given `$MOUNTPOINT` (for example, `/`), we run the following: +To see the amount of available and total space for a given `$MOUNTPOINT` (for example, `/`), we run the following: ```bash available_space=$(df "$MOUNTPOINT" | awk 'NR==2 {print $4}') @@ -66,7 +66,7 @@ fi echo "Mountpoint $MOUNTPOINT is currently using ${usage_percent}% of available space." ``` -The only part left undefined here is the `sendMsg` function. For me, I send a [webhook notification](https://brandonrozek.com/blog/webhook-notifications-on-systemd-service-failure/) to Zulip in order to both get notified and have a log of these messages. +The only part left undefined here is the `sendMsg` function. For me, I send a [webhook notification](https://brandonrozek.com/blog/webhook-notifications-on-systemd-service-failure/) to Zulip to both get notified and have a log of these messages. To have this check regularly automatically, we create a systemd service and timer files. From 77232e4af337d13901bfb921b8d4e946d6c7b82b Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Tue, 26 Nov 2024 21:03:48 -0500 Subject: [PATCH 5/5] New Post --- content/blog/vale-linter-human-prose.md | 75 +++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 content/blog/vale-linter-human-prose.md diff --git a/content/blog/vale-linter-human-prose.md b/content/blog/vale-linter-human-prose.md new file mode 100644 index 0000000..3b9ac5f --- /dev/null +++ b/content/blog/vale-linter-human-prose.md @@ -0,0 +1,75 @@ +--- +title: "Linting my blog posts with Vale" +date: 2024-11-27T16:29:30-05:00 +draft: false +tags: [] +math: false +medium_enabled: false +--- + +How do you write *good*? + +For some, the answer is Grammarly. This, however, falls short to me for the following reasons: + +- Needing to rely on some third party service. Seriously, what if I want to draft my blog posts without Internet? +- Not configurable. Leave me alone, sometimes I like writing **my way**. +- Where's my beautiful terminal application? + +I use [Vale](https://vale.sh/) ([GitHub](https://github.com/errata-ai/vale)) a linter for human prose. It runs locally on my computer ✔, is configurable by defining a rule set ✔, and offers not only a beautiful CLI application ✔, but even offers integrations to editors like VSCode. + +To provide useful feedback, we'll need a strong collection of rules. Like a crazy person, I went onto the [Vale package hub](https://vale.sh/hub/) and looked at the rules of many different packages and compiled the ones I liked into [my own package](https://github.com/brandon-rozek/vale) for us to use. + +All we need to do is specify the package in our Vale config. To see where this lives, you can run `vale ls-dirs`. For example, on my computer it is at `~/.config/vale/.vale.ini` + +```ini +StylesPath = /home/rozek/.local/share/vale/styles + +Vocab = brozek + +MinAlertLevel = suggestion + +Packages = https://github.com/Brandon-Rozek/vale/releases/download/0.1.0/brozek.zip + +[*] +BasedOnStyles = Vale, brozek +``` + +By default, Vale includes a spell-checker. As a technical writer, I often talk about products which Vale claims are typos. We can force Vale to not complain by creating a [Vocabulary](https://vale.sh/docs/topics/vocab/) (fancy word for dictionary). + +`/config/vocabularies/brozek/accept.txt` + +``` +BTRFS +[Bb]oolean +systemd +Zulip +``` + +These vocabularies are case-sensitive, which while may seen like a weird choice, I find useful in keeping capitalization consistent. To specify that something is not case sensitive you'll need to put square brackets around the upper and lower-case letter. For example, case-insensitive b is `[Bb]`. + +With all this configured, we can then sync the configuration rules to our machine. + +```bash +vale sync +``` + +Then, lint a blog post! + +```bash +vale vale-linter-human-prose.md +``` + +``` + vale-linter-human-prose.md + 14:48 warning Remove 'Seriously' if it's not brozek.Adverbs + important to the meaning of + the statement. + 20:70 suggestion Try to keep sentences short (< brozek.SentenceLength + 30 words). + 48:91 warning Remove 'really' if it's not brozek.Adverbs + important to the meaning of + the statement. +``` + +From there you can choose which suggestions to keep and which to ignore ;) +