Category: technical

Python Memory Footprint

This is a cross listed blog post. I had posted this blog on my company’s blog and wanted to repost here as it is a topic that very few python developers understand. Python has a high memory footprint, understanding that is the key to writing very space efficient python programs.Note there will be a follow…

continue reading
No Comments

uWSGI vs Gunicorn

TLDR; 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) History I have always been a big fan of the uWSGI project. It has…

continue reading
12 Comments

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…

continue reading
No Comments

Oneliner to generate a Django Secret Key

python -c “import string,random; uni=string.ascii_letters+string.digits+string.punctuation; print repr(”.join([random.SystemRandom().choice(uni) for i in range(random.randint(45,50))]))”

continue reading
No Comments

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) DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::=”–force-confdef” -o Dpkg::Options::=”–force-confold” dist-upgrade

continue reading
No Comments

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: echo ‘source $BYOBU_PREFIX/share/byobu/keybindings/f-keys.tmux.disable’ >> ~/.byobu/keybindings.tmux For Screen: # Enable Screen if you haven’t,…

continue reading
No Comments

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…

continue reading
No Comments

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 hg –config extensions.purge= –help

continue reading
No Comments

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

NO! 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.

continue reading
No Comments

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. for r in ( MyTable.objects.filter(somefield=’a’) | MyTable.objects.filter(someotherfield=’b’) ).filter(somethird=’c’): print r Now this becomes really useful when you use related_managers: for…

continue reading
No Comments