Browser History


If you frequent a site enough time, your browser will start to auto-complete that site’s URL when you begin typing its domain. Here is a list of what a single letter entered into the address bar of my browser produces.

A - amazon.com
B - boards.greenhouse.com
C - chatgp.com
D - daringfireball.net
E - en.wikipedia.org
F - fasterthenl.me
G - github.com
H - hackmd.gfuzz.de
I - imore.com
J - jimmymiller.github.i
K - kottke.org
L - lobste.rs
M - mail.google.com
N - news.ycombinator.com
O - os.phil-opp.com
P - polymonster.co.uk
Q - quillbot.com
R - rsdlt.github.io
S - sourcegraph.com
T - textualize.io
U - usgs.gov
V - veykril.github.i
W - www.youtube.com
X - xeiaso.net
Y - youtube.com
Z - zed.dev


How to Write Comments in Json


I spend a lot of time working in either JSON or YAML while building out infrastructure in AWS. I prefer YAML as I find it less cumbersome to type and it allows for comments.

Today on Mastodon I saw this posting that illustrates a way to put comments into JSON.

{
    "//": [
      "I am a comment",
    ],
    ...
}

Cumbersome, but effective.


How to Remove Outdated Local Git Branches


To clean up local Git branches that no longer exist on the upstream repository, you can run these commands.

Update your working copy

To start, make sure your working copy is up to date.

git fetch --prune

The --prune option removes and remote tracking references that no longer exist on the remote repository.

Discover which branches are already merged

By running

git branch

You get a list of all the branches on your working copy. Using the --merged flag, filters that list to show only those branches that are already merged into the main or master branch.

git branch --merged

Delete all merged branches

To delete all the merged branches from your working copy, run this command.

git branch --merged | egrep -v "(^\*|master|main)" | xargs git branch -d

The list of merged branches is piped to an egrep command that eliminates the master or main branch, as we don’t want to delete those. The remaining branch names are pipes to the git branch -d command, which deletes them.

Notes

Whenever I find a command or set of commands online, that purport to accomplish some task, I always break the command down, and execute each stage of it, to make sure I understand what it is doing, and to ensure that it does what the author claims. Trust, but verify.


How to See Only Active Network Interfaces on Macos


MacOS has a number of network interfaces making the output from ifconfig messy and not easily visually parsed.

Network Interfaces

A non-exhaustive list of network interfaces you might see on MacOS includes

  • ap1 - Access Point. Used if you are using your Mac as a wireless access point where you are sharing its connection.
  • awsl0 - Apple Wireless Direct Link. WiFi P2P link for AirDrop, Airplay, etc. Also used for Bluetooth.
  • llw0 - Low latency WLAN interface. Used by the Skywalk system.
  • utnun# - Tunneling interface. Use for VPN connections. MacOS seemingly hangs on to multiple utun interfaces, even after they aren’t in use.
  • lo0 - Loopback or localhost
  • gif0 - Software Network Interface
  • stf0 - 6to4 tunnel interface
  • en0 - Ethernet interface
  • en1 - Wireless interface
  • en5 - iBridge / Apple T2 Controller
  • en6 - Bluetooth PAN
  • en8 - iPhone USB
  • en9 - VM network interface
  • en10 - iPad
  • bridge0 - Thunderbolt Bridge

List current IP addresses

A simple way to see the current list of IP addresses your Mac has is by using an alias like this.

alias inet='ifconfig | grep inet | grep -v inet6'

Which produces output similar to this.

   ❯ inet inet 127.0.0.1 netmask 0xff000000
        inet 192.168.6.39 netmask 0xfffffc00 broadcast 192.168.7.255
        inet 192.168.65.1 netmask 0xffffff00 broadcast 192.168.65.255
        inet 100.101.18.109 --> 100.101.18.109 netmask 0xffffffff

While that can be useful, it would be nicer to know which interface had which IP address.

List current IP addresses and the network interface

This command will display the name of the network interface and the assigned IP address for the active network interfaces.

ip -4 addr show | awk '/inet/ {print $NF, $2}' | column -t

In order for this command to work, the iproute2mac formula via Homebrew.

The ip -4 addr show displays all the network interfaces having an IPv4 address.

