Skip to content

Instantly share code, notes, and snippets.

View mattstibbs's full-sized avatar

Matt Stibbs mattstibbs

  • Digi-M Ltd
  • Kent, UK
View GitHub Profile
@mattstibbs
mattstibbs / gist:72c69738e382424d08e9
Created April 30, 2014 18:47
Look through a string for UK number plates with a space in the middle, and combine them into a single word (e.g. AB12 GHF -> AB12GHF, J586 GHH -> J586GHH)
def combinesplitregistrations(message):
def contains_digits(s):
return any(char.isdigit() for char in s)
f = message
words = message.split(" ")
newwords = []
### Keybase proof
I hereby claim:
* I am mattstibbs on github.
* I am mattstibbs (https://keybase.io/mattstibbs) on keybase.
* I have a public key whose fingerprint is 8019 0DA8 2E70 D27A 341E 2308 6F96 1A24 7506 4F3B
To claim this, I am signing this object:
Verifying that +mstibbs is my blockchain ID. https://onename.com/mstibbs
@mattstibbs
mattstibbs / keybase.md
Created February 2, 2016 07:19
Keybase Proof

Keybase proof

I hereby claim:

  • I am mattstibbs on github.
  • I am mattstibbs (https://keybase.io/mattstibbs) on keybase.
  • I have a public key ASAkSpGkBuKpwuVmRjuIvRYp5gUC2mRO8iMRRm87hlaGZAo

To claim this, I am signing this object:

@mattstibbs
mattstibbs / auth.py
Created March 14, 2017 00:12
A sample basic auth module for Flask
import config as config
from flask import Response, request
from functools import wraps
def check_auth(username, password):
"""This function is called to check if a username /
password combination is valid.
"""
result = (username == config.API_USER and password == config.API_PASS)
def str2bool(v):
return v.lower() in ("yes", "true", "t", "1")
@mattstibbs
mattstibbs / tests.py
Created October 29, 2017 17:06
RecentlyUsedList-tests
import unittest
from recently_used_list import RecentlyUsedList
class RULTests(unittest.TestCase):
def setUp(self):
self.rul = RecentlyUsedList()
def test_new_RUL_gives_empty_list(self):
@mattstibbs
mattstibbs / rul.py
Created October 29, 2017 17:07
RecentyUsedList - code
class RecentlyUsedList():
def __init__(self):
self.list_of_items = []
def __len__(self):
return len(self.list_of_items)
def insert(self, item):
if item in self.list_of_items:
self.list_of_items.remove(item)
@mattstibbs
mattstibbs / test_mock_log.py
Created May 21, 2018 07:07
Mocking log line test
def test_log_line_written_ods_code():
u = User('test-username', 'test-password')
client = RestApiClient(u)
identifier = 'A91547'
data = {
'success':
{
'serviceCount': 1,
'services':
[
@mattstibbs
mattstibbs / validate_nhs_number.py
Last active January 7, 2022 14:51
Validates a given NHS number to ensure it is valid according to the specification
"""
This code checks that an NHS number is of valid format based on the specified calculation and check digit.
It does NOT check that the NHS number is an active, valid NHS number according to the national NHS number database.
Requires: Python 3.6+
"""
# NHS numbers must be ten numerical digits long
nhs_number = "1354554531"