Skip to content

Instantly share code, notes, and snippets.

View AnthonySteele's full-sized avatar
💭
😪

Anthony Steele AnthonySteele

💭
😪
View GitHub Profile
@AnthonySteele
AnthonySteele / NancyModuleExtensions
Last active April 11, 2019 09:19
Example code for my blog post on function shims for NancyFx request handlers
/*
* Example code for my blog post on function shims for NancyFx request handlers
* Blog post is here: http://anthonysteele.co.uk/more-patterns-for-web-services-in-nancyfx
*/
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Nancy;
using System.Web.Mvc;
namespace FeatureTest
{
public class FeatureRazorViewEngine : RazorViewEngine
{
private const string ViewsPathTemplate = "~/Features/%1/Views/{0}.cshtml";
private const string LayoutPathTemplate = "~/Features/Layout/{0}.cshtml";
public FeatureRazorViewEngine()
@AnthonySteele
AnthonySteele / AgileValues.md
Last active January 22, 2017 12:42
Agile with values
@AnthonySteele
AnthonySteele / Aboutasynchandlers.md
Last active January 17, 2016 22:38
About async handlers

##Setup

Many people have the misconception that async and sync code are mutually exclusive. This is not the case. It's easier than it seems!

If you have a method on an interface for async use, then the implementation can have zero or more awaits, and the case with zero awaits covers synchronous implementations. The code below will make this clear.

We have the following example contract that models a processor of messages:

 public class Request
@AnthonySteele
AnthonySteele / optimization_and_metrics.md
Last active August 28, 2017 08:35
About optimization and metrics

The git Pull Request is a powerful tool. But just because you have it, does not mean that you have to use it all the time.

I am thinking of a team that owns on a codebase and works on it regularly. Pull requests give outsiders a powerful thing that they did not have before: controlled access to apply changes that they need, with review by the owners. However it is not a good process to apply across the board to those same owners as a matter of course.

I always think of it as like a gate in an ancient walled city: A stranger can come in, if they pass inspection at the gate. Without the gate, they would be reduced to standing outside and shouting over the wall "We need this feature! And you need to update some urls!" and hope that it happens soon. So the gate allows them to come in and get business done, while res

@AnthonySteele
AnthonySteele / Async_basic_mistakes.md
Last active January 9, 2023 16:29
Avoiding Basic mistakes with async ... await in C# code
@AnthonySteele
AnthonySteele / EndpointData.cs
Last active March 10, 2017 17:27
EndpointData
using System.Net;
namespace JustEat.StatsD.EndpointLookups
{
public class EndpointData
{
private readonly IPEndPoint _ipEndpoint;
private readonly string _hostName;
private readonly int _port;

I have finally done a like-for-like benchmaerk on JustEat.Statsd version 2.1 versus version 3.1

In order to get a consistent measurement, it has to be on the same machine under the same conditions.

dotnet run -c Release --framework netcoreapp2.0

BenchmarkDotNet=v0.11.0, OS=Windows 10.0.17134.167 (1803/April2018Update/Redstone4)
Intel Core i7-4712HQ CPU 2.30GHz (Max: 2.20GHz) (Haswell), 1 CPU, 8 logical and 4 physical cores