markdown in WordPress – AT LAST!!!!!

Here’s some normal text interspersed with some Code, some italics and bold. a quote some sql select a.FILEID, [FILE_SIZE_MB] = convert(decimal(12,2),round(a.size/128.000,2)), [SPACE_USED_MB] = convert(decimal(12,2),round(fileproperty(a.name,’SpaceUsed’)/128.000,2)), [FREE_SPACE_MB] = convert(decimal(12,2),round((a.size-fileproperty(a.name,’SpaceUsed’))/128.000,2)) , NAME = left(a.NAME,15), FILENAME = left(a.FILENAME,30) from dbo.sysfiles a some code [TestFixture] public class ScrewdriverTests { [Test] public void Container_ExplicitRegistration1_ReturnsExpectedClass() { Container container = new Container(); container.Register(typeof(IScrewdriver<FlatHead>), typeof(FlatHeadScrewdriver)); var screwdriver = container.GetInstance(typeof(IScrewdriver<FlatHead>));… Read more →

Microsoft’s Task Parallel Library and the principle behind node.js

I wanted to see how Microsoft’s Task Parallel Library compared with node.js in so far as passing the next method in to the current to chain the calls indefinitely. So I created a method that iteratively adds itself to the current executing Task. The initial test was to see if the code would fail with a StackOverflowException but what I… Read more →

Sql Server Shrink Log File

Easy with Simple Recovery DBCC SHRINKFILE (“<FileName>_Log”, 1); GO otherwise http://social.technet.microsoft.com/Forums/sqlserver/en-US/0a7a7fc5-d30e-4841-8ed1-84676b575e55/sql-server-2012-how-to-shrink-the-database-transaction-log USE AdventureWorks2008R2; GO — Truncate the log by changing the database recovery model to SIMPLE. ALTER DATABASE AdventureWorks2008R2 SET RECOVERY SIMPLE; GO — Shrink the truncated log file to 1 MB. DBCC SHRINKFILE (AdventureWorks2008R2_Log, 1); GO — Reset the database recovery model. ALTER DATABASE AdventureWorks2008R2 SET RECOVERY FULL; GO Read more →

node.js calling multiple web services in parallel

http://askhds.blogspot.co.uk/2012/02/nodejs-rest-call-using-http-library.html var http = require(‘http’); // Add helloworld module var helloworld = require(‘helloworld_mod’); http.createServer(function(req, res) { res.writeHead(200, { ‘Content-Type’ : ‘text/xml’ }); try { // Bypass function call to “Google Maps API” getFromGoogle(req, res); } catch (e) { res.end(“Try again later”); } }).listen(1337, ‘127.0.0.1’); console.log(‘Server running at http://127.0.0.1:1337/’); console.log(‘Type the URL in address bar’); console.log(‘http://127.0.0.1:1337/maps/api/geocode/xml?’ + ‘address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false’); function getFromGoogle(mainreq, mainres)… Read more →

Extract details from an Expression

I wanted to come up with a way of establishing the type name and property name when applying general validations within my code. So, for example for this validation:. var bool = Requires.IsNotNull(user.lastName) I have to explicitly code the exception: throw NullReferenceException(“User.lastName”) What I’d like is for all this to happen when I declare the test, without double typing the… Read more →

Multiple Dispatch, Double Dispatch and the Visitor Pattern

I’ve been looking into the Visitor pattern and figuring out how to make it work with overloaded methods. Starting with the abstractions interface IVisitor { void Visit(AbstractElement element); } abstract class AbstractElement { public void Accept(IVisitor visitor) { visitor.Visit(this); } } And initial implementations class TestElement1 : AbstractElement { } partial class TestVisitor1 : IVisitor { public string visitedMethod =… Read more →

Dynamic objects part II

I decided to extend my DynamicObject class to enable me to do this: [Test] public void MyDynamicObject_SetWithSetter_CanGetByReference() { // Arrange dynamic obj = new MyDynamicObject(); obj[“property1”] = true; // Act bool value = obj.property1; // Assert Assert.That(value); } And this: [Test] public void MyDynamicObject_SetDelegateWithSetter_CanCallDelegate() { // Arrange dynamic obj = new MyDynamicObject(); Func<bool> d = () => true; obj[“property1”] =… Read more →

Dynamic Objects in a Generic World

I have a situation where I want a dynamic object that can used within generic classes and methods. I have a generic service that accepts any instance that implements a predefined interface: public interface IMyInterface { bool enabled { get; set; } } public class MyGenericService<T> where T : IMyInterface { public void Process(T obj) { obj.enabled = true; }… Read more →

Simple Injector – How to discover the underlying Implementation Type of a decorated instance when calling GetAllInstances

I asked the question “How to discover the underlying Implementation Type of a decorated instance when calling GetAllInstances?” on stackoverflow and got a perfectly valid answer – here’s a sample implementation to prove that it would work. Start with some test abstractions and implementations: public interface ICommandHandler<TCommand> { void Execute(); } public class A { } public class B {… Read more →