Recent Posts (Page 16)

Feature-Policy updates - now required for an A+ on SecurityHeaders.com

In my blog post and DjangoCon Europe talk earlier this year How to Score A+ for Security Headers on Your Django Website, I covered that Feature-Policy was a “bonus header”. In a recent update, Scott Helme wrote that an A+ on SecurityHeaders.com now requires Feature-Policy. Also it no longer requires X-Xss-Protection (though it’s still a good idea).

Read more...

Validating CloudFormation Templates With cfn-lint

I’ve been working with CloudFormation in some form for about five years now. Two years ago at Time Out, I helped write an in-house tool that performed some basic template linting. One year ago at Genus AI, I started using the AWS Labs tool cfn-lint to validate my templates before deployment. It’s really neat, covers a lot more than our in-house tool did, and has saved me from a number of mistakes.

Read more...

Django’s Test Case Classes and a Three Times Speed-Up

This is a story about how I sped up a client’s Django test suite to be three times faster, through swapping the test case class in use.

Read more...

Tuples versus Lists in Python

One thing I often ask for in code review is conversion of tuples to lists. For example, imagine we had this Django admin class:

Read more...

Celery, Rabbits, and Warrens

Every time I pick up the Python job queue Celery after not using it for a while, I find I’ve forgotten exactly how RabbitMQ works. I find the Advanced Message Queuing Protocol (AMQP) concepts drop out of my head pretty quickly: Exchanges, Routing Keys, Bindings, Queues, Virtual Hosts…

Read more...

All Is Turned to Black

If the title worried you about my mental state, you can relax. It’s about the Python code formatter Black!

Read more...

PyLondinium 2019 Notes

PyLondinium ran for the second time last weekend. It’s a three day conference from Friday to Sunday, held in central London at the Bloomberg office.

Read more...

Running CloudFormation Drift Detection on All Your Stacks

CloudFormation’s stack drift detection feature is useful. It discovers ways your infrastructure that you beautifully set up with Infrastructure-as-Code has been fiddled with manually. Often this results from a “quick temporary fix” being applied manually on the web console at 2am, then forgotten about.

Read more...

The Simplest WSGI Middleware

My library apig-wsgi bridges between AWS API Gateway’s JSON format for HTTP requests and Python WSGI applications. Recently Théophile Chevalier opened an issue requesting the library add an extra WSGI environ variable. I closed it by pointing out that it’s not much code to add a custom WSGI middleware to do so (plus the exact key is a bit out of scope for the library).

Read more...

Django Pony GIFs

I discovered GIFCities recently. It’s a project by the Internet Archive for browsing GIFs extracted from their Geocities archive.

Read more...

Updating My AWS CodeBuild Project from Ubuntu 14.04 to 18.04

I received a cheery notification email (twice) from AWS that they’re deprecating Ubuntu 14.04 on CodeBuild:

Read more...

Tools I Learnt About at DjangoCon Europe 2019

DjangoCon Europe 2019 was great fun. I loved meeting old and new friends, giving my talk and workshop, and learning in the other talks.

Read more...

Improving My Technical Writing

I found Mikey Ariel’s talk on documentation at DjangoCon Europe 2019 “Docs or It Didn’t Happen” well timed. I’ve recently been focussing on the lifelong skill of writing, in particular for technical writing such as this blog.

Read more...

Getting a Django Application to 100% Test Coverage

Code coverage is a simple tool for checking which lines of your application code are run by your test suite. 100% coverage is a laudable goal, as it means every line is run at least once.

Read more...

“Create Table As Select” in Django

A discussion recently came up on django-developers mailing list about how to build the SQL query CREATE TABLE ... AS SELECT (CTAS) with Django’s ORM. This statement and its cousin INSERT ... SELECT are useful for re-shaping data inside your database, using SELECT queries.

Read more...

Testing Boto3 with pytest Fixtures

This is a recipe I’ve used on a number of projects. It combines pytest fixtures with Botocore’s Stubber for an easy testing experience of code using Boto3. (Botocore is the library behind Boto3.)

Read more...

Solving Algorithmic Problems in Python with pytest

I occasionally enjoy solving algorithmic problems, for example Project Euler or The Advent of Code. I’ve been doing them since I was a pimply PHP-slinging teenager, competing with my peers across the UK in the British Informatics Olympiad. It was terribly nerdy and terribly fun.

Read more...

Scoring A+ for Security Headers on My Cloudfront-Hosted Static Website

On Saturday, I posted my guide on Scoring A+ for Security Headers in Django, following my talk at DjangoCon Europe. I thought it would be a good idea to step up and make my own site score A+, rather than a dismal F! My site isn’t built in Django, but as a Jekyll static site. It’s hosted on AWS S3 and CloudFront.

Read more...

What Happened When One of My AWS Keys Was Leaked

On Thursday I gave a workshop at DjangoCon Europe on deploying a Django application on AWS Lambda. I gave participants a Git repository to clone and temporary AWS keys to individual, restricted IAM users on my Workshops AWS account.

Read more...

How to Score A+ for Security Headers on Your Django Website

This is a blog post version of the talk I gave at DjangoCon Europe 2019 on the 10th April.

Read more...

Django versus Flask with Single File Applications

A lot of people pick Flask over Django because they believe it is simpler to start with. Indeed, the Flask front page includes an 8 line “hello world” application, while the Django default project has 172 lines in 5 files, and still doesn’t say “hello world”! (It does show you a welcome rocket and have a full admin interface though, both are pretty fun).

Read more...

What I Learned at PyCon Namibia 2019

I was at PyCon Namibia in Windhoek from the 19th to 21st of February, and had an amazing time! PyCon Namibia is one of the longest running PyCons in Africa, this being its fifth edition in as many years.

Read more...

Where to Learn Django in 2019

I quite often get asked for resources on where to learn Django. Here’s a list of the places I know!

Read more...

How I Provision My MacBook with Ansible

Yesterday evening I had the pleasure of speaking at the London Ansible Meetup on the topic of provisioning my MacBook with Ansible.

Read more...

Post-Apocalyptic Cowsay

While tidying up my mac-ansible repository in preparation for a talk I’m giving on it at the London Ansible Meetup tonight, I found my two-headed cow. It’s a bit of ASCII fan-art I made for the Fallout game series, whose post-apocalyptic setting has all the cows mutated this way.

Read more...