Runar Ovesen Hjerpbakk

Programmer. Software Architect. Technical Manager.

Benchmark CLI commands with hyperfine

I needed to benchmark a couple of CLI solutions today and found the wonderful tool hyperfine. It times arbitrary shell commands over multiple runs, giving you the mean execution time and other statistical variables. As command timings can vary significantly between runs, this is a live saver if you want to compare different commands with regards to run-time.

Features

  • Statistical analysis across multiple runs.
  • Support for arbitrary shell commands.
  • Constant feedback about the benchmark progress and current estimates.
  • Warmup runs can be executed before the actual benchmark.
  • Cache-clearing commands can be set up before each timing run.
  • Statistical outlier detection to detect interference from other programs and caching effects.
  • Export results to various formats: CSV, JSON, Markdown, AsciiDoc.
  • Parameterized benchmarks (e.g. vary the number of threads).
  • Cross-platform

Create a tag cloud sorted by post count in Jekyll without plugins

I previously wrote about how you can create a list of all your tags, sorted by the number of posts using Jekyll. Güngör Budak had a much better idea; create a tag cloud sorted by post count. Since this solution doesn’t require plugins, it too is compatible with GitHub Pages.

My tags now look like this, and for the first time, I’m happy with my archives page.

Sorting tags by number of posts in Jekyll without plugins

Over the years, I’ve amassed quite a few posts on this blog, but I’ve never been pleased with my Archives page. I’m still not completely satisfied, but it’s now improved by showing the tags and the number of posts in them, in addition to a chronological ordering.

I achieved this using only a Liquid template. It doesn’t use any plugins and is compatible with GitHub Pages.

Read More

Jekyll - ERROR bad Request-Line

Some of my regular readers might get déjà vu; this is the return of ERROR bad Request-Line.

Read More

Xnapshot - automated iOS screenshots

Taking screenshots of your app on every device and localization quickly becomes time-consuming. With 2 languages, 6 different iPhones and 10 screenshots, you are faced with 120 screenshots per release. If we increase the number of languages to 10 and add iPad support, this number explodes to 10 (languages) x 11 (devices) x 10 (screenshots) = 1 100 screenshots!

Xnapshot enables you to use C#, together with Xamarin.UITest, to automatically take the screenshots for you. Just derive from the abstract Screenshots class, implement one simple method per screenshot and use your time productively while your computer takes the screenshots.

Read More

Jekyll YAML front matter validator

This website is built using the excellent static site generator Jekyll. I write my posts in Markdown with a YAML front matter block that tells Jekyll these files should be processed according to the values specified. It works great but has one drawback.

What if you specify invalid values? Jekyll doesn’t care so long as the values are of the type expected by the variable. The result might not be would you’d like, but Jekyll will bravely try to build most of what you throw at it and you’ll need to visually inspect the site or the source to find errors. As a software engineer, this is no good. I need to fail fast, and if compilation does succeed, the resulting artifacts need to be verified by tests.

Enter my Jekyll YAML front matter validator.

Example

Given the following front matter:

---
categories:
- blog
layout: post
title: Jekyll YAML front matter validator
meta_description:
image: /img/
date: 2019-07-08T12:00:00.0000000+00:00
tags:
- jekyll
- dotnet
- dotnet-script
- docker
---

My validator will report the following errors:

  • meta_description is empty.
  • image contains an incomplete path that will not exist on the published site.
  • For this example, the date was also set in the future and Jekyll would not have generated the post to be published.

Read More

The SDK 'Microsoft.NET.Sdk' specified could not be found

Software sucks, every day another bug. Today the bug was in the Visual Studio for Mac package manager.

Read More

Unhandled managed exception - Default constructor not found

The Xamarin.iOS linker can be your best friend or worst enemy. It removes unused classes, methods or properties being from the DLLs in your app, thus decreasing its size. The downside is that you need to manually include code only used by reflection, serialization or other techniques hiding the code from the static analysis the linker uses. As the linker runs at AOT compile time, code only visible during runtime is skipped.

As I’ve written before, it’s easy to adjust the linker behavior, but what to do when these adjustments are not enough?

Read More

Why software sucks

I received an excellent question today:

Hey Runar, why is almost all new software and programs so ugly and difficult to use? Everything new from Microsoft or say Kongsberg looks like it’s made for Apple and it just looks horrible and has much less functionality than the older software’s had.. Any ideas?

An excellent question. And the answer depends on your perspective.

Read More

FindRef - find those references!

.Net is awesome and especially .Net Core Global Tools. Similar to npm install -g you can install tools by executing and easy command:

dotnet tool install --global [name-of-global-tool]

Running the tool is as simple as:

[name-of-global-tool] [arguments]

Just like that you get access to thousands of useful tools, without running installers or browsing to find the correct binary for your system. These tools will run on all platforms supported by .Net Core, both macOS, Windows and Linux. This is truly the power of a cross-platform, open ecosystem. The only pre-requisite is an updated .Net Core SDK installed on your machine.

Read More