❯ ip -4 addr show
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
        inet 127.0.0.1/8 lo0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        ether 74:a6:cd:b6:eb:7f
        inet 192.168.6.39/22 brd 192.168.7.255 en0
utun8: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1280
        inet 100.101.18.109 --> 100.101.18.109/32 utun8
bridge100: flags=8a63<UP,BROADCAST,SMART,RUNNING,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
        ether 76:a6:cd:6b:c1:64
        inet 192.168.65.1/24 brd 192.168.65.255 bridge100

The awk statement filters for the line containing inet and then prints the last field from that line ($NF) and the second field ($2). The last field is the interface name and the second field is the assigned IP address.

The column -t command formats the output into columns.

❯ inet
lo0        127.0.0.1/8
en0        192.168.6.39/22
utun8      100.101.18.109
bridge100  192.168.65.1/24


Neovim Paste and Indent


Today I learned that you can paste and match surrounding indentation at once. After selecting the line or block of lines to be pasted, use ]p instead of only p. Et voila.

I am embarrassed to think of the hundreds, thousands of copy-paste operations I’ve done that were immediately followed by selecting the newly pasted block and fixing its indentation. I need the read the friendly manual more.


Putting a Conditional Clause in an Ssh Config


Enough years ago that I no longer remember when I discovered this trick, I added the following clause to my .ssh/config file.

# Access GitHub even when port 22 isn't available
Host github.com
  HostName ssh.github.com
  Port 443
  user git

In a nutshell, this allows you to access GitHub over port 443, instead of the usual port 22. Various places block port 22 traffic; having this in your configuration file sidesteps that problem.

Until last week this worked perfectly. Then it stopped working, but only on my work laptop. Not on my personal laptop, not on the Linux admin workstation running in AWS, not from any of my collection of Raspberry Pies or the Intel NUC that is my IRC and mutt host, only from my work laptop.

Thanks to a GitHub repository, all my configuration files are shared between the various computers I use. The same .ssh/config worked everywhere but my work computer.

Recently my employer suffered an intrusion–we were hacked. Security has been tightened considerably. Including not allowing ssh traffic over ports that aren’t :22. As soon as I commented out the GitHub clause, all my git commands started working again.

Some searching and reading of the ssh man page and a little experimenting allowed me to create this slightly altered clause.

# Access GitHub even when port 22 isn't available
# Host github.com
Match user !<user> host "github.com"
  HostName ssh.github.com
  Port 443
  user git

The Match keyword allows you to place conditions on the directives that follow. The user and host keywords (must be lowercase) let me place a guard around the GitHub port 443 setup. If I am signed in as my work id, then the clause is skipped, meaning a normal ssh connection over port 22. For any other user the clause is used, to access GitHub. There are several other keywords that Match can operate against, allowing you to create some sophisticated conditional restrictions in your .ssh/confg file.


Do It Yourself Genius Playlist


For a long time Apple Music (nee iTunes) offered an option called “Genius Playlist”. You selected a track from your collection, and Apple generated a playlist of 25 titles that were somehow related to the seed track. I had 15 or 20 of these. It was my own personal radio station. One without ads or an annoying DJ talking over the intro or outro of a song.

I’m not sure when Genius Playlists were eliminated from Music, but I miss that option. So I set out to make my own. Once upon a time fifteen or more years ago, I remember reading an article where someone created a set of smart playlists that categorized tracks, and then a master playlist that used those category lists as its input.

What I have create are four category smart playlists:

  1. Never Played
  2. Not Played in 90 Days
  3. Not Recently Played
  4. Recently Played.

I also scrolled through the list of tracks and ticked the “favorite” star on several hundred tracks that I particularly like.

Never Played: Tracks that are favorites, and have a play count of zero.

Not Played in 90 Days: Tracks that are favorites, and that haven’t been played in the last 90 days, but have a non-zero play count.

Not Recently Played: Tracks that are favorites, that have been played less than 90 days ago, but more than 15 days ago.

Recently Played: Tracks that are favorites, that have been played in the past 14 days.

Each of these category lists is limited to 50 tracks are are selected randomly.

The master list draws from all four category lists. Where the category lists AND all the rules together-Favorite AND never played-the master list ORs the rules-Playlist is Never Played OR Playlist is Not Played in 90 Days OR ….

