Getting useful during coronavirus pandemic

Since many of us, including me, got more free time during the pandemic because the quarantine and the resulting situation, I decided to help the fight against the coronavirus by using my expertise where applicable. For free. I contributed in four projects.

  1. Joined Slovene volunteer group that decided to keep meaningful and reliable daily statistic data and models about the various aspects of the pandemic. Such data is priceless for keeping on pandemic progress. For some reason our government was and is still unable to provide this data in an useful way (initially it was much worse), hence the motivation. The website is COVID-19 Sledilnik and it is run by many great volunteers. Everything is open source as well and new volunteers are welcome to join. My part is the REST API service that converts manually collected data into a machine friendly way for data consummation. It’s an ASP.NET Core 3.1 web application packed in a docker container. It also features Swagger metadata and Prometheus support. Feel free to consume the data, but some terms apply, check FAQ.
  2. Joined a large group of volunteers and electronics enthusiasts at with 3D printing various protective visors for health workers and laser cutting the transparent part. We created and manufactured visors based on various designs with most popular being Prusa’s one. Each 3D print would take around 3 hours. We distributed for free something like 1000 complete visors before switch to injection moulding because of the huge demand, that solved the production speed greatly. Everything was given away for free and still is. We managed to send them even to a neighboring Italy.
3D printed part
Complete visor
  1. Created a 3D model for Xiaomi Mi Roborock HEPA filter adapter for Decathlon snorkeling mask extension and printed a couple of them. The mask mentioned is a full face mask that should protect one fairly well in case of various viruses, including the SARS-CoV-2. The idea is to mount it on the intake tube and protect yourself from inhaling it or getting it through eyes. The filter in question is HEPA quality, freely available, not expensive and should filter the air pretty well – the classic face masks have the problem that they don’t cover eyes and they were also unavailable due to the shortage at the time. However I never did really test it (how could I?) or wear the mask for real. It was just a fun experiment for something that might come handy in case the situation deteriorated really badly. Anyway, get the model on thingiverse.
    NOTE: You still need to print the mask adapter from the link above.
  1. Joined forces with scientists in search for a COVID-19 cure through distributed computing based on molecular docking. My part is helping them running computations on plenty of CPU cores on Azure cloud. The project is ongoing and crunching numbers as I write this.

That’s it so far. I believe I contributed quite a lot of my free time and hopefully, somebody somewhere will benefit from it health-wise. As for me, I got new experiences, expertise and met a lot of wonderful, resourceful and smart people along the path and if the effort helped even a single person, I’m happy.


Building a Raspberry PI cluster – software

  1. Building a Raspberry PI cluster
  2. Building a Raspberry PI cluster – software (this)
The last time I was writing about the hardware aspect of building a Rasberry PI based cluster. Here I’ll describe the software aspect. The installation is based on blog post by Hypriot guys. I’ll just describe my experience and changes I had to make to make it


First I had to configure mikrotik router to act like DHCP server for Rasbperry PIs and to map different ports to connected Raspberry PI’s port 22 (SSH). So I can access them through SSH and they are behind the router.

Burning Hypriot OS image to 4 SD cards

and afterwards assign each on proper hostname (master, node1 .. 3). The later is a bit different if you do it on Windows (you have to modify the configuration on each SD card instead of passing parameters to flashing tool).

Kubernetes installation

Pretty much as blog post. However, the first time I did it it wouldn’t install. Installation was stuck at waiting for kubeadm init.
The best way to figure out is to look at Docker logs for problematic containers (you’ll see them marked as restarted or failed) and inspecting kubeadm logs.

Live Writer is now open source

In case you’ve missed the announcement, Live Writer is now open source and renamed to Open Live Writer.

One of the interesing change is that it now uses Squirrel, an open source ClickOnce alternative for deployment. The other not so good change is that they temporarily removed spell checker.

Anyway, it works really fine – this and previous blog posts of mine were written using it.


My first public Android application has been published a while ago

I should have written this post months ago, I kept postponing it but now
here it is.

For the first half of the year I’ve been writing a relatively big Android
application for German Sony branch. They were promoting Sony Xperia Android line
of devices and as a part of this promotion they wanted an application that would
guide bikers through the cities of Berlin and Munich. They also arranged
rent-a-bicycle with Xperia 2 phone mounted on the cradle (cradle that would
allow charging through pedaling, no less).

