uWSGI vs Gunicorn


Gunicorn isn’t just “trendy” it actually works really well, in some cases (like mine) works much better than uWSGI. (also it seems that uwsgi is now becoming trendy, so am I just a hipster for switching to the uncool option :P)


I have always been a big fan of the uWSGI project. It has always been my number one choice of deployment of python web apps, running behind nginx as a reverse proxy. I have always checked to see if there is anything better out there and have always decided to stick to uWSGI. Data like [Nicholas 2010] [Kgriffs 2012] [DCramer 2013] made it easy for me to stick to my uWSGI choice and make my argument for uWSGI over the more “trendy” gunicorn [DCramer 2013].

Tmux – Attach to Different Windows

I am (was) a big time GNU Screen user. Once byobu arrived, I was a big fan of that and switched to it (byobu, is basically a fancy/pretty .screenrc). Byobu shortly after made Tmux the default and I was slow in adopting the use of Tmux instead of screen. Recently though I decided to embrace Tmux for its claimed lightweight. There are a few variations which once embraced can actually be a good thing.

Oneliner to generate a Django Secret Key

Debian – Truly Unattended Upgrades

This will make sure you bypass those pesky questions, with the safest option. For when you want to do an upgrade in a script (such as from a Vagrant :shell provision)

Making Byobu Behave

I love byobu (the awesome screen/tmux wrapper). One of my pet peeves with byobu, is it takes over the Function keys (F-keys). There is very little to no documentation on how to disable that by default. Here is how …

For Tmux:

For Screen:

Avoid Hyphens in Puppet Class Names

We had been using hyphens in class names until I faced an issue that I wasn’t able to figure out. The issue is, if you have a class name with a hyphen, and then try to grab a fully qualified variable from the class, the puppet dsl parser thinks its a minus.

They seemed to fix the issue and should be released with puppet 3.5; but until then, use underscores if you need to but avoid the issue.

Here is the doc that briefly mentions the gotcha: http://projects.puppetlabs.com/projects/puppet/wiki/allowed_characters_in_identifier_names

Hopefully this helps save some time if you hit this issue.

Enable HG Extensions for one command

Sometimes you want to enable an extension for just one command (either being on a different machine, or just don’t really want to clutter your hgrc for a one time thing) you can use –config directly on the command line, for example to enable the purge extension

Should you use underscore prefixes in python (private) variables?


especially not double underscores, never! … if you really really want and have an itch you want to scratch use one underscore, that’s more than enough to tell users that they shouldn’t change it.

Django OR Querysets using Binary Operator

One of Django’s cool (maybe the coolest) and undocumented feature is being able to OR and AND queries using bitwise (& and |) operators. It is a variation to the Q object that is documented.

Now this becomes really useful when you use related_managers:

while aTable and xTable are totally different instances yet they reference MyTable

Multiple ENV vars with UWSGI

To send in multiple environment variables using the uwsgi ini, you just need to pass in multiple env parameters for example: