Hello and welcome to my little nock of the internet. Here I have my blog which mainly contain posts about tech, the outdoors, cooking, and some times mead brewing.

A bit of background information before you step into my world of crazy. I am Lars, a.k.a. looopTools, a Software Engineer living in East Jutland, Denmark. I have 10+ years of experience from industry mainly through student positions, but also as self-employed consultant, or full-time employee. I mainly work in low-level user space, high-level kernel space, and storage systems in general. Besides research and software development, I also love the outdoors and try to go out as often as possible (not enough at the moment) and I am an aspiring author currently working on a few different novels. I also dabble in being a more advance home cook and baker, which you may see some posts about. Finally I like the ancient art of brewing mead, a.k.a. honey wine, and experiment with different flavour combinations and ageing times.

QueryC++ 4.0.0

09 August 2024

FINALLY!!! We are releasing QueryC++ 4.0.0 and I could not be happier and you can get it here: codeberg.org/ObsidianWolfLabs/querycpp/releases/tag/4.0.0. It has been a much slower process than I hoped and we are already working on release 4.1.0.

Sadly, the documentation is not quite ready yet for the new version, but it will be available here: querycpp-doc.obsidian-wolf-labs.com ASAP.

What have we done? A lot!

  1. We fully changed the library to use all lowercase function naming, As a request from users and this is the main reason that it is a major release… you know breaking changes.
  2. We add more functions for SQL commands. Amongst others you can now do joins.
  3. We add integration test with SQLite which also serves as our example for SQLite.
  4. We started working on our mdbook based documentation, which we will also release soon.
  5. We improved the PostgreSQL integration test and again it serves as our example for PostgresSQL.
  6. We expanded our unit tests.

Over all we are really proud of this release. This will be the last release announcement on this blog for QueryC++. The next one will be at blog.obsidian-wolf-labs.com when we get around to set up our blog there.

./Lars

The Death of Slim Shady

28 July 2024

It may come as a surprise to many, but I love Rap music. Old school rappers from the seventies and eighties, the nineties with its more aggressive and offensive rappers, all the way to modern day with Kendrick Llama. I even listen to Rap in multiple languages German, English, Danish, Spanish, and Farsi. I also listen to it in languages where I have no idea what is been said. It is the chain of words combined with the rhyme and beats that leads me to rap. In the beginning I did not know it was black music, I did not even know the artist I was listening to where black. Doc, Ice-T, and MC Hammer are just a few examples. Then in the Late ninties I heard a song called the Real Slime Shady and I was an instant Eminem fan.

Here over 2 and half decades later Eminem released a new Album called The Death of Slim Shady and frankly, I love it. But why do I love it? Well we get the best of both worlds. For those whom do not know, Slim Shady is Eminems dark alter ego. The character he use when he does very dark, aggressive, and right out horrifying rhymes. Slim Shady came in part from Eminems substance abuse and was powered through it. However, in April of 2008 he went on the straight and narrow, and have been for sixteen years now. As part of this he made some albums which focused more on the technical part of rapping rather than just being obscene. Which also left Slim Shady in the dirt. The music he has produced in this period has still been amazing to me. It has been different but amazing.

Then back in 2020 we got the album Music to be Murdered by. When I listen to this album, I felt like there was a change. It felt more like an old school Eminem album, almost like Slim Shady was rearing his head again. Even though I do not know Eminem in person, I was a little nervous if he had dabbled in substance again. But this year, he shared a post (I believe on Instagram), with his sixteen years sober token. Quite frankly amazing feat.

But why did I speak of all this, when discussing why I love the new album? Well, because we got Slim Shady back and in way I believe few expected. On the album there is a song called Houdini, for which the music video ends with Eminem and Slim Shady fuses into a single person. And that is why the album is magical, because that is what has happened it is what album gave. It gave us EminemSlimShady. He morphed his two sides and create music that was technically amazing and very old school Eminem/Slim Shady. He showed that he do not need the substances to be Slim Shady. Somehow, magically, he found a way to merge them both and create a nostalgic trip for us whom haven listen to him for ever and a new version of himself.

I hope we do not lose the very technical Eminem we got, for I love that part to. But thank you Eminem for giving us this.

./Lars

For element in range in C++

12 June 2024

While I was a teacher assistant and during my time helping new employees move from Python to C++, I have gotten one question often. Why can I not do a for loop like this for elm in range(0, 10) and you know what that is actually a fair question. In particular for arithmetic types… but what if you could part of the way?

Well first, let us look at a concept to define a type that must be an arithmetic type. This can be done fairly easy like this template<typename NumericType> concept Numeric = std::is_arithmetic<NumericType>::value;. Basically what this does is to create a type that must be numeric. I will show a little later what happens if you use one that is not.

