Recent Posts (Page 17)

Making the CloudFormation release history into RSS

Update (2025-06-01): The above feed is no longer available.

Read more...

Using boto3? Think pagination!

This is a problem I've seen several times over the past few years.

Read more...

pytest-randomly history

My plugin pytest-randomly was recently moved into the pytest-dev organization on GitHub, making it a bit “more official” as a pytest plugin. Thanks to Bruno Oliveira for suggesting it, Florian Bruhin and Bruno for approving it on the pytest-dev mailing list, and Gordon Wrigley for helping with its development.

Read more...

Django Quiz 2017

Yesterday evening I gave a quiz at the London Django Meetup Group for the second year running. Here it is so you can do it at home (no cheating!). Answers are at the bottom.

Read more...

Writing a Custom Ansible Dynamic Inventory Script

I’m writing code for a little Raspberry Pi HUD I’m running in my house, project ‘Homehud’. Naturally I manage the Raspbian system I’ve installed on it with Ansible.

Read more...

Optimizing the construction of Django QuerySets

Django’s ORM is normally fast enough as-is, but if you’ve ever profiled a high traffic view with a fairly complicated query, you might have found that constructing QuerySet can take a noticeable portion of your request time. For example, I once found a query on the front page of the site I was working on that took 1ms to construct and 1ms for the database to answer. With a performance budget of 100ms, that was 1% gone on computing the exactly same SQL.

Read more...

Introducing multilint

I maintain a few Python projects on Github + PyPI. I try to keep them as consistent and error-free as possible and thus running code quality tools (known as ‘linters’) such as flake8 and isort to ensure this happens. I also discovered the lesser known python setup.py check which has found a number of problems I otherwise wouldn’t have found until release time - highly recommended!

Read more...

AWS H3 is the Future of Hotels

AWS just announced Amazon H3 (the Highly Hospitable Hotel), available now in us-east-1 and coming years later to the region you actually use. They’re leveraging all the infrastructure they have built for their data centres to create a new style of ‘pay as you go’ hotel. Here are some of the features and pricing schemes available at launch:

Read more...

Introducing django-perf-rec, our Django performance testing tool

During PyCon UK I had the opportunity to work on open-sourcing our in-house Django performance testing tool, which has now been released as django-perf-rec. We created it over two years ago, and have been using and improving it since. It has been helping us to pre-emptively fix performance problems in our code, and now it can help you!

Read more...

Upgrading YPlan to Python 3 with Zero Downtime

We recently upgraded our 160,000 lines of backend Python code from Python 2 to Python 3. We did with zero downtime and no major errors! Here’s how we did it, hopefully it will help anyone else still stuck on Python 2!

Read more...

Restricting the Ansible Version in Use

At YPlan we love Ansible. We use it for controlling our various AWS instances and other services, as well as with Vagrant for development environments that are in sync. This way if we want to upgrade a system package or piece of configuration, it needs only be written once in Ansible before being applied everywhere.

Read more...

Deploying AWS Lambda Functions with Ansible

AWS Lambda is a hip “serverless” technology that everyone is talking about. While I find ‘serverless’ a bit of a funny name—it just means a managed environment—I like using Lambda functions for infrastructure glue or running small internal applications. Putting these things on individually managed servers of their own has always been a pain, so Lambda is a perfect fit.

Read more...

Swapping decimal for cdecimal on Python 2

Python 3 includes a faster re-implementation of the decimal standard library, called cdecimal. How much faster?

Read more...

Making Ansible a Bit Faster

I recently reduced the YPlan build time by about 30% by tuning two Ansible settings. They’re not on by default, but work in most setups, so this will make a nice short guide on going faster.

Read more...

Building a better DatabaseCache for Django on MySQL

I recently released version 0.1.10 of my library django-mysql, for which the main new feature was a backend for Django’s cache framework called MySQLCache. This post covers some of the inspiration and improvements it has, as well as a basic benchmark against Django’s built-in DatabaseCache.

Read more...

An Ansible MVP (Minimum Viable Playbook) for Testing Tasks

I showed this briefly in my post on merging groups and hostvars, but I thought it was worth writing a whole post on. The Minimum Viable Playbook (MVP) is the shortest, most useful Ansible playbook I have. Whenever I need to write some Ansible code and I’m not entirely sure I’m doing it right (which is often), I implement it first in the MVP so I can test it quickly. Here’s my latest iteration:

Read more...

Cleaning Up Nameless EC2 Instances with Ansible

I gave a talk at the recent London Ansible Meetup on how I cleared up unexplained nameless/‘anonymous’ EC2 instances from our AWS account at YPlan. This is the blog post version of that talk, so you can follow along and stop such instances appearing on your account and sapping money!

Read more...

Validating Ansible changes

If you’re using ansible to set a configuration file for a program, one of the most important things you can add is a validation step to ensure that you don’t hit reboot and the program refuses to launch - service down!

Read more...

Merging groups and hostvars in Ansible variables

I was googling for information on creating round-robin DNS records in Route53 with Ansible and came across this post by Daniel Hall who’d figured out a way of merging the his host group list with their hostvars in Ansible. After a bit of emailing with him I’ve figured a way to do it without having to add an extra filter as he did originally - by digging more into Jinja2.

Read more...

Using IPython Notebook to Write Jekyll Blog Posts

My last blog post was written in IPython notebook, and my blog is in Jekyll. Here’s how I hooked the two up.

Read more...

Python Concepts: Part None

Let’s learn about nothing. More particularly, let’s learnt about python’s concept of representing nothing, None. This is the most nothingest concept of nothing as well - for example, zero is nothing, but it’s also a number, so it still has some information. Other names for nothing from other programming languages include null, nil, or Nothing.

Read more...

My Talk “Factory Boy Fun” at Django London Meetup

On Tuesday I gave another talk at the London Django Meetup Group, titled “Factory Boy Fun”, based upon my previous blog post of the same name. The blog post covers pretty much the same stuff, but if you want to flick through the slides quickly for an overview, they’re hosted on GitHub.

Read more...

Factory Boy Fun

I’ve recently been working on improving the test suite at YPlan. The biggest change is moving towards dynamic fixtures for our Django models using “Factory Boy”. This library is essentially a tool that lets you define simple helper functions to generate random, sensible model instances quickly; by using them in tests you can avoid the static JSON fixture files that Django recommends you use in tests by default. Factories are also general purpose - they just generate data and use it to create a model - and so they can be re-used to fill your development database rather than dumping from production.

Read more...

Time to Move on From Cron

I was recently tasked with keeping the various repeating jobs running for our data scientists at YPlan. They have a number of nightly or weekly jobs to be run, such as creating summary tables of the day’s various activity logs, pulling in data from third party services, and so on.

Read more...

My Talk “Django at scale” at Django London Meetup

On Tuesday I gave a talk on Django at the London Django Meetup Group, titled “Django at Scale.” The slides are hosted on GitHub.

Read more...