PHP is Web Shell

One of the cooler things about working in a firm founded and run by a lot of dyed-in-the-wool Linux hackers like my current place is that there is a lot of Bash lying around, accumulated over a good 25 years or so. For all their faults, pure shell solutions still set the silver standard for programs which appear almost entirely immune to bit rot. But you know what? So does vanilla PHP. That pink stuff that was made from the ground up to get you from zero to working dynamic web page as fast as possible. ...

April 29, 2024

fd + xargs + bat = quick document review

I’ve been on vacation this week, and part of what I’ve been up to is fixing up the Selkouutiset Archive. Like most of my websites these days, SA is powered by Hugo, which means handling a lot of Markdown documents, which means I opted to use an intermediate Git repo as a submodule to actually store the custom-processed documents. After a few tweaks here and there, I found myself wanting to quickly flip through all of the Markdown documents I had generated for each news day. I wasn’t exactly sure what I was looking for, just that I would know it when I saw it. So: ...

February 25, 2024

Getting `fzf` to print the preview pane

fzf is an incredibly useful bit of software, if someone shows you how to use it. There’s a lot more to it than just fuzzy-switching directories and fuzzy-searching you shell history – it also comes with a preview pane that updates on every keystroke. Try 1 echo '' | fzf --preview 'echo {q} {q}' and typing something to see how it works. ({q} is the query you type in at the bottom of the screen.) ...

December 6, 2023

Git aliases for fun and profit

haskell-kata’s Quickstart now has this neat little ditty at the start: 1 2 git config --local alias.build '!sh -c \'for file in *.hs; do ghc -o "${file%.hs}-bin" "$file"; done\'' git build Git is the gift that keeps on giving. I was on the hunt for a subdirectory-scoped alias, and I just discovered this incredibly flexible way to create new Git subcommands. History: 2 years ago I read through the 1200 page behemoth Haskell Programming from First Principles. (Recommended!) I walked out of that with some 1300 Anki flashcards that I have been chewing through ever since. ...

December 3, 2023

Haskell has a rustup now?

Apparently so.. The resemblence is uncanny. I’ve apparently been out of the FP game too long, I thought Stack was the latest and greatest in abstracting over the toolchain.

December 2, 2023

traceroute uses UDP by default, not ICMP

At least on Linux. Don’t believe me? Run tcpdump -nn -i <interface> 'host example.com' in one shell and traceroute example.com in another. tcpdump will pick up all 3 of {ICMP, UDP, TCP}, and on my machine the pattern is clear: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20:58:47.187086 IP 1.2.3.4.41369 > 93.184.216.34.33434: UDP, length 32 20:58:47.187160 IP 1.2.3.4.39830 > 93.184.216.34.33435: UDP, length 32 20:58:47.187190 IP 1.2.3.4.43467 > 93.184.216.34.33436: UDP, length 32 20:58:47.187221 IP 1.2.3.4.50462 > 93.184.216.34.33437: UDP, length 32 20:58:47.187254 IP 1.2.3.4.35842 > 93.184.216.34.33438: UDP, length 32 20:58:47.187285 IP 1.2.3.4.44146 > 93.184.216.34.33439: UDP, length 32 20:58:47.187318 IP 1.2.3.4.50311 > 93.184.216.34.33440: UDP, length 32 20:58:47.187346 IP 1.2.3.4.34388 > 93.184.216.34.33441: UDP, length 32 20:58:47.187375 IP 1.2.3.4.43703 > 93.184.216.34.33442: UDP, length 32 20:58:47.187405 IP 1.2.3.4.35304 > 93.184.216.34.33443: UDP, length 32 20:58:47.187448 IP 1.2.3.4.50157 > 93.184.216.34.33444: UDP, length 32 20:58:47.187474 IP 1.2.3.4.58392 > 93.184.216.34.33445: UDP, length 32 20:58:47.187503 IP 1.2.3.4.45918 > 93.184.216.34.33446: UDP, length 32 20:58:47.187530 IP 1.2.3.4.38313 > 93.184.216.34.33447: UDP, length 32 20:58:47.187556 IP 1.2.3.4.41520 > 93.184.216.34.33448: UDP, length 32 20:58:47.187582 IP 1.2.3.4.55240 > 93.184.216.34.33449: UDP, length 32 20:58:47.225929 IP 1.2.3.4.60724 > 93.184.216.34.33450: UDP, length 32 20:58:47.225970 IP 1.2.3.4.43648 > 93.184.216.34.33451: UDP, length 32 20:58:47.226016 IP 1.2.3.4.52561 > 93.184.216.34.33452: UDP, length 32 I have no idea why. Performance? Getting around sysadmins who unwitting block all ICMP packets? It surprised me, at least. ...

November 29, 2023

Promoting Blog Tag Reuse with `fzf`

Some more updates to the main repo of this TIL site today, in particular I have added a new fzf-tags.fish script. til uses this script to Scrapes all the YAML tags: frontmatter from all current Markdown posts, Puts me into a multi-select fzf menu containing them, and Puts anything I select into the tags: of the new blog post. Tags form natural breadcrumb trails throughout a blog as it grows organically over time. Many an afternoon have I spent reading one or two particular tags of interest from a prolific blog. But, if you don’t remember to reuse the tags in the first place, you’ll never build the trail in the first place. ...

November 25, 2023

That damned Debian 10 one-liner I always need to let me `sudo`

1 2 # ⚠️: Reboots your VM. su -c "$(whereis adduser | awk '{print $2}') $(whoami) sudo && $(whereis reboot | awk '{print $2}')" In all its glory! For Debian 10 and up, because Debian 10 is where the sysv to systemd conversion became totalizing. Let’s break down quickly why each part of this is needed: Since we are trying to add ourselves to the sudo group right now, we obviously can’t use sudo. Enter su -c to switch to root, run a command, and then switch back out. whereis adduser instead of simply adduser because adduser is no longer in the $PATH by default anymore. Tempted to try which adduser? No dice – which only gets you things in the $PATH as well: 1 2 3 andrew@debian-10:~$ which adduser # zip, zilch, nada. andrew@debian-10:~$ whereis adduser adduser: /usr/sbin/adduser /etc/adduser.conf /usr/share/adduser /usr/share/man/man8/adduser.8.gz awk to rip out /usr/sbin/adduser, which - thankfully - at least is still executable. $(whoami) because your name might not be andrew! whereis reboot because I don’t want to have to manually remember to logout and login again.

November 20, 2023