The master list is also set to only 25 tracks, randomly selected.

I understand that the Never Played playlist will eventually run dry. And I’m not completely satisfied with using date ranges for the rest of the lists. What would work better, but requires considerable work, would be to rate tracks from 1 to 5 stars, and build lists around ratings and play frequency. A long term project.


Use Asdf to Manage Neovim Nightly


I’ve been using the Neovim nightly build for some time. The way I have been accomplishing this is to update my local clone of the Neovim repository, and then make and install the application. This works, but it does take a little time.

With asdf and the neovim plugin I can easily update to the latest nightly version.

To add the neovim plugin to asdf

asdf plugin add neovim

To install the nightly build of neovim

asdf install neovim nightly

To make the nightly version the global default

asdf global neovim nightly

In order to update the nightly version you need to remove the old nightly version first, so I have this bash alias setup.

alias update-nvim='asdf uninstall neovim nightly && asdf install neovim nightly'

And, since asdf will let me have multiple version of Neovim installed, I could have the stable version on hand, and use it for a project if I wanted to.


Using asdf to Manage Software Versions on Macos


After reading Thorsten Ball’s Register Spill newsletter about New Year, new job, new machine I decided to give asdf a try. It’s a single piece of software designed to manage multiple versions of any number of other pieces of software. Like rbenv or rvm is to Ruby, asdf is to Ruby, and Python, and NodeJS, and, and, and.

Here’s how I set it up.

Step One

Clone the GitHub repository. Installing it via Homebrew apparently has some issues. Running this command will close the 0.13.1 version into the .asdf directory in your $HOME.

 git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.13.1

Step Two

Install some plugins to manage the software of your choice. You can get a complete list of plugins available by running:

asdf plugin-list-all

I actually piped the output through grep to make finding the software I wanted a bit quicker.

asdf plugin-list-all | grep ruby

With the plugin name and repository information, run:

asdf plugin install ruby

Step Three

Determine the version, or versions, of the software you want.

asdf list all ruby

Step Four

Install the software.

asdf install ruby latest

or

asdf install ruby 3.3.0

Step Five

Set the version globally. (It can be overridden on a project by project basis.)

asdf global ruby latest

There is no Step Six.

Using asdf means I have one set of software version management commands to remember, and one location where that information, and those versions, are kept. Better still, the version information can be shared, say with your team, ensuring everyone has the same versions of required tools installed.


Five Useful Bash Aliases


Here are five bash aliases that I find useful.

List contents of current directory, sorted by size

alias 'dus=du -sckx * | sort -nr'

Here is a breakdown of the command.

  • du – command estimates file system usage
  • -s – creates a total for each argument
  • -c – creates a grand total
  • -k – sets the block size to kilobytes. Using -m would set it to megabytes
  • -x – skips directories on other file systems

The output of the du -sckx * command is then piped to sort -nr.

  • sort – sorts lines
  • -n – does a numerical sort
  • -r – reverses the result, so it is in descending order

Show all currently assigned IPv4 IP addresses

alias inet='ifconfig | grep inet | grep -v inet6'

Here is a breakdown of the command.

  • ifconfig – lists the current network interface configuration
  • | grep inet – returns only the lines with inet
  • | grep -v inet6 – eliminate those lines with inet6, i.e., IPv6

Depending on your OS you may need to use ip a instead of ifconfig.

List directory contents sorted by modification time

alias latr='ls -latr'

Here is a breakdown of the command.

  • ls – lists directory contents
  • -l – use the long format
  • -a – do not ignore hidden files
  • -t – sort by modification time, newest first
  • -r – reverse the sort order

The mnemonic I use for this alias is “later”.

Look up a word’s definition

alias 'define=curl dict://dict.org/define:"$@"'

Here is a breakdown of the comment.

  • curl – transfers a URL, in this case dict://dict/org/define
  • "$@" – the search term provided

Make a password

alias makepass='openssl rand -base64 15'

Here is a breakdown of the command.

  • openssl – runs the openssl command line tool
  • rand – generates pseudo-random bytes
  • -base64 – use base64
  • 15 – make the resulting password 15 characters long