Advent of Code 2017 - Day 1 - Inverse Captcha

If you’ve never heard of Advent of Code you should probably check it out. I could try to explain what it is but it’s easier to just quote what Eric Wastl, the organizer wrote about it:

Advent of Code is a series of small programming puzzles for a variety of skill levels. They are self-contained and are just as appropriate for an expert who wants to stay sharp as they are for a beginner who is just learning to code. Each puzzle calls upon different skills and has two parts that build on a theme.

I had spare couple hours this weekend and decided to give it a go. But it would be very boring if I was just trying to get the right answers. Instead, I’m using it as an opportunity to get more hands-on experience with F# - something I wanted to do for a long time now but never had a chance. I’m not planning to solve every single puzzle there is, but for the ones I do and find interesting I’m going to post a blog post with my approach. Here comes a little bit about how I solved the first puzzle - Inverse Captcha.

Read More

String.Split and int[] allocations

You might have already heard that it’s not always the best idea to use String.Split unless you really need all the substrings. It might be tempting to use it when you only need the first one, or want to check how many there is but it’s totally unnecessary to allocate all these substrings if all you care about is their count. As I found out pretty recently, it might not be the best idea to use String.Split even if you do want all the substrings. In this post I’ll explain why that’s the case and in what scenarios it might be better to roll your own split routine.

Read More

Monitor hapi based web service with Application Insights

Application Insights is a great tool which allows developers to get better understanding of what’s going on insight their applications and services. It’s platform-agnostic and can be used from pretty much everywhere: from ASP.NET and node.js on the server to client-only applications running in the browser. The documentation is quite good and will help you get started, but there is one thing that I found missing. There is a page describing how to interface Application Insights into node.js application, but it’s using node HTTP server in all the examples. While it might work for some, it doesn’t work for me. The app I’m currently working on uses hapi. In this post I’ll show how in just few lines of code you can instrument hapi-based application and get data flowing into Application Insights.

Read More

Moving datetimeformat.info to Azure Functions and GitHub Pages

I created datetimeformat.info couple years ago when I got tired of googling what the right custom format string for DateTime.ToString() method is. It used to be a simple ASP.NET site and I hosted it as an Azure Web App. The problem is, hosting it on Azure wasn’t cheap. datetimeformat.info does not get much traffic, there is minimal amount of logic there but because I hosted it on a single B1 Basic instance I used to spend ~$55 a month. Sure, I can pack multiple other websites and applications on the same instance and that money is something I get as part of my MSDN subscription anyway, but still, it felt wrong. That’s why today I updated it to use GitHub pages to serve static content and Azure Functions to provide required API. New cost of running the site: $0 (yes, zero!).

Read More

Programmatically creating a Pull Request against Visual Studio Team Services

There are certain scenarios, especially when developing software in environment which uses multiple repositories, where certain changes in a single git repository should be followed by another set of changes in another repository or repositories. Automating these tasks can make Continuous Integration pipeline and entire development system more efficient and let developers focus on writing code instead of manually dealing with multi-repository orchestration. Let’s see how that can be done using custom build scripts in Visual Studio Team Services.

Read More