tl;dr We found that 10% of the 666 most popular Python open source GitHub repositories had the following f-string typo bugs: f prefix was missing: "hello {name}" instead of f"hello {name}" . f prefix was written inside the string: "fhello {name}" instead of f"hello {name}" . We even saw an example of "hello f{name}" . Concatenated strings used […]
Lets coin a name for a very special type of unit test: Schrödinger’s unit-test: a unit test that passes but fails to test the thing we want to test. This article focuses on our code scanning of 666 Python codebases to detect one such Schrödinger’s unit tests. Specifically, this gotcha (which we found in 20 […]
Part 2 of the “Hacking Django” series: part 1, part 3 Clickjacking is an attack where one of your logged-in user visits a malicious website, and that website tricks the user into interacting with your website via an iframe. As an example, see the green “create pull request” button which will create a Pull Request […]
You probably agree using {% static %} is not a controversial: If you’re unfamiliar: {% static %} returns the path the browser can use to request the file. At it’s simplest, that would return a path that looks up the file on your local file system. That’s fine for local dev but in prod we […]
Ever wished Alexa sounded like she was an old-timey radio? Sports stadium announcer Alexa? Alexa behind a door? Alexa Browser Client has you covered. Why? Because it’s cool. But also to demonstrate the advantages of running Alexa in the browser: we have full control over the audio received from Alexa Voice Service. Adding audio manipulation takes […]
I made a pluggable Django app that allows you to talk to Alexa through your browser: Add alexa_browser_client to your INSTALLED_APPS Run the Django app ./manage.py runserver Go to http://localhost:8000/alexa-browser-client/ Say something interesting to Alexa e.g., “Alexa, What time is it?” And hear Alexa’s answer through your browser, Buy why? It’s like the Amazon Echo, but web […]
Consider a form that allows users to search for holidays. It is expected behaviour that the form remembers previous searches – so if a user previously searched for “4 guests”, the form should pre-populate with “4 guests” the next time the page loads. This is a simple enough idea, but an odd bug was raised for this component. Ten points to Gryffindor for spotting it before […]
Consider a spreadsheet user management interface that allows creating and updating users in web spreadsheet. It must validate that usernames have not been used before: An obvious solution is to ask an endpoint if the username has already been taken. However, the admin user will experience a small lag due to the round trip from client […]
I reduced the file size of my app’s dependencies by 15% by only including the Angular Material source code my app actually uses. This simple action improved page load speed and this should reduce bounce rate. As the app in question is another app’s marketing app/landing page, this improvement can have real monetary value. The landing page is built with Angular […]
A common problem working with ajax is firing duplicate requests. A common solution is to first check if a request is ongoing. I solved this problem differently by memoizing the get request for the lifetime of the request. Memoization is storing the results of a function call and returning the cached result when the same inputs occur. This is often used to […]