Part 1: Parsing Roman Numerals using C#
Lately I’ve become fascinated with the Latin language. I’m working on a project that converts photographs of Latin inscriptions on medieval statues into translated text. One of the challenges is parsing years, usually expressed in the form of Roman Numerals.
After building a parser class I noticed that it had a lot of nice characteristics: parsing, operator overloading, implicit conversions. A nice way to play around with C#.
Offline Google Authentication for MVC.Net
A while back I wanted to create an ASP.Net MVC client for Google Fit that charted my weight. It turned out that offline Google authentication wasn’t as straight forward as one would hope. This article will explain how it works using Google Fit as an example. The code is applicable to the whole Google API. In this example only one authorization is stored and used across multiple accounts.
Getting your weight from Google Fit with C#
I think Google Fit is a wonderful platform. It connects multiple devices and apps to give you insight into your fitness. I connected a Withing Smart Body Analyzer scale to the system. What I’m missing is a simple min / max weight per day graph. This blog describes how to get the weight data out of Google Fit into your C# application. You can use your own chart solution to plot a graph.
Simple Database-less Authentication for MVC.Net
There are many projects that are way too small to setup an ASP.Net membership configuration or OWIN authentication. But you still want to protect your applications by one or more accounts. What to do?
Well… there is a small – but obsolete (!!) – thing that you can try: ASP.Net Forms Authentication. While it is obsolete, it is still usable. In this article I’ll show how to implement it for MVC.Net.
A BlockHasher helper class
There are a few instances in which you’ll need to hash a combination of data. You might resort to creating one big string and hashing that. It has a clear disadvantage from a memory and processing point of few. It might even be impractical when files or streams are involved. That’s why I created a BlockHasher utility class that helps to generate these types of hashes.
An evaluator for simple script evaluation
In a previous blog I explored how to create a dynamic compiler. In this blog I’ll explore how to create an evaluator that aids in the compilation of classes. It will take care of the ceremony needed to wrap the code into a class, compile it and retrieve the result.
How to add dynamic compilation to your C# projects?
Dynamic compilation is an awesome feature to add to your projects. Especially frameworks will benefit from the compilation of dynamic expressions and scripts. There are two main ways of doing it: the Code DOM Compiler or the Roslyn project. In this blog I will show how to implement them both.
Auto fill settings objects with .config values
Lately I’ve been playing around with some API’s. Most of them need a bunch of settings that I’m storing them in my config files. I found myself doing the same work over and over again: creating a settings class, filling the class with information and using it. So I came up with a way to leverage reflection to fill my setting classes with .config values.
How to download a URL and get its MIME type using the C# WebClient?
A while back I needed to download a URL and determine the MIME type. Fortunately many web servers will send the MIME type of the resource back to the client (so browsers even require it). Here is a snippet of C# code that does the trick.
A (slightly) better WebClient class supporting cookies and headers
Sometimes you’ll need a (slightly) better C# WebClient that’s able to store/retrieve cookies, prevent redirects or retrieve the HttpStatusCode of a request. I’ve created a small class that facilitates these features.