Scala pattern matching & lowercase case objects

Posted on Wed 30 November 2016 in Coding • Tagged with scala, functional

I just learned something about pattern matching and case objects in Scala which I thought I’d share.


Continue reading

How Enumerable.Concat brought down a production server

Posted on Wed 26 November 2014 in Coding • Tagged with .net, linq, iis

TL;DR Using Enumerable.Concat to build a long sequence one item at a time is a particularly bad idea, since enumerating the items will consume a lot of stack space.

A while ago, a customer reported that our .NET application running in IIS started crashing on user registration after ...


Continue reading

The mysteriously escaped request path in ASP.NET

Posted on Tue 19 November 2013 in Coding • Tagged with asp.net, nancy, uri

This blog post answers the question “Why does Uri.AbsolutePath sometimes return an escaped path and sometimes an unescaped path for the request URL in an ASP.NET application?”

I spent some time googling for a possible reason, but search terms like URL/URI, request, path, encoding, and escaping are ...


Continue reading

Why I hate implicit return in CoffeeScript

Posted on Fri 26 October 2012 in Coding • Tagged with coffeescript, javascript

CoffeeScript is “a little language that compiles into JavaScript.” If you haven’t seen or tried it, go check it out! I’ve been using it in a project for a while now, and its obvious advantage over pure JavaScript is that it is very concise and has high expressive ...


Continue reading

Tricked by the IDE, broke the build

Posted on Tue 18 September 2012 in Coding • Tagged with fail, vb.net, csharp, vs2010

Over the last year, I’ve written a fair amount of Visual Basic .NET code for a customer project. As a result, I know a lot more VB.NET than I would like to, and I’ve run into a number of peculiar behaviors, such as this one. In this ...


Continue reading

One assertion per test, please

Posted on Wed 25 July 2012 in Coding • Tagged with assertion, qunit, testrules, javascript

When it comes to unit or integration tests, there are of course good ones and bad ones. There are few things more treacherous than a test suite filled with low-quality tests that don’t test what they’re supposed to, if anything at all. When the test suite goes green ...


Continue reading

Regular expression multiline mode - what's a newline?

Posted on Wed 30 May 2012 in Coding • Tagged with newline, regular expressions, csharp, java

I stumbled upon an interesting little detail as I was using a regular expression in a unit test case in a C# application. I had a multiline string and was searching for a particular substring in multiline mode. The newlines in the string were Windows newlines, meaning CR followed by ...


Continue reading

Testing asynchronous background workers in .NET

Posted on Tue 08 May 2012 in Coding • Tagged with async, background worker, test, .net

When you build a GUI, all lengthy operations that can be triggered by the user should take place on a background thread so that the GUI doesn’t become unresponsive. Why would it? Well, it’s because all GUI operations take place on a single thread - the GUI thread (the ...


Continue reading

Abusing XML literals in VB.NET

Posted on Wed 25 April 2012 in Coding • Tagged with vb.net, format strings, xml literals

One of the things I do like about VB.NET is XML literals. Given that XML is so common, it’s really a great idea! Here’s a tiny example:

Dim x = <p>Some test.</p>

I thought I’d write about how XML literals can be abused to create ...


Continue reading

Swedish to not-so-Swedish through diacritics removal

Posted on Fri 06 April 2012 in Coding • Tagged with diacritics, Swedish, unicode

According to Merriam-Webster, a diacritic is:

a mark near or through an orthographic or phonetic character or combination of characters indicating a phonetic value different from that given the unmarked or otherwise marked element

Right! :-) In the Swedish language, there are three common letters with diacritics, namely å, ä and ö. The diacritics ...


Continue reading