Next let us generate the range, here I will use std::vector as my range container. This can be done very simply with the function below. This assume that start is smaller than end, otherwise it will not work.

template <Numeric T> constexpr std::vector<T> range(T start, T end)
{
    T size = end - start;
    std::vector<T> data(size);
    for (T i = 0; i < size; ++i)
    {
        data.at(i) = start + i;
    }
    return data;
}

Now let us test it. For this we will make a print_range function which takes start and end and calls range and prints the resulting “range”. Again we use the Numeric template type constrained to be a arithmetic type.

template <Numeric T> void print_range(T start, T end)
{
    std::cout << "[";
    for (const auto val : range(start, end))
    {
        std::cout << " " << std::to_string(val);
    }
    std::cout << " ]\n";
}

Finally our main function, where we test with size_t, int, and float.

int main(void)
{
    print_range(static_cast<size_t>(1), static_cast<size_t>(10));
    print_range(1, 10);
    print_range(1.0, 10.0);
}

The expected result is:

[ 1 2 3 4 5 6 7 8 9 ]
[ 1 2 3 4 5 6 7 8 9 ]
[ 1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 7.000000 8.000000 9.000000 ]

The program should be compiled with clang++ -std=c++20 or g++ -std=c++20. The full program is listed below:

#include <vector>
#include <concepts>
#include <iostream>
#include <string>

template<typename NumericType> concept Numeric = std::is_arithmetic<NumericType>::value;

template <Numeric T> constexpr std::vector<T> range(T start, T end)
{
    T size = end - start;
    std::vector<T> data(size);
    for (T i = 0; i < size; ++i)
    {
        data.at(i) = start + i;
    }
    return data;
}

template <Numeric T> void print_range(T start, T end)
{
    std::cout << "[";
    for (const auto val : range(start, end))
    {
        std::cout << " " << std::to_string(val);
    }
    std::cout << " ]\n";
}

int main(void)
{
    print_range(static_cast<size_t>(1), static_cast<size_t>(10));
    print_range(1, 10);
    print_range(1.0, 10.0);
}

Now let us say we had called print_range with "a" as start and "z" as end. Well then you would get the following compilation error:

main.cpp:34:5: error: no matching function for call to 'print_range'
   34 |     print_range("a", "z");
      |     ^~~~~~~~~~~
main.cpp:19:27: note: candidate template ignored: constraints not satisfied [with T = const char *]
   19 | template <Numeric T> void print_range(T start, T end)
      |                           ^
main.cpp:19:11: note: because 'const char *' does not satisfy 'Numeric'
   19 | template <Numeric T> void print_range(T start, T end)
      |           ^
main.cpp:6:50: note: because 'std::is_arithmetic<const char *>::value' evaluated to false
    6 | template<typename NumericType> concept Numeric = std::is_arithmetic<NumericType>::value;
      |                                                  ^
1 error generated.

Some final remarks. First,this can be made MUCH prettier (which I may show in a later post). Secondly, this is not very optimised and only serves as inspiration. Finally, play around with it.

./Lars

Screens in the class room my hot take

05 May 2024

Before we get started this post is mainly related to some discussion that have been in Denmark over the last two weeks on kids and young adults usage of screens in the classroom. Therefore, most content I will link will be in danish, sorry about that.

It has been discussed lately that screens should be completely removed from the classroom with very little, in my opinion, nuance in the discussion. So I would love to give my hot take on this and what I my qualifications for this? None, really besides having been in school before phones and computers common and being a teaching assistant (TA) in University.

In my opinion there are both pros and cons of allowing devices such as laptops, tablets, and phones being used in the classroom. But for this discussion I will actually have to divide them into two separate categories. Phones and then the rest, and more specifically personal phones and then the rest.

Personal phones have absolutely no place in the classroom, unless a parent needs to get hold of a kid/teenager in an emergency. However, here a parent can call the school and it will get hold of the student, that is possible in Denmark at least. Now why am I so against personal phones? Well, I have literally never seen a phone being used for anything relevant to the class. It has either been for gaming or social media, never anything relevant. This is distraction not only to the student using the phone but also the students sitting around the user. Even though it does not seem like it, this distributes the class and students will miss information. Furthermore, it is very annoying for the teacher/lecture as it very obvious that the student or students is not following along. First of it is a lack of respect that you so clearly show no interest in a class. Secondly, it makes the teacher feel like why the hell did I even prepare for this lecture, even if it s only one student. Thirdly, as a teacher you also know that this student will likely have very simple questions later, just because they did not follow along. You do not believe me? Try being a TA for one lecture. Finally, a thing I have heard from students and parents “It cannot be that obvious that they are using a phone”! I sadly do not remember where I have this quote from but “No one is that interested in their crotch”. Therefore, I believe that phones should not be present in a classroom. When it comes to breaks, I would prefer a strong in the moment social relations between the students and one that is not build solely on technology, but I am not sure that is feasible.

