Dealing With Injuries

Posted on 4th of June 2022 | 918 words

Climbing and training for it have been my “mainstay” for quite some time. Naturally, when I have to stay away from it, it’ll start affecting me in one way or another. Especially these last couple of years have been relatively tough in this sense since, naturally, due to COVID: I’ve had to stay away from training, mainly due to external restrictions, closed gyms, and so on. Unfortunately, alongside this, I’ve had to live with a couple of injuries simultaneously.

First, I had a nasty fall while bouldering outside in 2019. While the fall itself was similar to many other falls that I had already had during that day, this time, I just fell a little bit awkwardly on my pads and dislocated my ankle and had two minor fractures to it at the same time. Thankfully nothing too major that a cast, rest and some rehab couldn’t fix it. But the timing of this was really unfortunate since it was very close to all this COVID non-sense, which meant that gyms in Finland started to close down, which then affected my recovery a little bit since I couldn’t get back to my regular training. Thankfully I was able to recover from my ankle issues quite nicely, albeit mobility is still a little bit worse than in my other ankle, but it is usable, at least.

During 2020 and 2021, COVID in Finland was going in waves, so we had a couple of months with no cases around, and then a couple of months later, there were hundreds of cases around. So during these “good months”, gyms were open, so I could at least train a little bit. But since COVID was still very present, and the training was quite haphazard for me. Meaning during the “busy hours”, I often didn’t want to go to the gym since there were so many people around. So there wasn’t really any regularity to my training which was a shame until around the second half of 2021.

Then, of course, I had to stumble upon a new injury around the end of 2021. This time a pulley injury on my right ring finger’s A3. So again, I had to take a couple of weeks off. Again the timing was quite unfortunate since, during the same time, COVID cases were rising in Finland and gyms had to close down again. Which again hindered my recovery.

During the first half of 2022, I also moved to Berlin, so I needed to find a new gym which basically meant finding a new “community”. Thankfully, I could get back into the groove of training in the months I’ve been living here. Unfortunately, again, after a couple weeks of training, I had a minor injury. This time a minor tear/sprain on my right knee’s LCL. Thankfully this time, it should be slightly more minor than my last two injuries so it should be healed in a couple of weeks, RICE (Rest, Ice, Compression, Elevate) and some physiotherapy/rehab.

Speaking only on my behalf (albeit I do believe that many other “athletes” feel the same), being on the disabled list definitely puts a toll on me. Mainly because while I’m injured, I can’t experience life the way I want. Why is it so? Of course, there are natural factors like pain and damage that will, of course, affect anyone experiencing those one way or another. Also, everything relating to those, like medical appointments.

But I would say climbing (alongside many other things like music) is part of my identity. So when I’m injured, I always feel that I’m losing some aspect of my whole identity. This kind of behaviour can often lead to a situation where the “athlete” tries to train through the injury, and often, making things only worse. Tied to this, being unable to do something that plays a significant part in your life can easily lead to hopelessness and loss of purpose.

Most importantly, I feel that connection plays the most prominent aspect in this. When “an athlete” is injured, they can often feel the loss of connection, especially if the community around your sport/activity is very tightly knit (like it tends to be in climbing, for example). So the fact that you need to sit out training sessions that you usually do with your “community” can significantly affect your mentality.

This one was especially crucial for me in these early months of 2022 since I had just moved to a new country, new town, without too much of connections (outside work at least). I already felt that I had become a part of the local climbing community, and after my injury, I already thought I couldn’t be a part of it. Thankfully in my case, the injury rehab and recovery time was relatively short, so I didn’t need to worry too much, but things could be worse.

But can you get away from this mindset? I think, first and foremost you need to respect your body and try to understand that even though you might not be able to take part in the activity that forms part of your identity, it doesn’t take anything away from it. Instead, try to focus your energy on healing and rehabbing so that eventually, when you’re healed, you can return even stronger. Also, when it comes to communal aspects of this, personally, I believe that isolating away from others is a big mistake. Instead you should try to champion others and give back to it as much as possible.


Now Page

Posted on 3rd of June 2022 | 200 words

My “now page” can be found here

So I decided to join the ranks of a bunch of “cool people” and create my “now page”. While my direct home page (root of this site) works as what most people could call “about” page, I feel that the “now page” reflects a little bit better on what I’m doing at this very moment. A similar effect could be achieved with random ramblings on some social media platforms, but personally I just want to stay away from those as much as possible.

That being said, most of the posts that I stumbled upon in those platforms - when I was still on those - were often related to relatively small events with a couple of big news here and there. “Now page” reflects the “big picture” a little bit better, which is why it works nicely for sharing with people I haven’t met in a long time.

With this kind of page, I believe it’ll also work to remind me of my current priorities. So if I stumble upon something new and exciting, I can reflect these on my “now page” to see if it fits there or not. Further reading:


Symbolics Graphics Reel 1989

Posted on 25th of April 2022 | 26 words

This is a collection of promotional and commercial work done by the Symbolics Graphics Division (and customers) showing off the capabilities of the Symbolics LISP Machine.

