Yet Another Chris

London, UK

Recent Posts

Podcast of the Month Oct 2016

Sunday October 16, 2016

The first 30 minutes of this podcast are worth a listen alone, Chris Kresser discusses how your stomach biome is linked to depression, your brain and cravings. After that they discuss the role of meat in providing nutrition to humans, and how we don’t consider ourselves animals anymore.

Object-oriented theory you may not care or know about, but are doing

Tuesday October 4, 2016

The law of demeter

A method m in a class A should not send a message to another object unless that object is one of the following:

  • An instance variable used in the method m;
  • A parameter to the method m;
  • An object created in the method m;
  • A global variable (public static variable) used in the method m.

One of the commonest examples is not exposing List<T> as properties, but IEnumerable<T> and providing methods to Add and Remove from the underlying list.

SOLID principles

I’ve asked about these so many times in interviews and I still can’t remember all the words behind the acronym - the point isn’t to memorise some words but rather understand the ideas behind them. The most important parts (for me) are having a single responsibility for an object, IoC/DI and having many interfaces rather than just one.

  • Single responsibility. “Do one thing and do it well”
  • Open/closed principle. Less important unless you are doing a lot with inheritence. Modification over extension of classes.
  • Liskov substitution principle. I’ve seen this abused with 8 class inheritence chains for a class ultimately is about performing a search. When abused, you end up unsure what the result of your override will do because of the mess above it.
  • Interface Segregation Principle. This ties into single responsibility - an example of it going wrong is where you might implement an interface and be forced to put empty implementations for half the methods.
  • Depdency inversion principle. If you’re using a DI framework like Structuremap then you’ll be following this.

Forks and Cascades

I’ve deliberately avoid LINQ to remove any confusion:


var microsoft = new Company();
Person john = microsoft.GetPerson("john");
int age = john.Age;


  var microsoft = new Company();
  Person john = microsoft.GetPerson("john");
  int age = microsoft.GetAge("john");

Inheritence vs Composition

Fairly self-explanatory: inheritence is inheriting from a base class while composition is allowing properties of your classes to be filled, e.g. MyCompany.Person. Most of the time you will use composition, and DI you get to use it via Setter injection, or constructor injection which then fill properties.

Podcast of the month - Sept 2016

Friday September 9, 2016

A weekly favourite podcast doesn’t really work on this site, as I only end up adding them every month or two. So I’m switching to a monthly format to share my discoveries in the Podcast world.

This month is (another) Sam Harris one, talking about free will. Sam’s books argues for the case that we have no free will beyond very simple choices. For example speaking - the broka region of the brain is responsible for speech but how much of your speech is words you are willfully choosing? Or another example given is decisions that the subconscious brain makes for you almost a second before the action is performed (from recent fMRI scans showing this is the case).

Dennett (a philosopher) argues against this.

Running cron jobs inside a Docker container

Wednesday September 7, 2016

Probably the most basic use of a Docker image is to run it, and let it exist - like docker run hello-world. If you want to do this on a regular schedule, you have several options but the cron one is narrowed down to running cron on the Docker host or in the container.

I wanted to run a dotnet core console app that parses Reddit posts and posts itself, inside a Docker container, every 30 minutes on set days of the week.

Running the Docker image as a daemon with cron running inside it makes it a lot easier to update the Docker image and also bring up on other machines.

There’s quite a few gotchas to doing this however, which I discovered and spent hours Googling the answers for. Most of the answers were dredged from Github repositories which luckily Google managed to find the keywords for. This included:

  • Cron doesn’t run as an interactive shell - you don’t get any environmental variables  - a well known restriction but nobody seemed to know the answer. I found my solution in this repository.
  • I’m running a .NET Core console app. It writes a temp file to its folder on the filesystem, but you don’t have permission to do this without CHMOD’ing the app directory.
  • Cron inside a Docker container can’t write to a cron.log so you end up having to map a volume. Without this you get the error “tail: unrecognized file system type 0x794c7630 for ‘/var/log/cron.log’”. This makes the Docker image rely on the host volume for storage, but it’s only a log file. The fix came from here.