On the other hand when it comes to Tablets and Computers they have a significant usage in the classroom. Be it for not taking notes, either directly in slide PDFs or whatever fancy note program the student uses. In many cases a pen and paper could easily replace it, returning to a slide print outs is a good idea. Personally I recall better taking notes by pencil than by typing on a computer but I gather this is not for everyone. Additionally when writing reports, doing plots, slides, and so on a computer or tablet is useful. However, as a phone they can take focus from the class either by students gaming or watching videos, most of the time it is silent. But sometimes there is a constant clicking or a student saying a little to loud “nice move” or something like that, and here it become a problem. Not just for the students, but also the teacher. So computers/tablets have their pros and the cons.

But how do we solve the cons? I have two suggestion and one is rather radical so we will start with that. Government / school issued devices that has a limited amount of apps installed, with blocks for installing more, and network block of social media and online gaming sites. The devices should have the bare minimum a word processor, a spread sheet, and presentation slides. As the students mature more can be added. For instance if a student is following a STEM line biology, physics, and programming tools can be added. If in stead a economic line is followed finance applications can be added. This would to a certain extend alleviate a lot of the problem. However, I am very much against internet censorship, so this even hurt to suggest.

The less dramatic option is to confiscate the offending student(s) device for the rest of the class. A repeat offender can in the worst case be forbidden to bring devices to class for a while. Although this will limit the student to taking notes by hand, it is also a way to show that there are consequence for once actions and hopefully it would help the student grow.

Finally, it is not just teachers and schools that have to do something here. Parents also have to address their kids usage of technology and dependency on it. A human should be able to survive 45 minutes without looking at their phone or checking social media.

During my PhD I attend a talk about how the maths department had adopted a way of producing teaching material that was not more than fifteen minutes long so it fit with the modern attention span. I raised the question, if it was not wrong to adjust to this and rather we should expect more of our students. The speaker literally could not see a problem with accepting humans getting a short attention span and “we have to adopt to the needs of our students”. I highly disagree. Because most jobs require you to be able to focus for more than fifteen minutes and if the educational system do not see that, then we have a huge problem.

Technology is wonderful and powerful. But we need to address how we use it, how dependent we are on it, and how we can reduce its usage in some parts of our lives. And I mean this even comes from a Software Engineer.

./Lars

Writing my notes by hand

01 May 2024

In Why I use notebooks I discussed why I prefer physical notebooks over digital notebooks. However, I feel like it is time that I revisited this as I have gotten some findings that surprise me.

First of let talk about how I organise my notes. I have two types of not temporal and persistent. These classification are necessary as it effect where I write my notes.

Temporal notes, are notes I will only need until a task is done. This could be how a certain data protocol wants data organised in packet type A, B, and C. I am likely not needing that for a long time as I can always read the code I write later, when it is related to work. These notes I most often write on loose leafed paper or on a note block. If I believe a temporal note is worthy of being persistent I will transfer it to my persistent note storage. Which is a notebook.

Persistent notes I keep in one or more notes, I am addicted to notebooks. Persistent notes are notes where I feel this information could be useful further down the line. For work it could be a specific Software library and what it does or a software architecture and how it is defined. Privately, it could be a “journal” of a fermentation process and what I messed up in case I did.

This split between temporal and persistent notes, lets my mind run garbage collection and throw out notes I no longer need from my valuable head space. Or at least it avoids it from taking up prime seats. Additionally, by having my notes in notebooks and often sorted by topic I have the options to quickly find my notes and go through them. You could do the same on a computer of course, but there is something about the tactile feeling that makes it more fitting for me.

I even bring a notebook to meetings and take notes as detailed as possible, and I have one just for meetings. This does two things, first of it shows other participants in the meeting that I take it seriously and want to grasp what the meeting is about. I have gotten compliments on this multiple times. Secondly, it enables me to write very concise summaries of meetings, which I can then send by email to all participants so we have a record of what was agreed. We can even discuss if my notes are correct. Sometimes my meeting summaries have let to a discussion about something that was misunderstood and once (just once) have it saved my behind, because half the team had completely misunderstood a task.

Now we move on to what is actually the most important part of this for me. Recollection! I find that weeks after I have taken a note by hand and placed it in my persistent note storage, then I can actually recall it. This means that I do not need to look something up again, which then means I am saving time. And time is simply a resource you can never get back.

I am unsure if it is the tactile feeling of pen to paper that makes remember but there is something about it that is just different. I think what has changed the most is how I separate my note taking between temporal and persistent. I think it makes my brain more susceptible to remembering, but I am not sure.

I will keep updating you on how this continues for me.

./Lars