Yearly Archives: 2024

Hosts Commander v1.6.3

  • A non-zero error code is returned if an error occurs.
  • Command show is renamed to unhide to better reflect what it does.
  • Command list treats show as an alias.
  • Command empty is renamed to reset.
  • Optional argument shell to run the hosts interactive shell.
  • Host arguments ignore mistakenly passed http:// protocol prefix.
  • The program is executed as a native 64-bit process on 64-bit Windows (AMD64 and ARM64).
  • Other cosmetic changes.
  • [2024/11/12] Added digital signature.

Download: hostscmd.7z (30KB). Project page →

Neat defer macro for C++

Manual resource management in low level C-style C++ code might be annoying. It's not practical to create good enough RAII wrappers for every single C API you use, but approaches with goto cleanup or loads of nested if (success) hurt readability.

A Go-inspired defer macro to the rescue! The usage is as simple as that:

void* p = malloc(0x1000);
defer [&] { free(p); };

The deferred lambda will be executed on scope exit, no matter how it happens: you can return from any point, throw an exception (if allowed), or even use a goto to an outer scope.

Macro implementation is concise and relies on basic features of C++17 (Clang 5+, GCC 7+, MSVC 2017+):

#ifndef defer

template <typename T>
struct Deferrer
{
	T f;
	Deferrer(T f) : f(f) { };
	Deferrer(const Deferrer&) = delete;
	~Deferrer() { f(); }
};

#define TOKEN_CONCAT_NX(a, b) a ## b
#define TOKEN_CONCAT(a, b) TOKEN_CONCAT_NX(a, b)
#define defer Deferrer TOKEN_CONCAT(__deferred, __COUNTER__) =

#endif

It is truly zero-cost and doesn't rely on C runtime or standard library, so it can be used even in kernel development.

Continue reading

Unchained Nostalgia v1.5

A Famicom/NES/Dendy demo based on the notorious 9999-in-1 pirate multicart with Unchained Melody in its menu.

In 2023, I was preparing an anniversary update: 10 years since the first version of the demo, 30 years since the first multicarts with Unchained Melody and the Dendy itself, and 40 years of the original Famicom. But I got distracted by something at the end of the year, so it remained unreleased. I'm releasing it now retroactively in the state the project was in November 2023.

  • Shooting stars effect on the night slides.
  • When automatic demonstration mode is enabled by pressing Start, the most suitable slide is immediately displayed.
  • Automatic demonstration mode is activated automatically after a long idle time (5 minutes) on a suitable slide.
  • More precise synchronization of automatic slide switching with the music beat, resolving a 6-frame deviation error.
  • Input handling is more responsive to rapid slide switching.
  • Standard NROM vertical mirroring is used (instead of non-standard 4-screen) for better compatibility.
  • Lightweight version of the sound engine in the NSF.
  • NSF file size: 1632 bytes.

Download: unchained_nostalgia.zip (20KB). Project page →

Finnish Duolingo Guidebook

I started to learn Finnish a few months ago. There is a great intro-level Finnish course on Duolingo that is quite entertaining and lets you try the taste of Finnish before you'll be ready to make a deep dive into the language. But it provides just exercises and doesn't explain anything, you are supposed to guess what is right just based on provided examples. It mostly works, but sometimes you are left with an open question "why?" without a chance to get an explanation.

The truth is, originally the course had proper lessons with explanations of basic grammar mixed with some jokes about Finnish culture. The lessons were removed in 2022 for some mysterious reason, and just exercises are left since then. Duolingo fans from the duome.eu preserved all these materials on a single page. I didn't like that the page doesn't allow to track progress of learning, so I made my own pirated version with blackjack and bells and whistles.

Finnish Duolingo Guidebook →

It's mobile-friendly and can be added to the home screen as an app. You can mark chapters that you already learned, and they will become green. Overall progress is displayed in the Table of Contents on the top of the page. You can quickly scroll to your current chapter by using the "triangle down" button. Each chapter mentions section and unit where you can find related exercises on Duolingo today. Each unit on Duolingo corresponds to a chapter in the guidebook, and they go in the same order, so it's convenient to read the guidebook and do the exercises in parallel. Just bookmark the guidebook page and visit it whenever you move to a next unit on Duolingo to read the next portion of grammar. No more guessing what the green owl wants from you!

Learning any new language is always a long road and it's important to find something that would help you to keep up for a few years. Tracking progress of learning might help with keeping motivated. Sometimes you might not feel your progress (that is quite subjective and can be discouraging), but tracking your daily progress does the trick and makes it visible so you can actually see it. This is why I also track how much time I spent on learning Finnish. Each lesson makes me closer to my target of 1600 hours.

Keep in mind that Duolingo alone is not enough. It's a great intro into the language, but you'll eventually need to take quite a few more courses if your goal is actually to start speaking. The Duolingo course is just roughly first 100 hours of this journey.