Below is the Docker file and the scripts are with the Gist.

Updated Unix Cheat Sheet

Monday September 5, 2016

My career as a web-centric software dev started with Unix (Linux and some Solaris/BSD) and thanks to .NET Core I’m now back in that world for some of my web development. I much prefer Unix for the server, particularly as it’s far cheaper than Windows to tinker with as a developer but also its simplicity. It is made for automation - something Windows is slowly catching up with but still performs in a clunky way.

Windows Server 2016 is likely to bring Windows closer to the bash and SSH world, but you are still stuck with some strange technology choices like WinRM using WCF, when SSH was already around and COM legacy everywhere and XML as the preference for configuration (versus YAML, TOML, JSON) for lots of systems like IIS and autoattend files.

Microsoft have performed a full U-turn with their Linux strategy and us C# developers are now free from our shackles and able to use Linux and Mac for things like Docker, .NET Core, Powershell on Linux, SQL Server on Linux and the Linux Subsystem on Windows.

It makes you wonder where Microsoft would be now if the decision to do this was done 10 years ago…anyway I’ve update the Unix cheat sheet I wrote about 11 years ago (put into a CMS in 2009) to include some new knowledge and the CHMOD calculator is able to go both ways. I few Docker commands will appear there shortly too.

Fixing .NET Core package restore problems

Monday August 29, 2016

I had this problem today where a dotnet restore was failing on a Linux CI server, but working on my Windows 10 dev machine. The error was:

Unable to resolve ‘System.Runtime.Serialization.Formatters (>= 4.0.0-rc4-24217-03)’ for ‘.NETCoreApp,Version=v1.0’.

It turns out I had this package in C:\Users\MyUsername\.nuget\packages so it restored locally, but on the internet the package isn’t at How did I get it originally? That was a mystery that luckily another project in the solution solved by accident.

A lot of the .NET Core nuget packages are hosted on until they’re ready to be fed over to The solution is to add a nuget.config file to your project, with this:

    <add key="" value="" protocolVersion="3" />
    <add key="dotnet-core" value="" />

One hour of my life wasted to save you 1 hour! The myget feed is currently on

Continuous Integration cloud services

Friday August 26, 2016

I’ve probably missed a couple, but this is a list I’ve compiled of all the CI services I know about, geared towards cheapo devs on a budget. My area of expertise is Teamcity, Octopus, Bamboo, Gitlab and a bit of Jenkins and Travis, and limited to dot net core.

.NET Core and .NET Standard simplified and explained by Scott Hunter

Monday July 18, 2016

With all the changes to .NET that have happened this year, and the constantly evolving .NET core/standard (and the bombshell that project.json is going), it’s quite hard to decipher what Microsoft are doing to the frameworks besides the main marketing features of it running on Linux/MacOS with NPM style packages and ASP.NET getting Kestrel.

Probably the clearest explanation I’ve found is hidden away in this DotNetConf Keynote by Scott Hunter. The first 20 minutes gives the lowdown on the new architecture, or you can read the slides if you don’t have time.

.net today

Note: The usage of Core library in this slide is slightly confusing, Scott is referring to System.Core.dll and for Base Class Library (BCL) this is typically system.dll

And if you really don’t want to read the slides, my summary would be: .net standard is a versioned contract that the implementation has to adhere to (like the CLR and CLS standards). It’ll get more APIs over time, and each implementation will have to honor the contract to keep up. If you want to be re-confused, try reading this doc. Why is everything version 4? Probably because it came straight from the .NET 4.0 code base.

So .NET Core is an implementation of the .NET Standard (.NET Core is version 1.0 right now, .NET Standard is version 1.6). The version numbers really don’t help at all, they would’ve benefited from resetting them all to 1.0 and blown a big raspberry at anyone who was using the betas and RC1 and RC2.

.net core

Also worth checking out is the .NET roadmap up until the start of 2017

Podcast of the week

Sunday May 8, 2016

Not really a podcast, more of a vodcast, the discussion talks about fasting (Ray Cronise had just been on a 30 day water fast), hot/cold therapy and the Vim Hoff method and the concept of being satiated.