4913 += 123

With merely a handful of articles, I’m still growing into my confidence as a writer. However, I’m obviously nailing it when it comes to titles, right? It will all make sense in a moment. As I was writing my tip about inotifywait(1) , decided to show how different editors behave when saving a file. “I use vim btw”™, so it didn’t take long to try it in there. Executed vim foo +wq and this is what inotifywait(1) printed:...

11 March 2024 · 775 words

Blocks of code into a C switch{}

A while ago I was digging deep into a C++ project, chasing an obscure bug. Neither the project in question nor the bug are important here. What’s important is that I’ve stumbled upon a weird syntax, that seemed wrong. What’s weird is that this block of code worked flawlessly, unlike some other parts of the project. Turns out you can have blocks of code inside a switch statement spilling between cases....

25 January 2024 · 372 words

Type for a context value in Go

Using context values in Go appears, at first sight, very trivial and easily understood. There are pitfalls, though. For instance, what type to use for the key? ❯ go doc context WithValue package context // import "context" func WithValue(parent Context, key, val any) Context WithValue returns a copy of parent in which the value associated with key is val. Use context Values only for request-scoped data that transits processes and APIs, not for passing optional parameters to functions....

8 December 2023 · 602 words

Why does Vim really use hjkl?

This is part of the talk “UNIX archeology” I gave at OpenFest 2023. If you, dear reader, are a vim user, you’ve probably seen this keyboard: It explains a lot about our beloved text-editor. CTRL is just where it has to be in the first place, the Esc is so near and the : symbol we use for commands is not hidden behind a modifier like nowadays. But why the arrows?...

14 November 2023 · 474 words

Why do we have /usr?

This is part of the talk “UNIX archeology” I gave at OpenFest 2023. In modern contexts, /usr is essential for housing the majority of user utilities and applications. This includes system-wide software and files like standard programs, libraries, documentation, and much more. Unlike the root filesystem, which contains the minimum necessary for booting and repairing the system, /usr provides the bulk of the operating system’s functionality. However, have you ever thought why do we have seemingly duplicated with / directories in there?...

12 November 2023 · 515 words

Why do we need hidden files?

This is part of the talk “UNIX archeology” I gave at OpenFest 2023. Hidden files are fairly popular these days, especially in our home folders. We store configuration, cache, logs and whatnot in there. Here’s what’s going on in the home folder on the machine I’m writting this right now: ❯ find ~ -name '.*' -type d | wc -l 5768 ❯ find ~ -name '.*' -type f | wc -l 30573 But why?...

10 November 2023 · 566 words

79 characters

This is part of the talk “UNIX archeology” I gave at OpenFest 2023. Have you ever thought why the 79 characters limit per line is so popular in programming and pretty much nowhere else? Python with their notable PEP-0008, the Linux kernel, PostgreSQL and the GNU project, just to name a few. Sounds like an arbitrary one. But why? tty People tend to believe that this is because terminals were able to print up to 80 symbols per line and this just got carried over....

8 November 2023 · 580 words

Open a pull request from command line

When ready working on a feature branch in a project that uses GitHub, GitLab or anything else like them, one generally do git push -u origin <branch_name> and then goes to the web interface to open a pull request. Pretty much all of these platforms provide the URL to go in order to spare a few clicks. For instance: ❯ git push -u origin baba Enumerating objects: 1, done. Counting objects: 100% (1/1), done....

23 October 2023 · 379 words

Simple Unix-like authorization with Go

Modern complex projects often require sophisticated access-control functionality, like Identity and Access Management (IAM ) systems. Sometimes, however there are cases where simple solutions might just cut it. Let’s cover one of these cases. Say we’re working on a system for publishing articles, allowing discussion below each article, with the following requirements: Moderators can edit all articles and comments Authors can create articles and edit only those created by themselves Users can read articles and post comments about them Any user-type can edit and delete their own profile We could define different user-levels as a bit-mask and store that alongside user’s information (e....

3 September 2023 · 637 words

Friday deploys

There are plenty of memes regarding deploying on Fridays and most of them seem to be about how you should never do it. I find that strange. In fact I think that every team developing a software product which ends up deployed on a production server (trying to exclude on-premise software releases, work with me here) should have a rule stating that there shall be no less than two Friday deploys per month....

13 August 2023 · 391 words

ttymouse_sgr

Recently I bought myself a new “ultra-wide” monitor - LG 35WN75C. Quite nice if you ask me. One of its greatest feature is that I can open 5-6 vertical splits of code (I use vim btw) without sacrificing on readability. Soon, I’ve realized that my mouse usage is increasing a lot. Apparently, scrolling through code and selecting things, when out of the-zone™, is far more comfortable with the mouse. How did I find that, you ask?...

11 August 2023 · 478 words

Hello world

Looks like I’m trying to start blogging again. I’ve been thinking about it for the past year or so. Eventually, I got it together, bought a domain, tried like five different Hugo themes, did some nitpicking for quite some time and as it often happens - completely abandoned that idea altogether. Later, pulled myself together, decided on a theme with solid card-like profile homepage and zero content in there and deployed it....

1 August 2023 · 187 words