Runar Ovesen Hjerpbakk

Programmer. Software Architect. Technical Manager.

Remove local branches not present on GitHub

I mostly use GitHub’s desktop client while working with GitHub repositories. This means that I get less exposure to the git CLI (command line interface) commands than perhaps is healthy.

But sometimes even I need to go old school.

Read More

Make your code more beautiful with the Fira Code typeface

Beautiful code: typography and visual programming by Peter Hilton was one of the best talks at NDC Oslo this summer.

Peter talked about how layout and typography can make code beautiful and improve code readability. After all, as Knuth pointed out:

Programs are meant to be read by humans, and only incidentally for computers to execute.

So how can one improve a monospaced programmer focused typeface?

By utilising ligatures of course!

Read More

Lookup IP from DNS name

As you can read from this blog, operations was never my main interest. But in these days of DevOps, I’m getting exposed to more hosting environments than I’ve ever been before.

Since I was a small child I knew about ping to check if a server was online and see its IP-address. Today I learned about nslookup.

Read More

Don’t commit launch.json

You’ll remember that I recently experienced a snag while working on the same dotnet script script(!?!) on two different machines. During the project, I updated dotnet script on one machine but forgot to do it on the other. I wrote in my post that the solution was just to remember to upgrade on all machines, but Bernhard recommended a better solution.

Read More

Converting a HTML table to Markdown using dotnet script

Working with software integrations can be both interesting, fun and mind-boggling frustrating. Today I needed to parse a table in a website (first mistake), clean the text using regular expressions (second mistake?) and generate a corresponding table in Markdown using dotnet script (definitely not a mistake).

Read More

Creating an ASP.Net Core app with a React frontend and Docker hosting

I started a new project this week, a SPA written in React with an ASP.Net Core 2.1.1 backend hosted in a Docker container. This is the tale of how I got all those pieces working together.

The running code from this article can be seen on GitHub.

Read More

Simplify your crontab entries with

As you’ve seen from my previous posts, I’ve used cron a lot lately to schedule periodic tasks on my RaspberryPi. cron is driven by crontab, cron table files, configuration files that specifies shell commands to run periodically on a given schedule.

# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday; 
# │ │ │ │ │              7 is also Sunday on Raspbian)
# │ │ │ │ │
# │ │ │ │ │
# * * * * *  command to execute

The timing syntax is understandable enough. In addition to numbers, we can use special operators:

*	any value
,	value list separator
-	range of values
/	step values

An expression to achieve At 22:00 on every day-of-week from Monday through Friday looks like this:

0 22 * * 1-5

My problem is that I get the elements confused. Without reading the explanation, is 22 in the expression above minute or hour? You have to read the spec to find out.

Read More

The application to execute does not exist

I really do love dotnet-script and its almost perfect integration with Visual Studio Code. But as it is a .Net Core global tool, and VSCode uses file-based task specifications which know nothing of this, things can sometimes break.

I’ve create a simple script for giving me a nice text to share whenever I post a new post to this site. Sure, this can be further automated, but you’ve got to start someplace.

For development I use two different Macs, an iMac at home and a MacBook Pro during my commute. I started coding this on my iMac, but on my ride to work I got this error while trying to debug from VSCode on my MacBook Pro:

The application to execute does not exist: '/Users/sankra/.dotnet/tools/.store/dotnet-script/0.25.0/dotnet-script/0.25.0/tools/netcoreapp2.1/any/dotnet-script.dll'
The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.
The program '[41202] dotnet' has exited with code 129 (0x81).

The script ran fine from the shell using dotnet script main.csx . So what is the cause of this error?

Read More

Automatically purge changed pages from the Cloudflare cache when adding a new post to Jekyll

This site is built with Jekyll, hosted on GitHub Pages, has DNS through Hover and is served by the Cloudflare CDN. The site is static, that is all pages are rendered ahead of time on the server. That means that even the simplest web server in the world could host without issue. So why is Cloudflare a part of this stack?

I put it behind Cloudflare for three reasons:

  • Real simple TLS
  • Security, Cloudflare can protect you from DDoS attacks (not that this is an issue for me) and has a looong list of known bad players which are blocked from accessing your site.
  • Performance, Cloudflare has a global CDN and an excellent cache. Thus, your own server is hit far less than without this outer layer.

Since Cloudflare has a cache, how do you make sure the right parts of the cache are invalidated when you create new content? With a simple dotnet script that’s how!

Read More

Shrinking a Raspbian installation to save space

Yet another Pi post!

When I put Raspbian on the SD card used by my Raspberry Pi, I used the Raspbian Stretch with desktop version. That was perhaps a poor choice on my part, as I use the machine as a headless server. However, I’m not that skilled with Desktop Linux, so the mere fact that there were buttons to push during the installation and stuff actually worked, made me feel like a pro.

All those packages that I’ll never use, like LibreOffice, still take up precious space, so I wrote a simple script to remove some of them.

Read More