Delving in the depths of my github

This morning I was trying to solve an issue where http://owenrumney.co.uk has an SSL error when trying to access my blog but https://www.owenrumney.co.uk is fine! (its still not resolved).

As I was poking around in my github account I looked at what I had done over the years… taking me back to 2012 when I originally opened my account.

The first project was an implementation of the LightsOut game written in NodeJS. Since I’ve never had a contract where I’ve been doing Node I can only assume i was writing this to learn Express/NodeJS etc.

The game is simple, click on the lights till they all go out, but when you click a cell, the state of the horizontal and vertical adjacent cells toggle their state.

LightsOut Game

Even a cursory look at the code has highlighted that it isn’t great, but my thoughts are more about... read more


Using Amazon SES with HP Scan-to-Email Printer

Overview

We have just replaced our aging Canon MX885 Multi Function printer with a new colour Laser printer, an HP M281fdw multi function. One of the scanning options is to “Scan to Email”. This is something I’ve found really useful in my current clients office.

What’s the issue then?

The issue I found setting up this functionality is that I need to configure the printer to relay through an SMTP server to send the messages to me. This is a pain and I didn’t want to have to stand up a simple SMTP server here just so I could use this feature.

My next thought was to try and use smtp.gmail.com. Even with the usual port and authenticating using my emails creds this still didn’t work properly so I figured why not make use of Amazon’s Simple Email Service. It’s simple, reliable and you can relay through... read more


Creating a Kerberos Keytab file with ktutil

NOTE: Creating a keytab file is easy enough but I have to refresh myself each time so I thought I would document it in a blog post.

Assumptions

I’m assuming for anyone who is doing this that you have your /etc/krb5.conf in order and that isn’t going to get in your way.

One thing you’re going to want to know is what your permitted and default enctypes and the realm are from this file. In my case I’m going to use aes128-cts-hmac-sha1-96 and my realm is DPE.INTERNAL.

Creating the keytab file

To create the keytab file you’re going to need ktutil (and a number of other kxxxxxx commands)

RHEL/Centos

sudo yum install krb5-workstation 

Ubuntu

sudo apt-get install krb5-user 

Now you have the required programs installed, you can create your keytab file using ktutil.

... read more

Creating a simple Dockerised Flask App

This post covers the steps to create a simple dockerised flask app to cover some of the basic steps required when creating a REST(ish) service that can be run as a Docker container.

The App

Rather than go with the obvious “Hello, World!” type example, I decided I’d try and do something just a touch more interesting and create a REST(ish) resource that will return a response with the status code that was passed in the path of the request. This might be useful for test frameworks where you want to validate some codes reaction to a given response status code or similar.

I’m using Flask to create a quick an dirty solution, mostly to keep it simple. Firstly, the requirements.txt file is simple, just one requirement;

flask 

requirements.txt

This will get us the Flask package to use in our simple REST(ish) service, which... read more


Adding retry logic to urllib3 Python code

In this post I’m going to cover the basics of implementing retry logic using urllib3.

There is probably a solid argument saying “why aren’t you just using requests?”, as it happens, requests uses urllib3 and it’s Retry functionality.

For the purposes of this post, lets imagine that we have a REST service and one of the resources is particularly popular, or flakey, and is throwing the occasional 503 HTTP Code.

Our initial code might look something like;

import urllib3 http = urllib3.PoolManager() r = http.request('GET', 'http://www.myflakyendpoint.com/dicey') if r.status == 200: logger.info('That was lucky') 

We have once chance to get it right. Yes, some convoluted while loop against the status code could be... read more