Posts

Posts

These are some snippets I primarily wrote for myself. The subjects can range very broadly.

Updates very infrequently with long hiatuses.

Lego Bellatrix Lestrange, escape from Azakaban photo frame MOC

Love her, or hate her, for the limited1 screen/story time she gets Bellatrix Lestrange, a character from Harry Potter novel, leaves quite an impression. In the movies she is beautifully portrayed by Helena Bonham Carter. The most famous moment, which is also her introduction to the audience in the movie, is the escape from Azkaban (1996) in Harry Potter and the Order of the Phoenix (chapter 20); the fifth movie in the series. So i decided to build a Lego MOC of that moment. ...

InitializeComponent for multiple assembly versions (WPF)

In the code behind of WPF controls the constructor loads the corresponding XAML1 file (code). The code for loading the XAML is automatically generated2 when calling InitializeComponent(), which one can find in virtually every control’s constructor. Unfortunately it might not play well, break, when there are multiple versions loaded of the same assembly containing the control (in the same AppDomain). The solution is simple but, alas, not well documented. ...

Singletons (in Rust)

Singletons are generally not easy to implement safely in any programming language, especially in a multithreaded environment. However Rust’s emphasis on (possibly guaranteed) on memory and concurrency safety sprinkled with some additional language constraints makes singletons awkward to implement at best, or plain annoying at worst. There are solutions however. This post will solely focus on the concept of Singletons, in general, and how to implement them in Rust. ...

Using ResourceManger with a CustomAssembly

ResourceMangers provide convenient access to culture-specific resources at run time. Resources may reside in the current or external assemblies. A ResourceManager can be created by specifying the base name of the resource file and assembly where it resides. However one constraint it not documented, the provided assembly must be of the type “ RuntimeAssembly” (not public). While most of the time you will, without knowing, be dealing with RuntimeAssemblies it is possible to end up with System.Reflection.Context.Custom.CustomAssembly instead which is not a RuntimeAssembly. The trouble begins… ...

Workaround for string representation of types in attribute constructor parameters (CS0182)

Attributes are a powerful way in C# of adding meta-data to your code which can be queried at runtime through reflection (or statically from the binary). Unfortunately they are constrained by which constructor parameter types they can use. Only constant expressions, most primitives, types, public enums or single dimensional array of the previous types are allowed. For more information see the official documentation. My use-case was to pass a string containing type information to an attribute and while those strings can be constructed manually, for maintainability reasons, i wanted to use typeof(MyType) this is where the trouble started… ...

Hugo shortcodes with markdown, gotchas

Generally Hugo works intuitively, unfortunately not for shortcodes with markdown text inside. While the documentation is often rather minimal, in this case it is incomplete. Having spend a lot of time wondering what i was doing wrong eventually a forum post a on the Hugo forums made everything fall in place. So to save you the effort i have summarized my findings here. This post only applies to Hugo 0.55 and beyond, at the time of writing i’m using 0.72. ...

Lego Anger MOC - reverse enginered

Ever since i saw1 Angus MacLane’s LEGO Anger MOC2 (2015) i was sold, even better it was submitted on Lego Ideas! However with 1.996 votes it did not quite make it and was never turned into an official Lego product, bummer. Fortunately it is made out of Lego, so if Lego will not create an official set you can do so yourself. As it often goes with projects, life happens and the idea got buried for a couple of year until today! I have digitized Angus MacLane’s Lego Anger MOC and planned on bricklinking it together. ...

Hugo + js = enhanced figures

Multiple shortcodes to enhance Hugo’s default figure capabilities. Hugo supports figures out of the box by using the figure shortcode or the markdown syntax. They both work well if you quickly want to add an image. The Hugo shortcode supports some customization e.g. adjust dimmension and what not but we want to go further. First of all images should auto scale to the available page width, use lazyload1 and have the ability to be shown modally. Images can come from the Page resources or external links. In addition some shortcodes are added to show images in different ways (gallery, grid, …). ...

Hugo + js = highlighted table of contents

Example on how to highlight Hugo’s default generated table of contents. While Hugo provides a default TOC (table of contents) which you can include on your page it does not have many features, like highlighting. Fortunately it can easily be added. From a UX point of view highlighting is useful to orientate the user on a page, especially if you have long form content. It can indicate where the user currently is, what has been read already and what is currently visible. ...

© Nelis Oostens