Roll Over Baby

Some people were scared of year 2000 bugs. Some people dread NTP rollover in 2036. Some are scared of Unix epoch rollover in 2038. And some are swearing at their GPS because of 2019 rollover.

Realistically, if your GPS was manufactured in this century, chances are that you won’t even notice anything happened. No user action is needed nor expected. If you have old GPS that hasn’t received update in a while - congratulations - you have yourself a brick.

You see, due to a quirk of design, original GPS message format has a 10-bit week number. That gives you 1024 weeks or about 20 years before it needs to roll back to 0. As GPS needs correct time not only for display but also for determining actual position, if clock is off by 20 years or so, navigation is going to be almost as bad as using Apple Maps.

On a bright side, every GPS I ever owned (going back to original Garmin eTrex) is actually quite capable of dealing with this rollover without breaking a sweat - even with their original firmware. This is not a first rodeo for any decent manufacturer and thus, baring some unexpected bugs, a normal user can be oblivious to this problem.

If you need to deal with old industrial equipment that was installed under Roman emperor and last had its firmware upgraded in middle ages, you might want to heed warnings and check anything that’s really critical. But my guess all such users were aware of this for a long time now.

PS: Since newer GPS devices already have support for 13-bit week format giving you about 150 years between rollovers, I doubt anybody will be worried for next 10-bit rollover in 2038. Anyhow, for that year, we have a bigger fish to fry.

PS: Actually, on most of GPS devices only consequence of non-update firmware is just a wrong date.

Visual Studio 2019

Illustration

Visual Studio 2019 is among us and, thanks to multiple release previews, it seems as it was always here. From C# developer point of view, it’s not a revolution but a nice, steady improvement.

The first change you will notice is the new Start window. While it can get crowded if you deal with a lot of projects and it could definitely use a search function, it’s much better than what Visual Studio 2017 had to offer.

The next visual change is that menu got merged with title bar. While this has no functional impact on menu management, it does provide your editor with much needed vertical space. You can see that this was coded by young developers as you cannot blindly double-click at 0,0 to close solution anymore.

The most important new feature for me as a C# developer is break point on data. While I didn’t need it often, I definitely felt C++ envy when I did. Now C# developers can simply set a single breakpoint on data itself instead peppering bunch of them all over the code hoping to catch the rogue update.

Visual Studio Live Share is feature I could see used massively in teaching environment. A long time ago I taught coding and the most difficult part was going over examples on projected screen. It was annoying having to setup Visual Studio specially for projector (e.g. text size) instead of my standard environment. Now presenter gets to work in his own environment and each other connected party (read-only or editable) gets to use their settings too. Pure comfort. :)

There is quite a few other improvements, be it in performance or new flows and you can check release notes for more information.

Or, since Download is available, install and enjoy!

Replacing Bitmap In-Place

Illustration

Sometime even the simplest application can cause the exception. For example let’s just open an image, edit it, and save it afterward. Something like this:

var image = new Bitmap("test.jpg");
// do something with image
image.Save("test.jpg");

This code will throw the really helpful “A generic error occurred in GDI+.” exception.

Fortunately, there is more than one way to skin this cat. Rather similar (and equivalent) code will work:

Bitmap image;
using (var stream = new FileStream("test.jpg", FileMode.Open)) {
    image = (Bitmap)Bitmap.FromStream(stream);
}
// do something with image
image.Save("test.jpg");

A slightly different embodiment of the same idea.

Appending to Certificate Bundle

When one needs to add an extra certificate to a certificate bundle, the first idea might be something like this:

cat example.pem >> /etc/ssl/certs/ca-bundle.crt

And that will work - if you are a root user. However, if you are just a sudoer, or God-forbid a cloud-user, you might find yourself up the creek without a paddle.

You see, sudo won’t simply do as it operates on the source and not the destination:

sudo cat example.pem >> /etc/ssl/certs/ca-bundle.crt
 -bash: /etc/ssl/certs/ca-bundle.crt: Permission denied

You might want to play with tee, but depending on your exact permissions that might fail also.

cat example.pem | sudo tee -a /etc/ssl/certs/ca-bundle.crt

However, one command that never fails is vi as it has quite a lot of code to work out writing to read-only files. And conveniently, we can script it too:

sudo ex +"r /opt/install/ca.pem" -scwq! /etc/ssl/certs/ca-bundle.crt

Yep, we essentially start vi, read the extra content into it, and then force-save it all.

Configuring Thumb Button on M720 Under Ubuntu

The most usable function I found for my mouse thumb button is actually Minimize window. When you combine it with Alt+Tab, it does wonders for fast window switching. Under Windows it’s trivial to configure this within Logitech Options. While not as easy in Linux, it’s actually not that hard either.

Since the Thumb button on most Logitech’s devices is not a mouse button but a key combination, we can use Ubuntu’s built-in Keyboard utility instead of remapping buttons. Or we can do it from command line equally easy:

gsettings set org.gnome.desktop.wm.keybindings minimize "['<Primary><Alt>Tab']"

If you really want to have quick switching, you might want to also disable animations:

gsettings set org.gnome.desktop.interface enable-animations false

With those two changes you have your thumb button configured.

PS: And yes, this works for MX Master too.