Go-YAML Field Names

I wasted away a good thirty minutes trying to figure out why I couldn’t parse my YAML config file this morning using go-yaml. package main import ( "fmt" "log" "gopkg.in/yaml.v2" ) var configText = ` Message: Welcome UpdateInterval: 5 EmailAddresses: - john.doe@example.com - jane.doe@example.com` type Config struct { Message string UpdateInterval int EmailAddresses []string } func main() { var c Config if err := yaml.Unmarshal([]byte(configText), &c); err != nil { log....

February 14, 2015

Assertions in Moq Callbacks

I learned an important lesson today: do not assert inside of Moq callbacks. In the code below, even if the Assert.AreEqual fails, it will not cause the unit test to fail. moqObj.Setup(m => m.Doit(It.IsAny<string>())).Callback<string>((s) => { Assert.AreEqual("foo", s); }); // Insert test code that invokes `Doit` You could use Verify instead, but it’s not always ideal, particularly when trying to step through the assertions while debugging tests. Instead, you can take this approach suggested by Thomas Ardal....

February 9, 2015

A New Look for 2015

I have wanted to revamp my website for close to a year now. In that time I’ve looked into different blogging engines and tried creating new themes, but I didn’t settle on a path forward until a couple weeks ago. Engine At one point I considered moving to a statically generated site since they were all the rage. I tried out Jekyll and Middleman. I liked both and even wrote up a post on using Zurb’s Foundation with Middleman....

February 2, 2015

Google Analytics Site Speed for Small Websites

If you’re running a small website and using Google Analytics, your site speed metrics graph might look empty. If you don’t get a lot of traffic there will be no samples to measure site performance. This is because the default sampling rate is only 1% (i.e. site speed metrics will only be collected for 1% of your visitors). This is plenty if your running a big site with tons of visitors per day, but if your running a smaller site this isn’t going to be good enough....

January 25, 2015

Middleman Foundation

This weekend I decided to try out the static site generator, Middleman. While I was working on converting an existing static site, I decided to take the opportunity to try out Zurb’s Foundation and SCSS too. Andrea Moretti created a Middleman template to get you started doing just this, but I hate just using templates without understanding what they are doing. So I decided to start with Middleman’s HTML5 Boilerplate template and add the Foundation Bower package to it....

April 29, 2014