Skip to main content

Posts

Migrating Hg Repos with hg-fast-export and Windows Subsystem for Linux

Introduction I prefer Mercurial (hg) to git . I don’t really have any reason for this preference - they both do the same thing, and the user experience for 90% of the use cases is the same. It probably comes from the conditions of the DVCS landscape when I started using these systems. Some of this may have been perception only, but it looked like this: GitHub didn’t have free private repos BitBucket did have free private repos BitBucket was very hg-friendly Joel Spolsky had an amazing tutorial that served as both a how-to for hg as well as a general intro to DVCS hg was much more Windows-friendly than git Since hg was written in python, I felt like extending it would be easier than doing so for git if I ever needed to (admittedly, this is a pretty ridiculous reason) hg felt like a more unified, “coherent” system than the very linux-y feeling git and its extensions (also pretty ridiculous) Where they differed, I liked the verbs hg used better than git’s counterparts
Recent posts

Reminder to Self

You don’t always have to use an existing framework/toolset/platform to accomplish a common task. You’re a coder. You can code it. I was reminded of this in two different scenarios recently. Unit Testing I’ve been taking a lot of algorithmic coding tests for potential employers on sites like HackerRank , Codility , CodeSignal , etc. Usually it works like this: You have a problem: given these types of inputs, produce this type of output You are given constraints for the inputs You are given example inputs and the expected output There is some scaffolding code to read the input and print the output There is some way for you to enter custom input for testing Sometimes there are some basic test scenarios that you can see that your code will go through Always there are unseen test scenarios that your code will go through One big problem here is that when trying to test (and retest, and remember) all of the edge cases, manually entering custom input data isn’t very efficient or r

Enabling Globalization Invariant Mode for .NET Core App on Raspberry Pi Running LibreElec

I had an app I wanted to run on my Raspberry Pi 3 running LibreElec . In LibreElec you can install the dotnet core 2.2 runtime as an addon, and in Visual Studio you can compile for ARM processors with ‘Target Runtime’ set to ‘linux-arm’ in the publish profile. So, I published to a folder from VS using that profile, and I copied the output over to my RPi which had the dotnet runtime installed. I did a simple dotnet Whatever.dll to run the app (actually in this case, it was /storage/.kodi/addons/tools.dotnet-runtime/bin/dotnet Whatever.dll because of the way the addon is installed) and was met with this error: FailFast: Couldn't find a valid ICU package installed on the system. Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support. at System.Environment.FailFast(System.String) at System.Globalization.GlobalizationMode.GetGlobalizationInvariantMode() at System.Globalization.GlobalizationMode..cctor() at Syste

C#-like Events in Python

I've been experimenting with Python recently for a few different reasons: It's fun to learn new things I'm planning to build a site for a friend on top of Django and Wagtail I have some ideas for Kodi Addons I had the need to implement an observer pattern for decoupled publish/subscribe messaging between independent Python modules. C# has this built in to the language with events. I found  this Stack Overflow post where user  Jason Orendorff 's  answer provided the following excellent decorator: This is difficult at first to understand as a Python noob, but once you get it you appreciate the simplicity and the power the language has. Starting at the bottom, the boundevent class stores the event handlers and iterates over them when the function is invoked (i.e., the event is 'raised'). The event decorator exposes the boundevent (that is stored on the object instance) for a given event (which is really just a method) when it is accessed via the '

Whatever Happened to Pong ... err ... SharpMock?

Just short of four years ago, I came up with an idea for replacing static/sealed methods in legacy code (the Michael Feathers kind) with fakes for testing purposes. Here's a quick rundown of what happened after I had that idea: Messed my brain up trying, for several hours over the course of many days, to figure out how to bend PostSharp to my will Left it alone for months Came back to it and spent several hours re-learning what I needed to know Left it alone for months Came back to it again and spent several hours re-learning what I needed to know Left it alone for months Came back to it and decided to try using LinFu as the AOP framework driving things Had what seemed like a pretty decent prototype working based on a dozen or so unit tests that fell apart under a little more weight Gave up on LinFu and left it alone for a few months Started over using Microsoft CCI Code Model to create my own specialized AOP framework to drive the mocking framework Made minor advan

Exception Handling? WTF??

A recent Daily WTF explored a Guard class which throws an ArgumentNullException if a parameter is null. Most of the commenters correctly point out that the code is not a WTF but rather a good practice because it Enforces the code contract - this parameter is not allowed to be null Provides better stack trace information Causes the app to fail fast One principle at work here is the idea of adding information to an exception. Without guarding against potentially invalid input in this situation, a NullReferenceException will (presumably) be thrown at some point. But why? What's null? What made it null? Even with the stack trace, this can be painful to debug... annoying at the least. An ArgumentNullException cuts straight to the problem and tells us exactly what is wrong. Anytime you can add information to an exception (or potential exception in this case), you should do it* . I think this is a good principle to follow when deciding whether or not to catch an exception (t