Tag Archives: bash

Best Practices Patterns

Patterns: don’t mess up the prod db!

With 12factor style environment configs, it’s a very easy to accidentally connect to your production database when you think you’re connecting to dev. Here’s a simple guard you can add to make sure your  DATABASE_URL isn’t somehow pointed to someplace it’s not supposed to (assuming you’re using Amazon AWS):

bash:

if [[ ${DATABASE_URL} == *"amazonaws"* ]]; then exit -1; fi

Python:

if 'amazonaws' in os.environ['DATABASE_URL']:
   exit('Cannot be run against a production database')

Django:

if 'amazonaws' in settings.DATABASES['default']['HOST']:
    raise CommandError('Cannot be run against a production database')

(thanks to x110dc for the bash syntax and 12factor link)

You didn't say the magic word

Life=Boring Nerd

Weekend^H^H^Hday Hack

So today, being stuck in the house, I decide I should streamline some of my things in the unix world. So I picked up some BASH scripting. I got some serious flashbacks to the 90’s. I would have flashed back earlier, but I’m not old enough. It really makes you appreciate the UNIX geeks of yesteryear. Those guys were clever. And this code looks ugly. But it could be worse… I could be doing MUMPS.

Some sites that aren’t Google I found helpful:

And some random grep links: