I’m surprised that the further we get away from the election, the less threatening all of the bluster from Republicans about throwing away votes and stolen elections seems, and the more sad and pathetic it all looks. Not that I don’t think refusing to concede, and claiming Democrats stole the election without evidence, isn’t disgusting and will only make the next several years that much more miserable than they needed to be. Still, this thing which felt so threatening before feels so impotent and laughable now.

It’s Morning in America Again

Congratulations to everyone on electing Joe Biden President of the United States. No one knows what happens next, but a lot of people worked incredibly hard for this, and all of us have suffered in one way or another under the evil and malice of the last four years.

We all deserve to celebrate today, and then it’s time to win those Senate seats in Georgia.

The “Butt in Chair“ Writing Process

I’ve been reading all of John Scalzi’s Old Man’s War series of books — of which there are six — and was interested to read this article on his writing process.

I’ve been writing books now for 20 years and my experience really is that it’s not complicated, it’s just mostly sitting down and doing it, one day after another. Inspiration for me happens because I’m writing, not the other way around. In talking with other long-time writers, I’ve learned that’s how it works for most of us.

This reminds me a lot of when I read Stephen King’s autobiography or Anne Lamont’s Bird by Bird. I guess the “sit down each morning and write for a set amount of time“ method is a pretty common one among successful writers.

I think Trump was trying to project strength – or something – when he went back to the White House, but all I saw was a sick old man struggling to breath, and who was too caught up in his own macho act to not put himself and the people around him in unnecessary danger.

If you’re into video games and watching other people play them, come follow me on Twitch and hang out. I’ve been streaming things like Stardew Valley, Super Mario Maker 2, Splatoon 2, and Cities: Skylines (although I’m not too good yet).

This is the view out of my office window today. I guess ever year now the state will catch on fire and spew so much smoke into the atmosphere it won’t be safe to go outside? Something to get used to, I guess.

Smoke

Hyrule Warriors: Age of Calamity

Just watched the trailer for Hyrule Warriors: Age of Calamity, and I’ll definitely be playing this. I enjoyed the first game, but it felt disconnected from the world of Zelda. It’s exciting that the third-party developer that makes Warriors games are working closer with Nintendo this time to make something that ties into Breath of the Wild.

September

I feel like I just looked up and realized it was already September? I haven’t even blogged sine May. I could have sworn it was more recent than that. This whole year has been a blur.

What a time to be alive.

I’m doing a little project in my free time of re-reading K&R’s “The C Programming Language” and completing all of the exercises. It’s pretty time consuming, but I think worthwhile. Thankfully it’s a short book, so it’s not as daunting as it could be.

Really digging this sort-of-retro terminal theme and font combo I’ve got going. The theme is Gruvbox and the font is Input Mono Narrow Medium.

Even if you don’t care about the topic, this post on how to name servers is worth reading just to get his script which turns 8-bit images into ASCII art.

Things I’m Doing Since the Lockdown

Next week will be my third working from home, and there’s no clear date when it will end. I’m still not used to it, but I’m trying to do what I can to stay healthy while we’re all stuck at home. My time has consisted of at least a few of these each day.

  1. Going on at least one thirty minute walk a day.
  2. Trying to get my father to stay home.
  3. Playing guitar.
  4. Reading old books about old computers.
  5. Blogging and tweeting more.
  6. Trying to reassure people who are more worried than I am (and I’m pretty worried).
  7. Buying books from my favorite bookstore online so that hopefully they don’t go away forever.
  8. Realizing I have to keep in touch with friends better.

This is pretty rough. I have a lot thoughts, and a lot of feelings. It’s hard not to feel anxious all the time, and I can feel things like sleep quality decline.

I know that I’m incredibly lucky to have the kind of job I do and to be in the position I am in. I can’t stop thinking about all the people who aren’t so lucky though. It hurts to think about so many people suffering as much as I’m afraid they might.

BitBar: Easy Custom Menu Bar Apps

BitBar is a free app for macOS which — essentially — lets you create custom menu bar apps from shell scripts or other command line tools. If you can write a program or script (in Shell, Python, C, Swift) and print, you can put something in the menu bar. BitBar also lets you define how often it should automatically refresh each specific script.

My favorite thing I’ve made uses the speedtest-cli tool to refresh what my current download and upload speeds are and show colorized output based on the results.

2020 20 03 bitbar speedtest

The script might look strange if you’re not used to awk, but the main thing to know is that $2 (the second space separated for the line) represents the result number and $0 represents the whole line. So I’m grabbing the number and then printing the whole line with a color based on the value. Also, awk is cool and you should learn it.

#!/usr/bin/env zsh

echo "⏱"
echo "---"

/opt/local/bin/speedtest-cli |
awk '/Download/ {
        if ($2 < 25) {
            print $0, "|", "color=red"
        } else if ($2 < 90) {
            print $0, "|", "color=orange"
        } else {
            print $0, "|", "color=green"
        }
    }
    /Upload/ {
        if ($2 < 4) {
            print $0, "|", "color=red"
        } else if ($2 < 9) {
            print $0, "|", "color=orange"
        } else {
            print $0, "|", "color=green"
        }
    }'

More Parseable Output, Please.

Since reading Unix: A History and a Memoir by Brian Kerninghan (of K&R), I’ve been a little enamored with the idea of writing small command line tools. This article titled Hints for Writing Unix Tools hits on a bunch of things, and is worth reading, but one that really jumped out at me was this:

