Categories
Posts

Stop Firefox from redirecting to HTTPS

I don’t know anything about your web stack except for one thing: You’ve landed here because you are facing the same annoying problem I had with Django’s SECURE_SSL_REDIRECT. After accidentally enabling this option in my local dev environment, the world’s favorite browser kept redirecting all localhost URLs to their https counterparts. This was super annoying […]

Categories
Posts

A minimal reverse proxy using PHP & cURL

A reverse proxy acts as an intermediary between a client and one or more servers. Requests sent by the client are received by the proxy and passed on to one of the servers in the background. There are many scenarios in which such a setup might be useful. For example, reverse proxies can be used […]

Categories
Posts

Whitelisting files in Serverless

By default, the Serverless framework will deploy every file in the project directory. In most cases, this is not what you want. serverless.yml offers the option to control which files will be deployed to your cloud provider by using the exclude / include parameters. Due to the way these parameters are implemented, it is not […]

Categories
Posts

Busting some caches with Django

In contrast to server-side code, client-side assets such as JavaScript files and static images are not directly deployed to where they are ultimately executed or displayed (i.e. the user’s browser). Rather, they are downloaded on demand whenever a browser retrieves a page for the first time. For sake of efficiency, the browser saves the retrieved […]

Categories
Posts

Prevent Gutenberg from breaking words in table blocks

For some reason, the Gutenberg editor applies the following CSS rule to table block cells: This rule will make your tables look something like this: As you can see, a cell’s text content will be wrapped mid-word which might not be the behavior you’d expect from your table cells (at least it wasn’t was I […]

Categories
Posts

He or She? Or: The basics of (binary) classifier evaluation

Of all the amazing scientific discoveries of the 20th century, the most astonishing has to be that “men are from Mars, [and] women are from Venus”. (Not that the differences weren’t obvious pre-20th century, but it’s always good to have something in writing.) If indeed the genders do originate from different planets, then surely the […]

Categories
Posts

Avoiding query code duplication in Django with custom model managers

For a second, please imagine we are building the next big social network. We decide that our “revolutionary” new app shall allow its users to create profiles. Besides a mandatory user name and avatar, we consider a profile complete only if the user also supplies an email or physical address (or both). In other words, […]

Categories
Posts

Hosting multiple sites within a single Django project

Imagine we are running a successful online store for cat food (let’s call it catfood247.com). Since things are going so well, we would like to expand our business with a second store for dog food, dogfood247.com. Does this mean we’ll have to set up a separate server even though the two stores will be very […]

Categories
Posts

Spring-cleaning your (Arch) Linux system

Disclaimer: Some operations mentioned in this post are potentially destructive and irreversible. Be sure to back up all your important data before proceeding. Note: This post is written from the point of view of an Arch Linux user. Most steps presented below should nevertheless translate well to other distributions. Through the usual course of their […]

Categories
Posts

Validating constraints across multiple form fields in Django

After all fields of a Django form have been validated in isolation, the Form().clean(self) method is called to conclude the validation process. This method is meant to house validation logic not associated with one field in particular. For example, let’s suppose we have an application where our users can order gourmet-level cat & dog food. […]