Skip to content

Blog of David Culley#

What I do first on a new Linux server

Especially in the 2020’s, as corporations and for-profit companies increasingly enshittify their services and surveil us, people are discovering the benefits of self-hosting open-sourced applications and owning the digital infrastructure they depend on. For most people that probably means renting a VPS from the likes of Linode, DigitalOcean, Hetzner, or Hostinger. Being solely responsible for the administration of a server that is accessible from the internet can be a scary thought due to all the botnets that will constantly try to break into your server from the moment it goes online. Apart from the general security worries regarding having a server accessible to anyone and everyone with malicious intentions over the internet, folks who are entirely new to self-hosting might not even know how to get started and what to do after giving a VPS provider their money. In this article I describe the first steps I take on a fresh VPS. If I’m wrong or miss a crucial step, you are welcome to contact me and I’ll integrate your corrections. 🙂

If the terminal command clear doesn’t work in SSH sessions when using Ghostty

I use Ghostty as my terminal emulator. I also sometimes connect to remote machines via SSH.

When I type, for example, the command clear into Ghostty during a SSH session, I receive the following error:

'xterm-ghostty': unknown terminal type.

This means that the environment variable TERM has been set to xterm-ghostty by Ghostty, but the remote machine doesn’t recognize this value of TERM. Ghostty isn’t a terminal emulator that your server knows. Read on to learn how to solve this problem.

Start using named tuples instead of regular Python tuples

If you're a Python developer, you surely must've seen code like this:

height = person[2]

This code snippet is not easily understandable. What is person? Is it a list, a tuple, something else? What does the value stored at index 2 represent? You can probably figure out relatively quickly from skimming over the code you're working with if person is a tuple. But still, what is it that is stored at index 2 of that tuple? In this particular case we were lucky enough that the variable was named height, which enabled us to guess that it must be the person's height that is stored at index 2. But more often than not you'll see nondescript code such as h = person[2]. Can you still guess correctly that it's the person's height that is stored at index 2? Can you rule out with absolute certainty that it isn't a Boolean that specifies whether the person is hungry or not? To be sure you'd have to comb through the code to find out. That's why the code snippet above is not easily readable. Wouldn't it be much easier if the code author had written explicitly what that value person[2] is meant to represent? If the author had written person.height instead of person[2]? You can do exactly that with named tuples.

Learning How to Learn

Do you still remember what you learned four semesters ago? No? How about one semester ago? No? Well, how did you study the material? By reading and re-reading textbooks, while annotating and highlighting interesting parts, as most students do? I hate to break it to you, but such so-called passive learning techniques aren't successful learning strategies, as you have experienced firsthand. Even taking notes and summarizing passages in your own words isn't an optimal study method. Read on to learn what are the best study strategies (backed by evidence) and what's the only way to ensure high learning retention rates so that you actually remember what you're studying

Haskell’s foldl and foldr Explained

If you want to (or have to) learn Haskell, you can't avoid the two functions foldl and foldr. They are two of the most powerful tools in Haskell's toolbox. However, they continue to confuse beginners and experts alike, so here's my take on making these functions a little more accessible.