Blogging again

I used to have  a posterous blog (even before it was renamed spaces, and then shutdown post twitter acquisition). What made me post frequently is the ability to easily post by email. Since the shutdown I have posted a few short tidbits on coderwall but nothing substantial. I have been also posting on my company’s blog.…

read more

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…

read more

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))]))”

read more

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

read more

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,…

read more

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…

read more

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

read more

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.

read more

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…

read more

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: [uwsgi] plugin = python27 enable-threads = true single-interpreter = true virtualenv = /path/to/leadsift/staging/builds/current env = NEW_RELIC_CONFIG_FILE=newrelic.ini env = NEW_RELIC_ENVIRONMENT=staging env = DJANGO_SETTINGS_MODULE=leadsift_app.settings.staging module = leadsift_app.wsgi:application

read more