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.

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 nuget.org. 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 myget.org until they’re ready to be fed over to nuget.org. The solution is to add a nuget.config file to your project, with this:

<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
  </packageSources>
</configuration>

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

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.