this is where i come to cry.


sc and dustman

October 9, 2016

In my career as a programmer and generally speaking software developer, I often had to deal with things for which I couldn’t find any solution online, so I decided to write a solution from scratch.

Once I wanted to make a “speedcoding” video, the coding version of speedpainting. “Use Chronolapse”, I hear you say. “I am a Linux user”, you hear me say. And while it is true that Chronolapse has a linux version, it’s also true that it fucking sucks. It crashed on me about 10 times when I was trying to use it, and I got pretty sick of it. So what did I do? I wrote my own! And so, sc was born.

sc stands for SpeedCoding, and it is, of course, a software for speedcoding. It really is something I wrote in a few minutes, and that I made for my very specific use case, which is using it on KDE (it executes spectacle). Its code is absolutely minimal, and it can be adapted to other “screenshot taking systems” very easily, because all you need to change is one function: I’ve been using it to make my speedcoding videos, and various other attempts to do it, which always end up with being too long or too short.

Today I’ve made a second tool, which is always in the kind of same style. This time it took a couple of hours, but still not too long, and I didn’t write any particulary huge amount of code for it. And it also does one thing, and does it well. While it may sound stupid, this is my new spam filter. And it’s called dustman.

So here’s the story, which I predict will take slightly longer to explain. Basically, setting up an email server in 2016 still sucks. And apparently it always will. Anyway, I set up the email server on my server, zxq, way back in the past, like 2 years ago, and it has always worked ever since, in a way or another. Early this year I’ve made it work using my MySQL server, which basically meant I didn’t have to modify two files each time to add a new user. That had already been a nightmare to get working, but in the end I made it. Now, fast forward a few months, and here we are at me like 3 months ago. The amount of spam email I was (am) getting is amazing, I receive a spam email every 10 minutes, so the need for a spam filter is in order.

Digitalocean, from which I read the guide on how to setup the mail server, had a guide on how to set up spamassassin, which unluckily didn’t work completely. My desired behaviour is very simple:

  • Emails that are spam get in the Junk folder.
  • Emails that are not get in the inbox.

Turns out this is one of the most difficult things to do in the world, at least on my server. So I sweared and I sweared day and night, but still nothing. The best I got to was being able to receive email (with spam going to Junk), but no way in the world being able to send email. So I rolled back changes, but well, now spamassassin warned me with a nice *****SPAM***** in the subject line, which made deleting all spam emails fairly easy, but still, I was doing it manually, and you probably know how much a programmer hates doing things by hand. I postponed this job for about a month now, but finally, today I did it, and I wrote dustman, probably one of the hackiest ways of filtering spam.

What it does, basically, is get notified for file changes in the mail folder. If it’s an email being created, or modified, it checks the emails headers, and if there’s X-Spam-Flag and it’s “YES”, then it moves the file to the Junk folder. And since it uses file system notifications, it’s so fast to move stuff, that your email client doesn’t even notice it ever was in the inbox. Hack-ish, but it works.

Getting this cool stuff

Now, if you’re here, you might be wondering how you can download these things? Well, the easiest way to do that is to install Go, set up the GOPATH, and then go get Easy as that!

© Morgan Bazalgette 2015-2017