The application allows user to:

  • make a reservation for free rent-a-bicycle (expired, not available any
  • selection of city (Berlin, Munich)
  • selection of three routes for each city
  • customization of predefined route points
  • rich information for every route point
  • starting, pausing and stopping route
  • voice information when either point of interest or route point Is hit
  • turn-by-turn navigation
  • 2d/3d map perspective

The application itself is written in C# with Xamarin for Android. There were two reasons for choice of Xamarin. One is multiplatform capability and the other is that I am much more skilled/productive in .net environment. The architecture of choice is, of course, MVVM (custom stuff, INPC provided by Fody) which yield numerous advantages, mostly big percentage of code sharing among different platforms (nice separation from UI) and combined with DI/IoC (Autofac) very unit-testy (Nunit, Moq). The (huge pile of) data (multimedia stuff, route points, points of interest, etc.) is loaded when application starts using HttpClient and Json.NET. If data changes, only the changes are downloaded next time to avoid data traffic as much as possible. Almost all the logic is implemented in a PCL because of portability and testability (this way one can use unit tests written in Windows library to avoid unnecessary troubles with Android world).
Besides the usual Android UI views I used Google Maps Android for map display and The Google Directions API for turn-by-turn navigation and route calculation (it requires data connection).

For debugging during the development I’ve used Genymotion, the fastest and most feature rich emulator there is. The only problem with it is that it doesn’t have Google Play support baked into Android images (it is required because of Google Maps) because of … Google legal issues, I guess. There is a workaround and everything works quite well (though Android guest might report a crash in one of Google Play applications here and there). The other part of testing was done on real devices, such as Galaxy Nexus (yes, the old one) and Xperia2 mini (the device used on rent-a-bicycles).

There were some interesting takeaways I’ve learned during the development.

  • First and most important is that Xamarin is suitable for Android development-no surprise here. I was/still am on beta channel and as all beta updates I had minor problems here and there, but only at development time. No problems for release version.
  • Double garbage collection might bite you if you are not careful. Typical example I had is that during activity creation I’ve initialized maps fragment and if activity was recreated a few times (i.e. during device rotation) the application would crash due to the out of memory exception. I wasn’t doing anything wrong but still the app kept crashing in this situation. The reason is documented but it might not be that obvious. The thing is that Xamarin doesn’t know the memory pressure (nor you can inform it, like you can with .net) when it holds reference to a Java object (i.e. maps fragment). Thus each time the activity was recreated the Java memory kept raising “dramatically” but the memory from Xamarin point of view was increased only by a reference to Java object (few bytes that is). So the Xamarin GC wasn’t aware that it held quite a lot of memory (though it knew the Xamarin objects were ready for GC) and app crashed eventually. The solution is to invoke garbage collection manually in such situations.
  • Avoid compass. Compass readings have to be avoided when moving as it just offsets the faster you go. And even when not moving, different devices might go just nuts and create all sort of false readings (calibration might help). GPS readings are much more reliable but it requires movement.
  • Good luck talking to Google for using Directions API for business

Since the Stadthelden application has been published for free in June, it was downloaded between 10.000 an 50.000 times so far. Currently it is rated 3.4 which is quite good I’d say. Some rationale for ratings really surprised me though, most interesting was a guy rating it 1 because it supports only two cities.
Anyway, overall it has been a pleasant experience developing it and using Visual Studio/Xamarin tools. If I were to do it again I’d probably go with Xamarin Forms, but that wasn’t available back then.


Annoying problem that prevented comments on blog fixed. Hopefully.

Looks like I’ve finally fixed a problem that prevented you to comment on my/this blog. It was caused by‘s TypePadFilter extension that, when unconfigured, was throwing an uncaught exception that was propagated to the user that initiated comment save.
Here is my feedback on the issue. Hopefully the crew will make the posting comment less error prone by embedding all calls to extensions with a try/catch clause.
Anyway, fire comments away – good or bad. And please, let me know if there are still problems.


Updated Righthand Intel Rapid Storage Technology cmdlet

Version 1.1. brings new Get-IrstDisk cmdlet that lists physical disks. Also upgraded to the latest IRST version.

Check out the dedicate page.


Powershell version for Righthand Intel Rapid Storage Technology

Since few guys asked if I’ll be releasing new command line utilities for Intel Rapid Storage Technologies I’ve decided to refresh those old utilities with a fresh Powershell v3 version.

Check out the dedicate page.


Tips for Setting Git on Windows for SSH

Last weekend I took some time to configure Git (and Gitolite for easier repository access management) on my Ubuntu server. It was a fun experience for a Linux newbie. Anyway, here are a bunch of things to watch out when configuring Git client on Windows.

If you want to use OpenSSH (SSH that comes with Git)

  1. Always generate public/private key pair using ssh-keygen -r rsa even when using PuTTY. (I initially made a mistake because I used Puttygen).
  2. Set the environment variable HOME=C:\Users\[USERNAME], this variable isn’t set by default. SSH looks for private keys in the C:\Users\[USERNAME]\.ssh folder. Not sure whether there are options to instruct it to looks elsewhere.
  3. Use default key name which is id_rsa. From what I can tell SSH looks for identity and id_rsa names (no suffixes).

When using PuTTY (an alternative to OpenSSH)

  1. Set environment variable GIT_SSH = C:\Program Files (x86)\PuTTY\plink.exe (path valid for x64 system). This variable will tell Git what library to use for SSH communication.
  2. Run Pageant (part of PuTTY distribution) which will handle your private keys. Added bonus is that you don’t have to repeat passphrase to private key when accessing it (granted you set the passphrase when you created the key – always a good practice).

Other tip would include trying the SSH connection to the server first using verbose output: SSH -vvv [USERONSERVER]@[SERVER]. This output helps to a certain extent.


Defining custom regions in TypeScript files and preserving their content during CodeSmith template based code generation

I am looking to do some TypeScript code generation with CodeSmith and I’d like to use PreserveMerge merging strategy(preserve merge preserves your custom code within generated code between regenerations). CodeSmith’s merging mechanism is powerful and flexible (besides preserve it supports insert merge strategy as well. But if you feel constrained then feel free to create your own merging strategy). Out of the box it supports C#, VB.NET, XML and T-SQL start region and end region notation. This is a problem for TypeScript because, it can’t use any of those with TypeScript files hence I have to define my own start and end region keywords.

So I came up with

/// #region [Name]


/// #endregion

notations – TypeScript will ignore them (as comments) and they are explicit enough. Nothing Earth shattering but they should do the job for me.

Definining new region keywords for CodeSmith

Now I have to update CodeSmith with my these new TypeScript region keywords.

CodeSmith uses regular expressions for searching region keywords. They are defined in registry under the key HKEY_CURRENT_USER\Software\CodeSmith\<VERSION>\LanguageRegionDefinition. Here is a C# definition


The definition consists of LanguageKeys, RegionStartRegex and RegionEndRegex. Pretty much self-explanatory.

Here is my TypeScript entry under next available number 4 (also attached to this post):

LanguageKeys: Typescript|TS
RegionStartRegex: ^[ \t]*///[ \t]*\#region(?:[ \t]*(?<name>[^\r\n]*))?[ \t]*\r?\n
RegionEndRegex: ^[ \t]*///[ \t]*\#endregion[ \t]*\r?\n

Creating the node 4 as a sibling to other region definitions does the trick. Note: LanguageKeys is important when you set the merge strategy (you can use any of strings that are pipe delimited: either TypeScript or TS in my case).

Using regions in TypeScript generated code

Let’s create a very simple proof of concept (the project is attached to this post).

First create new console project and then add a CodeSmith template for TypeScript code. As a TargetLanguage you could put “TypeScript” even though CodeSmith doesn’t really know how to syntax color it. It is just a hint for CodeSmith. Place one or more region delimiters within template (mine is really simple one, just to show the concept), here is my template:

<%@ Template Language=”C#” TargetLanguage=”TypeScript” Debug=”False” %>

module RegionTest {
  function tubo(){
    var i = 5;
    /// #region Test
    /// #endregion

Add CodeSmith project file and add the above template as an output. In the Edit Output settings set the proper output file name (test.ts in my case), Merge type as “PreserveRegions” and Initialization string as “RegionNameRegex=.*;” or “RegionNameRegex=.*;Language=TypeScript;” if you didn’t set it as TargetLanguage (it defaults to template’s TargetLanguage when not defined). RegionNameRegex gives you a chance to use only selected region names for preserve strategy – in my case any name or no name will do. Below are my Edit Output settings.


Generate the code, the output content should appear just like the template definition since there is no real code generation.

Add custom code within the Test region in generated test.ts file (not in template), like:

/// #region Test
alert ("wow, this is really a persistent alert");
/// #endregion

And generate the code once more. If everything is in place the new output should have persisted the custom code of the Test region.



To enable CodeSmith’s PreserveRegion merging strategy in an unsuported TypeScript language I had to add a registry key and that’s it. The simplicity of making a language supported in this case shows the CodeSmith flexibility and power and the CodeSmith’s use or registry shows bad practice Smile they should really use files instead of registry (hint). (20.95 kb)

typescrip-regions.reg (614.00 bytes)


Blog engine’s e-mail problems

For some reason I didn’t notice that my blog engine wasn’t properly notifying me of your comments sent through Contact page and thus I was actually unaware of any comment sent.

Hence I apologize to everybody that contacted me and got no response.

I am pretty sure the notification system is working properly now.