Push propelled program tinkerer and picture maker.

Conditionally Linking Stuff In Netbsd Makefiles Based On Compile Options

I run a forked/patched version of Bozohttpd so I can add Cache-Control headers. I had intended to keep it up to date, but before you know it three years have passed and I’m well behind.

I hit an issue trying to build the new one because of a linker issue to libblocklist. I presume what has happened is that the blacklist library has been renamed blocklist (Probably with NetBSD 9.2? Or maybe just Current?), but I wanted to build on NetBSD 9.1 before upgrading where the library is still called blacklist.

The Makefile has support for compile-time options and avoiding blocklist support:


But this still tries to link to the blocklist library. Normally this wouldn’t be a problem. I.e. if changed to -lblacklist then it builds fine on 9.1. But in my mind it doesn’t make any sense to (try to) link to something if not compiling that thing.

So I tweaked the Makefile to make more sense:

# If we are setting a compile option of NO_BLOCKLIST_SUPPORT then it makes no
# sense to have a linker for it.

This neat trick is actually mentioned in the manpage, but it still took me a bit to get it right.

  1. The M in ${COPTS:M-DNO_BLOCKLIST_SUPPORT}" is a variable modifier and so takes the whole $COPTS variable and tries to match only -DNO_BLOCKLIST_SUPPORT. If $COPTS doesn’t contain that string then it’ll result in an empty string.
  2. It then compares that match to what we are looking for, -DNO_BLOCKLIST_SUPPORT
  3. And if that’s there then it returns “nothing”, i.e. there is nothing between ? and :.
  4. If the match isn’t there (i.e. we are not trying to avoid blocklist support) then it returns -lblocklist

make -d A is helpful as will show stuff like:

Modifier pattern: "-lpants"
Modifier pattern: "-lblocklist"
Result["-DNO_BLOCKLIST_SUPPORT" == "-DNO_BLOCKLIST_SUPPORT"] of :? is "-lpants"

Here I was just testing (make COPTS="-DNO_BLOCKLIST_SUPPORT" -d A) and so wanted to return something in either case.

LINK: SimplenoteGo in Simplenote.vim

Took me five (5!!!) months to review this PR on simplenote.vim, but finally did so. It’s a really neat idea that allows you to follow internal Simplenote links. That’s an embarrassing about of time.

On one hand I knew I didn’t want to merge exactly as it was and that I wanted to make some tweaks to it so taking a bit of time is expected. On the other hand I really do not understand where my time goes. I’m strongly considering fully tracking my time to discover. I’ve been tracking my working hours since 2018 (because they are often spread out throughout the day, rather than being in consistent solid blocks), but I don’t track non-working time. I do a fair bit of running, but not that much. I genuinely don’t understand.

Semi-automatically switching kubectl versions

I can’t be the only one that has this issue and yet I’ve not been able to find any existing solutions.

At work I have to deal with multiple flavours and versions of Kubernetes. Until very recently stretching all the way from 1.12 up to 1.20. I found it a pain in the arse trying to ensure I was using the correct kubectl version; And helm, but that’s another story and fortunately less of an issue now.

kubectl does seem to be very compatible across differing versions, but I was still keeping different named binaries that looked like this:

ls bin/

I decided to write a very simple shell function to switch to the correct version:

