Using MITMProxy for Testing and Debugging

In web development, you might occasionally get the urge to update a production server directly. Don’t do that. It may seem harmless to add some logging to better understand a bug, or make a quick change to test a proposed fix. Whatever the reason, manually updating code in production is risky business. Something will probably break, and undoing the change may not be as simple as a quick revert. At that point users will be impacted, and your boss will not be pleased.

Piping Data into a Custom Django Management Command

For command line administration of a django site, nothing is better than manage.py. It provides a single point of access for database management, development tasks, data serialization and deserialization, testing, and more. Even better, you can write your own custom commands and ship them with your app. In many cases, the expected input for a manage.py command is simple. It may be an app name or a list of model ids, which can be easily typed for a one off command, i.e.python manage.py somecommand 1 2 3. This is great when you already know the input, but there are cases when you need to run one command to get the information you need for a follow up command. How can we solve that problem?

Breaking an iterable into chunks

The itertools library is one of my favorites in the python stdlib. It allows you to operate on an iterable in all kinds of fun and iteresting ways. For example, if you have a series of iterables and you’d like to loop over one after the other performing the same operation, you might normally do something like this: