Posts

OxyPlot Charting Control

Image
The other day, I needed to display a simple time-series chart inside a little tool I was writing. Now, as we know the web has a slew of cool charting controls to pick from including chart.js and amcharts.js which I have used in the past and are great. But those libraries were out of the question because I needed to include the chart inside a WinForms application. Now, in the past I played with the Charting Controls from Microsoft and whilst they are good, that suite of controls has not been updated for an ice-age! So I decided to have a look to see what the landscape looks like for charting controls in the WinForms / WPF arena which is where I came across OxyPlot . OxyPlot is a cross-platform library for .NET and supports WinForms, WPF, Xamarin and UWP (but let's be honest, Who is targeting universal windows apps?). What makes OxyPlot interesting is that their main page says the project is supported by the likes of JetBrains and Xamarin to mention just a few! Thos...

Playing with WebAssembly and C#

Image
I will always remember the day I was shown asm.js running a demo of a game using the Unreal engine ... in a web browser, no less!!! - My jaw was on the ground. That was 2014. Little did I know at the time but asm.js would seed the path towards WebAssembly . WebAssembly (also known as WASM) looks very exciting. The homepage bills it as "a new portable, size- and load-time-efficient format suitable for compilation to the web." . It's being designed "as an open standard by a W3C Community Group that includes representatives from all major browsers.". Basically, it allows statically typed languages to be cross-compiled into a format that browsers can understand and execute. Wow! Like I say, it looks exciting. For your standard line-of-business web apps, it doesn't sound like it will displace the use of JavaScript when building Web Apps but it will be useful for high performance apps like games or canvas related apps. Even the WebAssembly homepage...

Creating a static HTML web site using Microsoft Azure

Image
I own the domain oceanairdrop.com which has been laying dormant ever since I bought it, so this holiday I thought I would take the opportunity to wire it up to a simple static HTML web page hosted on the Microsoft Azure Platform . Basically, I wanted an excuse to play around with Azure. The page itself, is only going to be used as a simple landing page, so I don't need anything jazzy. Now, while this might be all very basic, I am writing this blog post as an aide-mémoire for my future-self as this is my first time working with Microsoft Azure . What am I going to put up there? Erm, at this point I haven't got a clue, but that's another story! But let's get straight into it and kick things off. The first thing to do is log into the Azure portal and select "app services" and create a new service. As mentioned earlier, I am selecting the basic HTML5 template because this page is only going to be used as a landing page, however they have plenty of templat...

The state of C# code contracts

Image
If your following defensive programming principles, a good function should always check its inputs to protect itself from receiving bad data. If you are writing an API library that will be used by other upstream applications or via a publicly available resource, then you need to ensure that the parameters that are passed to its API don’t contain illegal arguments. If there is a bug in production then ideally I would like an exception to be raised and the error to be logged somewhere . For example, the following two functions don’t contain any defensive measures: class Program { static void Main(string[] args) { CreateUser(null, null); SetAlarmTime(1234567); } static void CreateUser(string firstName, string lastName) { // will this function work when nulls are passed in? } static void SetAlarmTime(int hours) { // will this function work if hours is greater than 24? } } As a reader of the above code, you can’t tel...

Moving a ClickOnce Installation

Image
A while ago I needed to move a ClickOnce installation to a new URL based on an update I was performing. Now, anyone who is familiar with ClickOnce knows you can migrate an application to a new URL inside Visual Studio by setting up the new "Update Location" in the settings dialog below: In the past, I have bookmarked and followed Robin's guide on how to move a ClickOnce deployment using this standard method. Robin's blog is a one-stop shop for any technical information regarding ClickOnce. However, guess what? It turns out this method does not work if you want to change the CPU type of the application (which is what I wanted to do) or if your certificate has already expired. I wanted to change my application from AnyCPU to x86. Apparently there is nothing you can do about this because the process architecture setting is part of the ClickOnce deployment manifest. Basically I was stuck!! And then I found this stack overflow post about uninstalling a click o...

Load balancing TCP/IP traffic using HAProxy/Nginx

Image
Despite all our best efforts, problems can and do happen in production. If you are practicing CI/CD and continually pushing new code to a server, bugs can sometimes creep in. When that happens you want to be able to inspect, debug and even step-through the code to identify and fix the problem. However, depending on the type of problems they might be hard to reproduce on a dev box. Some problems only occur when you get real live data flowing through the system. For example, if the problem is to do with incoming TCP/IP connections from a specific set of IoT devices, this can be hard to reproduce in dev. Of course, it's considered bad form to debug the code live on the production server. If you are connecting up to an application in debug mode, you're effectively stopping all clients communicating with the server while you step through the code. Not good form! And let's not mention leaving a break-point on and then going for lunch! In this scenario, what you real...

Commodore 64 Basic

Image
Well, that was a nice trip down memory lane! I have just come across the C64 Mini over at https://thec64.com . It's not being released until 2018 but it's a mini replica of the Commodore 64 with USB and HDMI ports. The Commodore 64 was my very first computer. Of course I played the games! Buggy Boy & Commando instantly spring to mind. But the cool thing about the C64 was that it booted up into the basic language! I have fond memories of typing out programs from the back of magazines only for them not to work. The result of a rouge typo somewhere! But I do remember experimenting with the basic language because the user manuals for the computer covered the BASIC language. Amazingly I have just found the manuals preserved online here . Isn't it funny that the GOTO keyword is considered harmful today in software development, but it introduced me to scrolling my name infinitely up a TV screen! 10 PRINT "Ocean Airdrop Woz Here" 20 GOTO 10 RUN Anyway, w...