Blog

Detecting Outages

Millions of my fellow Texans were in crisis the week after Valentine’s day 2021. The weather was colder than it had been since Santa Anna marched his army to San Antonio, and the whole state was experiencing blackouts. But I was lucky. I had an exact record of precisely when the power shut off and was restored throughout this whole ordeal. How did this help me? It didn’t. But it was nice to know that my power outage notification system was working as intended.

Writing a Simple Notcurses Program

Notcurses is a modern TUI library written by Nick Black (who you may see around the net as dankamongmen or some equally dank designation). As Dank himself will tell you, the older ncurses library is beautifully documented, rigorously tested, and very well supported. It is, however, quite old tracing its history back to at least 1982, and as such lacks some modern features such as thread-safety. I had been using the venerable ncurses for my fireplace program - a use case that it was never designed to handle. Overall ncurses does a good job, but there is occasional tearing and artifacts. Notcurses solved all the graphical glitches beautifully, and performance was noticeably improved. The problem is that just about the only other person using notcurses is Nick Black himself, and while his documentation is extensive, it is mostly source code snippets with few examples. Hopefully this article will provide a nice jumping-off point for the absolute beginner.

Strange Spells

Since the beginning of time, man has desired power greater than he possesses alone, power greater still than that of his enemies, and - perhaps for some - power far surpassing that of his neighbor. To this end, the practice of magic is long and storied. Many practitioners kept their arts a secret and their knowledge is lost. Some published grimoires to spread their wisdom (or from a more cynical point of view, to make a quick buck) and because of their generosity (or greed) we are able to examine the magical practices of old. What can be found is surprising not in its grandeur and mystery, but in oddity and sometimes downright silliness.

On Substitution Ciphers

One of the first “real” programs I ever wrote would encrypt a message using a substitution cipher and (more impressively) decrypt an encoded message without knowing the encryption key. Perhaps the first thing I had to come up with was an algorithm to take a cipher key that was used to encode a message, and transform it so that it could then be used do decode the ciphertext back into plaintext. I was aware of ROT-13’s property that if applied once to the plaintext, and again to the output ciphertext, it would yield the original plaintext. That is, ROT-13 is its own inverse. However, this is not the case for all possible keys, so I needed to find a more general algorithm.