Python decorators (from http://stackoverflow.com/a/1594484/1515209)

If you are not into long explanations, see Paolo Bergantino’s answer. Decorator Basics Python’s functions are objects To understand decorators, you must first understand that functions are objects in Python. This has important consequences. Let’s see why with a simple example : def shout(word=”yes”): return word.capitalize()+”!” print shout() # outputs : ‘Yes!’ # As an object, you can assign the… Read more →

Preventing Automatic Restart for Windows Updates on Windows 8

To prevent Windows 8 automatic restart for Windows updates, administrators must follow the steps given as below: 1. Log on to Windows 8 computer with the account that has elevated privileges. 2. Click Desktop tile from the Start screen to view the desktop. 3. On the desktop screen, press the Windows + R keys simultaneously to initiate the Run command… Read more →

Referencing the container is not automatically the Service Locator Anti-pattern

This post will briefly describe when it is ok to reference a container in your application. What is a Container? A container is an object that you delegate the responsibility of creating and managing your object graphs and object lifetimes. What is a Service? A Service is an object that exposes one or more methods. What is the Service Locator… Read more →

Elmah in the Enterprise: a 3 tier solution

Elmah is a fantastic error logging solution for ASP.NET, but it has one “feature” that can prevent its adoption in the enterprise – errors can be stored on the local drive or to a database, neither of which are working for my employer. Error details should not be stored on the web server and the web server cannot be given… Read more →

Trying to get JetPack Markdown with code to play nicely with WordPress

After a lot of trial and error here’s how I got code in markdown to work in WordPress. 2 plug-ins are required Smart Syntax for adding class=”prettyprint lang-xyz to the <pre> tag and Prettify Code Syntax for the most flexible syntax highlighter I have ever found for WordPress. Finally, go to Settings – Prettify Code Syntax and change the top… Read more →

Building a Func<TEntity, bool> delegate from an anonymous object

The background to this code is that I’m getting rid of Entity Framework – it’s too slow and IQueryable is so cool but ends up sucking by slowly bleeding into the code base and thereby becoming difficult to performance tune. Thanks, as always, go to my friend .NETJunkie for his remarkable post on the query pattern that has led me… Read more →

Migrating from NUnit to xUnit

These regular expression came in handy recently – they’re not perfect, in particular a couple of the second grouping need to be more greedy – but I did the migration first time through so didn’t get to improve them. Find: Assert.That((.+?), Is.EqualTo((.+?))) Replace: Assert.Equal($2, $1) Find: Assert.That((.+?) == (.+?)) Replace: Assert.Equal($2, $1) Find: Assert.That((.+?), Is.StringContaining((.+))) Replace: Assert.Contains($2, $1) Find: Assert.That((.+?).Contains((.+)))… Read more →