Youtube video

Table-Driven Testing in C++

Posted on 24th of April 2022 | 700 words

I’ve always found tremendous value in testing my software. Especially what might be closest to home for developers - or at least should be - are unit tests. While unit tests are not necessarily the best way of making safe working code (this often requires a little bit more exhaustive testing) but at least they’re very beneficial for your future self and/or co-workers who might be working with your code since with them you can quickly see any new errors that might’ve come from regression.

That being said, often, writing unit tests can be quite cumbersome. I would love to see some mature tooling for randomized testing like QuickCheck in Haskell (and later some other languages too) that would “just work”, but often something like that just isn’t possible, especially when the project reaches a certain degree of complexity. Tests and test suites should be designed on their own as well as your code itself. Unfortunately, people tend to forget this. In these kinds of cases, quite simple table-driven test design can come to help!

I first stumbled upon table-driven test design when I was working with Go, since in there, this seems to be a quite popular way of doing unit tests, and at least, in my opinion, it works quite nicely!

Often while writing unit tests, you would want to write various failing and passing test cases, which often leads to quite a bit of duplication. For example:

TEST(TwoSumTests, PassingTest) {
  std::vector<int> nums{2, 7, 11, 15};
  auto got = twoSum(nums, 9);
  std::vector<int> expected{0, 1};
  EXPECT_EQ(got, expected);
}

TEST(TwoSumTests, FailingTest) {
  std::vector<int> nums{2, 7, 11, 15};
  auto got = twoSum(nums, 9);
  std::vector<int> expected{0, 123};
  EXPECT_NEQ(got, expected);
}

So even with this elementary example, we can see that most of the code in the test case is duplicated and/or boilerplate. So we can do better. For example, with quite a simple table for tests, we can loop through multiple tests without duplication and easily add new tests.

Regarding testing functions, we often care about what is going in and what should go out. Everything else in unit tests is often boilerplate. So where table-driven design help in setting up these input and expected outputs.

typedef struct {
  std::vector<int> nums;
  int target;
  std::vector<int> expected;
} twoSumTestCase;

TEST(TwoSumTests, BasicAssertions) {
  twoSumTestCase tests[] = {
    {
      std::vector<int>{2, 7, 11, 15},
      9,
      std::vector<int>{0, 1},
    },
    {
      std::vector<int>{3, 2, 4},
      6,
      std::vector<int>{1, 2},
    },
    {
      std::vector<int>{3, 3},
      6,
      std::vector<int>{0, 1},
    },
  };
  for (auto t : tests) {
    auto got = twoSum(t.nums, t.target);
    EXPECT_EQ(got, t.expected);
  }
}

So when we run this we can easily run all the tests at once:

[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from TwoSumTests
[ RUN      ] TwoSumTests.BasicAssertions
[       OK ] TwoSumTests.BasicAssertions (0 ms)
[----------] 1 test from TwoSumTests (0 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (0 ms total)
[  PASSED  ] 1 test.

To demonstrate failing test case, let’s add new test there:

{
  std::vector<int>{3, 3},
  6,
  std::vector<int>{0, 2},
},

We get the following output:

Expected equality of these values:
  got
    Which is: { 0, 1 }
  t.expected
    Which is: { 0, 2 }
[  FAILED  ] TwoSumTests.BasicAssertions (0 ms)
[----------] 1 test from TwoSumTests (0 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (0 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] TwoSumTests.BasicAssertions

 1 FAILED TEST

Extending test cases

Of course, with that information, test logs can be pretty misleading. Thankfully, we can just change the table to our liking. For example, we could add names to the tests:

typedef struct {
  std::string name;
  std::vector<int> nums;
  int target;
  std::vector<int> expected;
} twoSumTestCases;

That we could then use on diagnostic messages in GTest’s macros:

EXPECT_TRUE(false) << "diagnostic message"; // format to your liking

With this kind of formatting, we easily extend these test cases with just playing around a little bit with your test struct, so it could involve enumeration, subtests and much more. Which could help you making your tests/code easier to fix, but also easier for adding new useful and good tests.


Showing Now Playing with Hugo

Posted on 6th of April 2022 | 151 words

So I wanted to add a “Now playing” footer to my posts so I can easily share the music I’m listening to. Maybe some people can find something new and exciting with that, so I implemented a very quick and poor man’s implementation for it! I only play with YouTube’s search_query URL parameter and pass in the song to that from the Hugo post’s front matter. I pass in the current song as a slice in the post’s front matter similar to this:

---
nowPlaying: ["DAF", "Liebe auf den Erste Blick"]
---

Then I just parse that in the template:

{{ if .Params.nowPlaying }}
{{ $artist := index .Params.nowPlaying 0 }}
{{ $song := index .Params.nowPlaying 1 }}
{{ $query := querify "search_query" ( printf "%s %s" $artist $song ) "search_type" "videos" }}
<a href="https://www.youtube.com/results?{{ $query | safeURL }}" target="_blank">
  {{ $artist }} - {{ $song }}
</a>
{{ end }}