/images/p1.jpg

Hi, I'm Tomasz

I'm a professional C++ software engineer with over a decade of hands on development experience with variety of technologies (mostly Linux & embedded systems). This is my blog.

Find me on social media

Manipulating /proc files as structured data

/proc provides essential data about the operating system on which the program is running. Often there’s a need as well to alter system’s configuration using /proc files as an interface. Now, you may ask yourself, why should you care? After all, there are already well established solutions like i.e. procfs or containerd allowing for convenient dealing with proc files, cgroups… and I agree. Sometimes though you just don’t want to suck in a huge dependency like containerd and it’s much easier to write something smaller that is better tailored to specifics of the problem at hand.

Golang method expressions

What are method expressions? Coming from a C++ background, I’ll allow myself to use a C++ example. If you know C++, Golang’s method expressions are very similar to member pointers. The code is relatively simple and even if you’re not a C++ enthusiast it should be possible to understand the intentions Here’s a short C++ recap: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 class Foo { public: std::string foo() { return "foo"; } int bar(int i) { return i; } }; using FooPtr = std::string (Foo::*)(); using BarPtr = int(Foo::*)(int); int main(int argc, const char *argv[]) { Foo f{}; FooPtr fooPtr = &Foo::foo; BarPtr barPtr = &Foo::bar; std::cout << (f.

I wrote my own argument parser in C++20

Why? Well, it kind of happened by accident, if I’m honest. While working on a different project, where I’m building a set of utilities (assembler, disassembler, debugger, simulator) for a custom programming language, I needed a parser to create some basic CLI interfaces. I wanted to limit the amount of dependencies and thus didn’t want to reach for Boost’s program_options. Another reason is that I don’t really like it that much.

Quickest way to learn is to be inquisitive about everything!

It starts with “how?” std::variant is a new addition to C++ standard library adopted from ominous boost libraries. Just as a reminder, std::variant is a type safe union with a very cool visitor interface, thanks to which handling its state is very convenient. The type itself wouldn’t be very special to me until I stumbled upon this sentence on cppreference As with unions, if a variant holds a value of some object type T, the object representation of T is allocated directly within the object representation of the variant itself.

Interview question: merging intervals

Let’s write a calendar app Recently I stumbled upon a very common interview question (I think it can be found both in AlgoExpert database as explained in this mock interview) and CoderPad examples database. The gist of the problem is that you’re asked to write a calendar app, which given two calendars will return a list of free time slots between the two. Each calendar is a list of meetings.

C++11's user defined literals are super cool!

What are user defined literals? This is a small feature added with c++11 revision which I think is super fancy. In short, you can define your own unit system when declaring variables and each literal’s value, prior to its usage will be put through the operator appropriate to the types and suffixes used. cppreference page describes everything in great details. This sounds a bit unclear but the examples will summarise everything, I promise.

Testing in golang with "Is" framework

Today’s post is gonna be a short one. I’d like to recommend a framework which I used personally on a number of occasions. Golang comes with a great environment and a set of tools. Tests are first class citizens. Why would you need additional framework for your tests then? Purely for convenience. is API is is a mini framework, at the moment of writing this post, the API is comprised of four functions: