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.


Sometimes (Visual Studio) error messages are just misleading

Take into account this code

    () =>
        throw new Exception();
        t =>

Which results in following error:

error CS1593: Delegate ‘System.Action<System.Threading.Tasks.Task,object>’ does not take 1 arguments

If I use an overload that takes TaskContinuationOptions.OnlyOnFaulted instead of TaskScheduler.FromCurrentSynchronizationContext it just works. There are two overloads (among twenty of them) of ContinueWith:

public Task ContinueWith(Action<Task> continuationAction, TaskContinuationOptions continuationOptions);
public Task ContinueWith(Action<Task> continuationAction, TaskScheduler scheduler);

So, why does the later work and the former doesn’t? Can you guess without reading on?

The explanation is really simple – TaskScheduler.FromCurrentSynchronizationContext is not a property but a method and thus it should be used like TaskScheduler.FromCurrentSynchronizationContext(). Once brackets are in place it works. Rookie mistake.

However the C# compiler’s error message is misleading in this case. Instead of reporting that FromCurrentSynchronizationContext is a method and not a property it yields “can’t find proper overloaded method”. At least it could yield both errors.