Runar Ovesen Hjerpbakk

Programmer. Software Architect. Technical Manager.


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

Signing commits using GitHub Desktop on macOS

This morning I got inspired by Phil Haack’s post on proving the identity of package authors. How can you know people are who they say they are online? A step of the way is a social proof, that is you link your identity on many different services together, thus increasing the certainty that you are you for every service added.

The place to tie these identities together is

So not only did I install and join Keybase, I decided to begin signing my Git commits with my PGP-key. Signed commits on GitHub gets a nice Verified badge when the key used to sign the commit matches that registered on the given user’s profile.

This increases the public’s confidence that the commit was indeed submitted by the actual person, and when this again can be verified on services like Keybase we’re almost there.

Setup commit signing

The following is a guide to setup automatic signing of commits on macOS. It even works with the GitHub Desktop app!

Read More

Script for creating transparent PNGs

Introducing transparent-png, a simple Python script for creating a transparent PNG of a given size.

Read More

How to edit the Open Folder in Visual Studio Code macOS service

Got a question from andrewb273 on GitHub regarding my macOS service which opens a folder in Visual Studio Code:

Can you add the source code for this extension and instructions on building it?


Read More

Use Caps Lock as Escape in macOS

On Touch Bar enabled Macs, the Escape key has been removed and replaced by a Touch Bar software button. As a developer, this sucks. I use Escape all the time and need a proper button.

Luckily, this is easy to fix.

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

Remove stuck Launchpad progress bar from the Dock on macOS

I’m one of those guys who actually keeps the Launchpad icon in the dock on macOS. I have it there to see the progress of installations of apps and updates from the App Store.

And it seems that not many people does this, for every so often the progress bar hangs. That is, it is there, empty, never going away. I’ve reported this to Apple through their Bug Reporter, but the problem has persisted through many versions of macOS.

Read More

Visual Studio Code failed to start on macOS

One day Visual Studio Code (VS Code) did not start on my Mac.

Read More

Bartender organizes your menu bar apps

Not only does this app have the most awesome name, it’s also extremely useful! Bartender enables you to show, hide or remove macOS menu bar items giving your desktop that clean look you’re craving.

This is my menu bar right now, containing only my most used menu bar items.

Bartender organizes your menu bar items

The dotted button is the Bartender menu bar item. Push it to toggle the Bartender menu to reveal the hidden items:

The Bartender menu

My menu bar went from trash heap to Zen garden in an instant 😃

Rocket is my new favourite macOS app

Rocket is my new favorite app for macOS. It provides Slack-style emoji in any app! It lives in the menu bar and simply pops up a palette whenever you type a colon. Thus giving you the option of inserting a clarifying emoji or a snarky gif wherever you want.

I mean, look at it:

Slack-style emoji throughout macOS

Thinking different about groups and tags in DevonThink

I’ve ditched Evernote as a knowledge manager and I’m now trying out DEVONthink for macOS and iOS.

Thus, I’ve been pondering the difference between groups (folders) and tags, and when either should be used. Arno had an interesting take:

Think of the group structure in a DevonThink database as a catalog rather than as the place where your documents are stored

Use DevonThink’s groups to tag your documents by topic

Use DevonThink’s tags to flag documents for special purposes

Using groups to store documents by topic and tags to actualize them while working on projects is something I’ll try from now on.

Open folder in Visual Studio Code from the Finder

As a Christmas gift for you my dear readers, I’ve fixed the bug you all wanted to be fixed. Now the Open in Visual Studio Code macOS service no longer opens a previously opened folder together with the folder you wanted.

Thus, this service now works as advertised! Happy coding 😉

Read More

Make the macOS firewall to permanently allow iOS apps running in the simulator

macOS has an awesome firewall, however the default setting is very harsh for us iOS developers.

Read More

Open folder in Visual Studio Code from the Finder

When working on many simultaneous projects with Visual Studio Code (VS Code), it is convenient having a fast way of opening the project folders. With the open from the terminal shell extension, and the macOS service below, your project folders can be opened from both the Terminal and the Finder.

Read More

WiFi login on OS X

Lately I've been having a first world problem with my 13" Retina MacBook Pro: Safari refuses to load the login page of WiFi Hotspots it has been previously connected to. Quite a hassle in airports and coffee shops.

Safari shows this success-dialog when connecting, but there is no Internet.

Success dialog without success

The solution was to abandon Safari and go to a random URL with another browser. Using Firefox makes this dialog appear at my local airport.

Firefox with login page

Read More

New features in FermiContainer 1.1

FermiContainer gains features, but while doing so becomes even more simple. How is this possible? Let me tell you:

Automatic resolving of constructor arguments

Through constructor injection, the dependencies known to the container are automatically resolved. No attributes or XML configuration are needed.

