Fork this blog on GitHub Fork this blog on GitHub

DatabaseError: permission denied errors on Heroku

DatabaseError: permission denied errors on Heroku

If you are seeing this error while investigating Heroku logs, it might be because your write permissions have been taken away!

Whoops! How do I know that? This blog was down for a couple of days because I had exceeded the maximum number of Postgres database rows on my Heroku free account. Conveniently, Heroku now makes it easy to directly interact with Postgres data via psql.

I fixed the issue and waited 24 hours, but I was still receiving HTML 500 errors. This time the errors were limited to my django admin login page. Upon inspection of the traceback, it ...

Continue reading

Customizing Vim to Easily Add Python Breakpoints

I added a few lines to my .vimrc today in my ongoing effort to be more productive and type fewer key strokes.

First I changed the <leader> variable from a backslash to a comma which is easier to type.  The leader variable is useful for creating custom commands.

"Easier mapleader than the default "\"
let mapleader = ","


Instead of manually typing "import ipdb; ipdb.set_trace()", the following vim configuration will insert a python breakpoint in the next line by typing ,p in normal mode.  As the comment explains, ctrl v and then escape must be typed in order to create the characters ...

Continue reading

Python Argparse - Parsing Command Line Scipt Arguments

The python argparse module is quite nifty.  In the past I have used code like this to parse arguments to command line scripts:

import sys

prog_name        = sys.argv[0]

def printUsage():
  print 'Usage: ' + prog_name + ' USEFUL_ARGUMENT'
  print 'This script does something useful with an argument.\n'
  print 'Examples:'
  print '  '+ prog_name + ' USEFUL_ARGUMENT\n'
  exit()


sys.argv.remove(prog_name)
if '-h' in sys.argv or '--help' in sys.argv or len(sys.argv) != 1:
  printUsage()

useful_arg = sys.argv[0]

The argparse module helps to eliminate boilerplate code, provides nice formatting for free, and provides useful features. Here is the same code using the ...

Continue reading