function kubeset {
	version=$(kubectl version --short | grep Server | sed -E 's/.*(v[0-9]+)\.([0-9]+)\.([0-9]+).*/\1\.\2\.\3/')
	minor=$(echo $version | sed -E 's/(v[0-9]+)\.([0-9]+)\..*/\1-\2/')
	if test -f ~/bin/kubectl$minor
		echo "Setting kubectl to $minor"
		echo "Downloading kubectl $version and setting to that"
		curl -L$version/bin/darwin/amd64/kubectl -o ~/bin/kubectl$minor
		chmod +x ~/bin/kubectl$minor
	rm ~/bin/kubectl && ln -s ~/bin/kubectl$minor ~/bin/kubectl

(I don’t care about patch version compatibility, just minor version)

It does require that there is an initial version of kubectl available. I guess it could be adjusted to handle that case, but if you’re not careful you end up taking something simple and elegant and ending up with this; Although snark aside this would be nice as a hook/extension to kubectx.

Thankfully we’ve now torn down the 1.12 cluster (because it’s easier to tear down and re-write everything than upgrade K8s; more snark) so I have less versions to deal with.

[EDIT: 2021-03-30] This is actually more useful than I realised. Sometimes kubectx doesn’t work so well with mismatched kubectl versions. But this kubeset thing does the trick. Nice.

Vim session titles in MacOS tabs

After a few years now of using Vim it has kind of sunk in; There really was a time when I never thought I’d get the handle of h/j/k/l and now I find myself using them where they aren’t even supported.

I am still cross-platform, but have been fortunate enough not to have to use Windows for the past five years so it’s NetBSD for pleasure and then MacOS and Ubuntu for work. So for work, Panic’s Nova has been the first thing in a loooong time to tempt me away from Vim; Atom and VSCode make me want to puke - Sorry, but a web-browser to write code… no. Nova doesn’t offer any kind of Vim support yet but they are working on it so something should come eventually via an extension so I’m not completely lost with key bindings. I’ve had a play with the trial and am highly likely to buy it for work at some point this year just because it’s really nice to look at and a pleasure to use. And if I can make work more pleasurable then I have no qualms paying for Nova out of my own pocket; I’m not shy of the command line, but I’d bought Transmit for work just to make my life easier dealing with umpteen s3 buckets. Plus I have had good experiences with Panic’s products, buying and using these over the years:

  • Transmit
  • Transmit for iOS
  • Prompt for iOS
  • Candybar (when MacOS wasn’t MacOS and was good)
  • Unison

Sure, I can absolutely edit text faster in Vim (:global is great), but as much as I love Vim, Nova is way more polished. Anyway… I haven’t bought it yet… but one thing using the trial made me realise is that I could be handling projects better in Vim; I might have used Vim for ages now, but it doesn’t mean I’m always doing things as efficiently as possible.

How I used to do things was:

  1. Don’t use gvim
  2. One terminal window for all my vim sessions
  3. One tab per session/project, but each time I’d cd to the directory and open vim, re-open :NERDTree, etc.
  4. I’d manually do cmd+i to open the inspector and name the the tab title to suit each project which some action would then overwrite and change.

Playing about with Nova made me realise I could do:

  1. Don’t use gvim
  2. One terminal window for all my vim sessions
  3. Use the Session plugin. This way I can :chdir in Vim and keep that per session, re-opening windows and :terminal from last time
  4. Automatically set the tab title to the session

To do the last one I have the following in .vimrc:

" Tab title, not window title, on MacOS
set t_ts=^[]1;
set t_fs=^G
autocmd BufEnter * let &titlestring = xolox#session#find_current_session()

(The ^[ is actually the ESC control character entered with ctrl+v followed by escape. And the ^G the BEL character entered with ctrl+v followed by 7).

And in Terminal preferences only having “Working directory or document” selected for the Tab Title (unsure how much difference this makes, probably not any).

Asides from the Session plugin I was already using these anyway as a somewhat Nova equivalent:

Those are all arguably way more powerful than what Nova offers too (Fugitive currently trounces the git support within Nova). But… Nova is joyful. And it’s not like I have to stop using Vim… it works great from within Nova’s terminal.

LINK: Pkgsrc WIP package for Spotifyd updated to 0.3.0

For want of anything else to post and as proof that I sometimes manage to honour my open-source commitments; Sadly I’m really behind on simplenote.vim.

I’m still building this on a Pentium D. It’s quicker than it used to be, but still up there in terms of effort

Teuxdeux on Apple Watch take Teux

Some of this maybe new with iOS 14 / watchOS 7, or it maybe I was just missing a trick before; However, I’ve now for three shortcuts on my watch:

  1. NeuxTeuxDeux
  2. TeuxDeuxs
  3. TeuxDone

Taking advantage of Haskerdeux and having my own server means I can create really simple, but useful, shortcuts using “Run script over SSH” as follows:

  1. NeuxTeuxDeux
    1. Ask for Input, with text input
    2. Run script over SSH where the script is:

       export CURL_CA_BUNDLE=/usr/pkg/share/mozilla-rootcerts/cacert.pem && /path/to/bin/haskerdeux today new "[Provided Input]"

      Those are actual " around the provided input otherwise it’ll only create Teuxdeuxs with single words.

  2. Teuxdeuxs
    1. Run script over SSH where the script is:

       export CURL_CA_BUNDLE=/usr/pkg/share/mozilla-rootcerts/cacert.pem && /path/to/bin/haskerdeux today todos
    2. Show Result with “Shell Script Result”

  3. TeuxDone
    1. Ask for Input, with a number
    2. Run script over SSH with

        export CURL_CA_BUNDLE=/usr/pkg/share/mozilla-rootcerts/cacert.pem && /path/to/bin/haskerdeux today [Provided Input] crossoff

On the one hand, being able to do stuff like this makes me think the Apple Watch is simply brilliant. On the other hand bugs like this make me want a Garmin (and a Google Pixel 4a).

LINK: ncspot on NetBSD

This is interesting. I think this came about (kind of) because of my efforts getting Spotifyd working on NetBSD. I stumbled across this forum thread which links to my post and culminates in folk getting ncspot working on NetBSD. It’s a really nice thread as summed up by this post.

  1. If I’d known about ncspot I may well have tried to get that working before Spotifyd
  2. However… Spotifyd is still handy for me for when I’m on my work laptop and can control Spotify from there, but play out to my NetBSD desktop (where my headphones and stereo are plugged into)
  3. I wish I had more time to be involved with the “community” so I’d hear about these things sooner (and had more time to help out). Oh well. Maybe one day
  4. I wish I had more time to get stuff I do out of Pkgsrc WIP into main
  5. Makes me love NetBSD and Pkgsrc a little bit more.

Wow, there’s also a QT client now, but I love the ncurses approach

Haskerdeux Arg Handling

Found some time to change the order of commands like I mentioned wanting to do last time.

After doing it I’ve realised I probably shouldn’t have, but seeing as how it took me a couple of months to find the time I’m not going to change it back.

It all came about because I had issues with this not scanning/reading well:

haskerdeux today moveto 2 2020-08-30

And wanted:

haskerdeux today 2 moveto 2020-08-30

But I should have probably just changed the wording:

haskerdeux today move 2 2020-08-30

Because it makes sense on all levels to have a consistent order of arguments of

haskerdeux date command [todo date]

But for craziness reasons I now am able to do:

haskerdeux today todos
haskerdeux today 2 moveto 2020-08-30

By using some guards to flip the order of commands if needed:

main = do
	(date:number_or_command:argList) <- getArgs


	let command | isDigit $ head number_or_command = head argList
	            | otherwise = number_or_command
	let args | isDigit $ head number_or_command = number_or_command : (tail argList)
	         | otherwise = argList
	token <- login
	dispatch command (token, todos_date:args)

With no need to change the rest of the programme. Yay for more bad Haskell.

LINK: Small Mailserver Best Current Practices

Stumbled across this which I thought quite timely given my last post. It is a really good resource, but mostly it made me sad.

I already have:

  • SPF
  • DKIM
  • Let’s Encrypt

And yet still ran into trouble with the Spamhaus SBL-CSS thing. And this is a server that I hardly send any email from: An occasional reply to NetBSD Users, etc. None of that was too fiddly to setup, but this post takes things way beyond that:

  • Not using -all on SPF records. I didn’t know that was a bad thing and it’s 100% non-obvious from the SPF site (that doesn’t use https!). In all fairness this is 100% bollocks (it might be true, but it’s still bollocks): “the larger operators have metrics to show that using -all tends to be a sign of over-enthusiasm rather than reality, so it will slightly count against you”. So don’t use SPF at all then? This is already in the realms of browser User Agents.
  • Rotating DKIM keys. I did not know that was a thing.
  • DMARC and not using quarantine. Firstly it’s 100% dumb that SPF, DKIM and DMARC all have to exist. And it’s then 200% dumb that you can’t then use those things the way they are meant to be used.

And then I stopped reading because it made me too sad. Sending email shouldn’t be this difficult.

Quite a few years back now, I remember my daughters saying something like “Who still uses email? Email is dead!” and I “corrected” them because, well, businesses still sent a stack of email even if just internally; Even nowadays working somewhere that primarily uses Slack, we still send a stack of email. But actually I think they were right. And products like this just prove it. If email isn’t dead yet, I wish it would just hurry up and fuck off and die.

Some changes to Haskerdeux

Made a couple of changes to Haskerdeux recently:

  1. Adding a nextweek command to allow me to easily put stuff off until the next Monday whatever day the todo maybe on.

    I could achieve similar by doing:

     haskerdeux today moveto 3 `date -d "monday" +%Y-%m-%d`

    But that’s not as succinct as doing:

     haskerdeux today nextweek 3

    And plus if I happen to be on Monday then the date one just returns today’s date not next Monday. This is quite handy as for a while now I’ve been using Teuxdeux in a bit of a Kanban style to balance my work: I limit to three work tasks per day and three home tasks per day. I don’t take into account how long these tasks or chunks of work will take though - the only differentiation I have is some tasks I prefix with a q for things that are quick (putting some washing on, putting the bin out) and these I don’t count towards my total of three tasks. Of course nothing ever goes to plan and stuff rolls over to the next day, begins to pile up and I need to rebalance my week - and that’s where quickly being able to punt stuff to next week is handy (I can then plan the next week when I get there).

  2. Allowing me to use “mon”, “tue”, “wed”, etc in addition to the current “today” and “tomorrow”.

    This means I can do things like

     haskerdeux wed todos

    It’s not clever enough yet to do this though:

     haskerdeux wed moveto 3 fri

    But that’s something I can think about adding. There are possibly existing natural date processing libraries out there for Haskell, but because I’m using a ye-olde version on NetBSD and am limited as to what I can add via cabal I don’t want many external dependencies. Just a simple improvement is good enough for me (I.e. it currently only works with three letter day names, “mon” not “Monday” - because I don’t want to type more than necessary anyway)

The only thing remaining that I really would like to be able to do now is work on multiple todos. I’m not too bothered about dealing with someday lists via Haskerdeux, but being able to move stuff in bulk would be good. I guess eventually I’ll find time to do that…

I also should think about improving the order of arguments. Being able to do haskerdeux today 3 moveto 2020-06-01 reads much better than the current haskerdeux today moveto 3 2020-06-01

These are the ten most recent posts, for older posts see the Archive.