public void Register_EvenMoreComplexClass_CanBeResolved() {
  m_fermiContainer.Register<IEvenMoreComplex, EvenMoreComplex>();
  m_fermiContainer.Register<ICalculator, Calculator>();
  m_fermiContainer.Register<IComplex, ComplexClass>();

  var complexInstance = m_fermiContainer.Resolve<IEvenMoreComplex>();


public interface ICalculator {}

public class Calculator : ICalculator {}

public interface IComplex {}

public class ComplexClass : IComplex {
  public ComplexClass(ICalculator calculator) {}

public interface IEvenMoreComplex {}

public class EvenMoreComplex : IEvenMoreComplex {
  public EvenMoreComplex(
    IComplex complex, I
    Calculator calculator, 
    ClassWithoutInterface classWithoutInterface) {}

public class ClassWithoutInterface {}>

Default container instance

var instance = FermiContainer.DefaultInstance;

Assert.AreSame(instance, FermiContainer.DefaultInstance);

Easier to extend

The Services dictionary is now protected so FermiContainer is easily extendable.

Better performance

C# expressions makes FermiContainer very performant.

Available as source through NuGet

PM> Install-Package FermiContainer.Sources

Read More

Introducing FermiContainer - an IoC container for the rest of us

Fermicontainer icon

What the world needs most is more IoC containers in the .Net space.

So I created FermiContianer, the simples IoC container imaginable.

It supports registering implementations of interface using either a default constructor or a factory method.

IFermiContainer fermiContainer = new FermiContainer();

fermiContainer.Register<ICalculator, Calculator>();

Resolve gives you a new instance each time.

var calculator = fermiContainer.Resolve<ICalculator>();


var calculator2 = fermiContainer.Resolve<ICalculator>();

Assert.AreNotSame(calculator, calculator2);

Singleton will return the same instance.

var calculator = fermiContainer.Singleton<ICalculator>();

var calculator2 = fermiContainer.Singleton<ICalculator>();

Assert.AreSame(calculator, calculator2);

That's it! Available through NuGet for for .Net 4.0 or later, Xamarin.iOS, Xamarin.Mac, Xamarin.Android, Windows 8, Windows Phone 8, Windows Store apps and Silverlight 5. The source lives on GitHub.

PM> Install-Package FermiContainer

If FermiContainer ever becomes too simple for your needs, I recommend LightInject.

Read More

Xamarin.Forms and iOS Simulator Scrolling

Here are a couple of Xamarin quick tips i have found useful the last couple of days.

iOS simulator refuses to scroll

If your iOS simulator refuses to scroll your ListView or TableView, try restarting it. The simulator sometimes locks up and disables scrolling for some reason. This has only happened during my Xamarin.Forms development, but I have no clue as of the source.

Open another instance of Xamarin Studio

To open another instance of Xamarin Studio on OS X, use the following command in the

open -n "/Applications/Xamarin"

To open another instance of Xamarin Studio on OS X, use the following command in the

open -n "/Applications/Xamarin"

Given that Xamarin Studio is in its default location. Sometimes Unix can be useful, who knew? 😬

Read More

OS X script for fetching App Store icons

Via Brett Terpstra:

I wrote a quick script to allow me to search for an iOS app by name and instantly write its 1024px version (or the highest resolution available) to the current directory in Terminal. There’s also an OS X application version at the end of this post, so you can perform this trick without needing the command line at all.

I came across this nice OS X script for fetching the logo from your favorite app in App Store. Works great!

iOS Simulator scaling on a retina display


If the iOS Simulator scaling is set to 75% or 100% on a non-retina display, scale it to 50% before moving it to a retina display.


One of the biggest advantages of a Retina MacBook Pro is that the iOS Simulator can run at 100% resolution and you get a good feel for what your app will look like on the real device. Running the simulator on an external display, you often need to scale down the window to 75% or 50% in order to view the whole thing.

100 scaling quite large

If the simulator scaling is set to 100% or 75% on a non-retina display, it will retain its seemingly large size when moved to the retina display.

Double retina, not exactly useful


Before moving the simulator to a retina display, set the scaling to 50%. The simulator will detect the retina display and set its scaling to 100%.


Exactly as we want.



The iOS Simulator only seems to auto scale if its scaling is set to 50% on a non-retina display.

Read More

Remove duplicated entries for same application in Finder context menu


Multiple duplicated entries for the same application in the OS X Finder Open With context menu. I first noticed this after upgrading to Mountain Lion (10.8).

Duplicate entries pre


  1. Open
  2. Run the following command:
/System/Library/Frameworks/CoreServices.framework//Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain user

The lsregister command is used to query and reset the Launch Service database. This is the database used to determine the default application and it controls the contents of the Open With context menu.

  • -kill resets the Launch Services database before doing anything else
  • -r performs a recursive directory scan, but does not recurse into packages or invisible directories
  • -domain local -domain user specifies the domains in which the command should be run. Local and User should suffice.

The result can be seen in the screenshot below. All the duplicated entries from before are now gone.

Duplicate entries post

For more information, read lsregister: How Files Are Handled in Mac OS X.


Still unknown, but the problem has yet to reappear. This reminds of the Everything's broken and nobody's upset post by Scott Hanselman.

The answer? Uninstall, reinstall, stop, start, restart.

Read More

Optimize SVG images for retina displays

As high DPI screens are becoming more and more common, it is necessary to improve the images around the web to look great on these new screens and not just the low DPI screens of the past. Guides like this can be used when dealing with ordinary raster images.


Another solution is to create vector graphics, for example in the SVG format. Vector images can look equally great in any resolution and at any DPI. The caveat is that the image depicted must be usable even when rendered using few pixels on low DPI displays. Thus the format is best used for icons and images without a lot of stuff going on. In the example to the right you see that the upper text on the bottle is unreadable when zoomed out.

After you have created your SVG image, you should make sure that it has the smallest file size possible. Just as we have done with raster images since forever by using tools like ImageOptim and its like.

To minimize the SVG's file size, I use the python script Scour - an SVG scrubber.

Scour is an open-source Python script that aggressively cleans SVG files, removing a lot of 'cruft' that certain tools or authors embed into their documents

This will decrease the file size with as much as 50%. Since I use the script on all of my SVG images before uploading them to my website, I've created an OS X service to run Scour from the Finder.

for f in "[email protected]"
    if [ ${f: -4} == ".svg" -o ${f: -4} == ".SVG" ]
    python /Applications/Utilities/scour/ --enable-comment-stripping --create-groups --enable-id-stripping --shorten-ids --set-precision=5 --quiet --indent=none -i "$f" -o "$f 2"       
    mv "$f 2" "$f"

The service contains a shell script that checks if the image file selected really is an SVG image and runs the Scour with a couple of optional parameters. Then it replaces the original image with the optimized version. If you want to keep the original image, this step can be deleted.

Optimize SVG Automator Service

To use the service as is, Download the OS X service and Scour. The Scour script should be copied to /Applications/Utilities/scour/, before opening the service to install it. After the service is installed, you can right click on any SVG image in the Finder and choose Optimize SVG.

Optimize SVG Automator Service

Read More

Install Java in Mountain Lion

The new version of OS X (10.8), Mountain Lion, does not ship with Java preinstalled. Luckily, installing Java is easier than ever.

  1. Open Terminal (Applications > Utilities > Terminal).
  2. Type in the Command Java and press Enter. This should give the prompt:

No Java runtime present, requesting install.

  1. Software Update will launch and Java will be installed. After the installation is completed, verify the installation by running the command java -version, which will show the currently installed version of Java. The whole process is shown in the screenshot below.

Installing Java in Mountain Lion

Easiest installation ever, next to shipping with Java preinstalled of course…

Read More

Disable OS X Lion Resume per application

I sometimes divide applications into two groups: one group contains applications which creates content while the other contains viewers. Examples in the first group could be Word or your favorite IDE. The second group contains applications for viewing PDFs, images or videos such as Preview or QuickTime.

OS X Lions Resume feature enables applications to be opened in the same state as when they were closed. This saves time for programs where you wish to continue working on the same stuff, but can be annoying for most viewer applications. Using Preview to view an image from the Finder will open the image together with the images opened the last time the Preview was run. Not always what you want.

Luckily there are (at least) three ways to tweak the Resume behavior:

  1. In System Preferences this setting can be disabled system wide by disabling General > Restore windows when quitting and re-opening apps.
  2. Pressing Option  when quitting an application from the menu or using Cmd+Q will disable Resume for the last session. Cmd+Q = quit and resume later, Opt+Cmd+Q = quit and forget the open windows.
  3. From the Terminal the Resume functionality can be disabled on a per application basis by using the command: defaults write [application identifier] NSQuitAlwaysKeepsWindows -bool false. For example defaults write NSQuitAlwaysKeepsWindows -bool false will disable Resume for QuickTime after a restart. Issuing the command again using true instead of false, will re-enable Resume for the application.

Finding the application identifier

In order to find the application identifier to use in the command above, Activity Monitor can be used.

Activity Monitor

Open Activity Monitor and search for the relevant application (TextEdit in this example). Press Sample Process and the following window will appear. The identifier can be copied from this window.

Get the process identifier

Input the command in Terminal using the identifier from step two.

Disable using the terminal

    Read More