Category: code

Patterns & Abstractions

Patterns and Abstractions My central architectural pattern of choice is CQRS. Commands Actions that change something and return nothing public interface ICommandHandler<TCommand> where TCommand : ICommand { void Run(TCommand command); } Queries Actions that return something and change nothing public interface IQuery<TResult> { } public interface IQueryHandler<TQuery, TResult> where TQuery : IQuery<TResult> { TResult Execute(TQuery query); } Mediators A combination… Read more →

Debug IIS/global.asax within Visual Studio

Taken from this SO answer You may create a post-build event which changes the timestamp of a web.config file. I used a touch.exe tool from http://www.stevemiller.net/apps/. You also need to set the “Run the post-build event” to Always. With this option set anytime you start the debugger, web.config timestamp is getting updated causing application (thus IIS pool) restart on the… Read more →

A web based Markdown file viewer (IIS/PHP)

Firstly, thanks must go to the author of this post. Put markdown.php in your blog site folder. Add a posts folder and place all your md files into it. Create a content folder and download google prettify and bootstrap Create index.php <html> <head> <link href=’content/bootstrap.css’ type=’text/css’ rel=’stylesheet’ /> <style> * { font-family: Verdana; } </style> </head> <body> <div class=”container”> <div… Read more →

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 →