Template replacement engine

Using Regex as a template engine is an efficient way to replace strings in a template. Regex replace method supports executing a method upon match. We can populate a dictionary and make a lookup on all matches. This way we do the replacement in a single pass, rather than executing multiple .Replace(). Since dictionaries can be made case … Read more

Norske fødselsnummer i C# / Norwegian national ID numbers in C#

Available as NuGet package: https://www.nuget.org/packages/Tedd.Fodselsnummer Code to verify Norwegian national id number (fødselsnummer / personnummer) written in C#. Obeys 2013 standards as described in this Wikipedia article. Please let me know how if you find bugs / improvements. 🙂 (PS: This code is easy to test in LINQPad. Select C# Program, paste it in and hit run.)

ASP.Net 5 Areas

Visual Studio 2015 with ASP.Net 5 doesn’t support Areas in the GUI editor. Hopefully that will come, but until then here is a simple workaround. Create folder structure In the root of your project (not wwwroot) create the folder structure for Areas manually. In this example I created an area named “Foobar”. Edit Startup.cs to … Read more

Better text console for C#

I recently discovered how slow Console.MoveBufferArea actually is. I used it for writing NLog output to a console and discovered that at times of high output it became dead slow. I could at times see it flicker and update line for line while the whole machine temporarily came to a crawl. As I searched the … Read more

Optimizing RDP for casual use

Optimizing RDP client/server for casual use. Make it use less bandwidth. Get higher throughput and adaptive transfers. Revisit Back in 2011 I wrote a blog post on optimizing RDP in Windows 7. I’ve been thinking of updating that post for some time, and now finally got around to it. Background Since sometime around 2000 I … Read more

HTML5: Drop-in prerender and prefetch script

Reading about prefetch and prerender, and especially Chromes prerender, got me thinking that this could to some extent be automated. My blog has become increasingly slow and I though that this would work as a simple quick-fix. This script relies on jQuery. Prefetch At startup (document ready) it will find any a-links tagged as “prefetch” … Read more