Posts

Auto Updating an Android App outside the Play Store

Image
In my previous post, I explained how I was writing a private Android app that is only intended for personal use (basically a hobby project). Because of this, I do not intend to release it in the Google Play Store .. But that brings up an interesting question: How am I going to update this app over time? One of the benefits of hosting your app in the Google Play store is that you get the ability to auto-update your apps (amongst other things like in-app billing etc). But, as the official documentation explains, there are many ways you can distribute your Android app including: Distributing through an app marketplace Distributing your apps by email Distributing through a website This is an extra bullet point! This blog post explains the steps I went through to get my Android app to auto-update via a website. In a nutshell, I wanted the app to be able to: Check a website to see if an updated . .apk is available If so, give the user the option to download the upd

Android, Self-Signed Certificates and OkHttp

Image
Just recently I have been writing a private Android application using the latest freshness that is Kotlin . Of course, like all mobile applications, it makes heavy use of HTTP requests, sending data back and forth between my app and the back-end API. Because this app is private, it will never be released in the Google Play store and the back-end server will not be publicly available on the internet. The server is a private home web server on an internal network (think intranet) and the application will only contact it over my home WiFi. Did you know that Sensitive Data Exposure is still on the 2017 OSWASP top 10 list ? It's currently sitting at the #3 spot. The OSWASP folks say: "Over the last few years, this has been the most common impactful attack. The most common flaw is simply not encrypting sensitive data." So, as a good developer, my next job was to switch my project to use HTTPS/TLS . That's when I remembered Let’s Encrypt which is a free , auto

Excel Interop & C#

Image
If you've ever developed even a small line-of-business application, sooner or later, you know your users are going to ask: "Erm... This is great and everything but can we get this data exported to excel?" Now, of course, exporting data to Excel has always been possible and back in the day, you would use COM Interop to create an Excel file using C# but... how do I put this? - Let's just say it wasn't pretty! Take this small snip of code for example: private void ExcelTest() { object mMissingValue = System.Reflection.Missing.Value; Application excelApp = new Application(); // Open the file Workbook workBook = excelApp.Workbooks.Open(templatePath, mMissingValue, mMissingValue, mMissingValue, mMissingValue, mMissingValue, mMissingValue, mMissingValue, mMissingValue, mMissingValue, mMissingValue, mMissingValue, mMissingValue, mMissingValue, mMissingValue); Worksheet sheet = (Worksheet)workBook .Wor

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