Output should be simple to parse and compose. This usually means representing each record as a single, plain-text formatted line of output whose columns are separated by whitespace. (No JSON, please.) Most venerable Unix tools—grep, sort, and sed among them—assume this.

Trying to parse the output of something like this on the command line is incredibly frustrating:

{
    myThing = "Blah"
    percent = 0.5
    ...
}

However, if the output is tab delimited:

myThing     blah
percent     0.5

Parsing it with Awk, sed, or other Unix filter tool can usually be done as easily as awk '/myThing/ { print $2 }'. I wish more tools paid attention to this. Maybe if you were writing Unix from scratch today, you’d have processes communicate using structured data (I think this is what PowerShell does?), but you have to work with the system you have.

Everyone knows that regular expressions are terrible, but what my theory presupposes, is that a large percentage of the “how can I parse …” questions on places like Stack Overflow that are solved by a crazy regex wouldn’t exist if more tools had sane output.

The Growth of Command Line Options, 1979-Present

This post shows the growth of arguments for a bunch of the most common Unix commands over time. The author demonstrates how we went from 99 in 1979 (Version 7 Unix), to 393 in 1996 (Slackware), to 700+ today (Ubuntu). After that, they make the argument that maybe that isn’t inherently a bad thing? Super thought provoking if you think about design or use a shell all day.

I don’t necessarily want to say I’m one of histories great innovators for having the idea to label power adapters with the name of the thing they came with… but I think it’s pretty smart.

Added a new pin to my denim jacket which I’m pretty into 😉 Wondering if anyone will notice I have the BBEdit icon on my jacket around work? If they do, I guess I’ll know that I should become friends with that person.

Script for Better Man Page Viewing

If you’re on macOS, you can open man pages in a separate, nicely formatted, window by using the x-man-page URL scheme.

Example Man Page

Typing x-man-page://ls, however, isn’t super convenient. This script lets you type xman command_one two... and open each page in a separate window. If it can’t find the command you asked for, it prints a message to stderr. Enjoy!

#!/usr/bin/env zsh

function xman() {
    for i in "$@"; do
        if [ $(command -v $i) ]; then
            open x-man-page://$i
        elif; then
            printf "Can't find command: %s\n" "$i" >&2
        fi
    done
}

I wrote seven tests today of my own free will to confirm all the variations of a string that could get returned based on a number of factors were what was expected. So I think I’ve finally gotten religion on testing.

It seems almost too obvious to say, but something I’m thinking and trying to do at work is to always leave code better than when I found it. Even if it’s just a tiny improvement. If something can be more clearly named, more testable, faster, I should just do it.

“I’ve ripped off very few songs in my life, but I’ve ripped off the Hot Pockets theme in like three songs.”

Jenny Lewis Tiny Desk Concert: www.npr.org/2020/02/2…

Filter Through Command in BBEdit

I’ve used BBEdit for a long time, but only recently started digging into the scripting side of it. If you’re willing to write your script against it’s scripting dictionary in AppleScript or JavaScript, you can do a lot, including attaching a script to every menu command in the app. You do however have to write a script and put it in the right place before you can use it. Sometimes I’d rather pipe my text through grep 'foo' | sort -u like you can on the command line, and have it format my text for me.

TextMate has exactly this command, so emulating that seemed like a good place to start:

FilterThroughCommand_TM.png

I figured out that I could build most of what TextMate has as a BBEdit Text Filter:

FilterThroughCommand_BB.png

Dr Drang had already done pretty much exactly the same thing, but I wanted my script to remember at least the last command I ran, which won’t work with his approach. To get that, I needed to make a proper AppleScript so that I could take advantage of persistent properties (which is a super useful thing AppleScript can do if they’re saved as an scpt file).

You can copy the script below into Script Editor and save it in script format to BBEdit’s Text Filters folder:

property default_command : "sort"

on RunFromBBEdit(_range)
	set shell_command to the text returned of (display dialog "Enter a shell command:" with title "Filter Through Command" default answer default_command)
	
	if shell_command is "" then
		quit
	end if
	
	set default_command to shell_command
	
	if _range as text = "" then
		set text_content to text of front document
		set results to executeCommand(shell_command, text_content)
		set text of front document to results
		return ""
	else
		set text_content to _range as text
		set results to executeCommand(shell_command, text_content)
		return results
	end if
	
end RunFromBBEdit

on executeCommand(shell_command, text_content)
	set AppleScript's text item delimiters to {ASCII character 13}
	set results_text to text items of (do shell script "echo " & quoted form of text_content & " | " & shell_command)
	set AppleScript's text item delimiters to {ASCII character 10}
	set return_text to text items of results_text as text
	set AppleScript's text item delimiters to {""}
	return return_text
end executeCommand

Set up MacPorts as a replacement for Homebrew last night. So far so good I think? The only package which wasn’t available so far was swiftlint, which I can build myself.

I’m trying to make a habit of saying “thank you” instead of “sorry” whenever it’s appropriate. For example, thanking someone for their time instead of apologizing for taking it.

Using os_signposts with Instruments is so cool and useful for seeing what your app is doing and zeroing in on specific operations. This post shows the kind of thing I’m talking about if you haven’t used signposts before: www.iosdev.recipes/os-signpo…