Sunday, April 10, 2016

SQLAlchemy - JSON not changing on commit

If your changes to a JSON, JSONB, or HSTORE field aren't saving after you commit, then you need to wrap your field in the MutableDict shown here:

Saturday, April 9, 2016

SQLAlchemy - AttributeError: type object 'JSONB' has no attribute 'lower'

This error happened because I mistyped "db.column" instead of "db.Column" when I was creating my database model using SQLAlchemy.

This might be your problem if db.create_all() isn't creating all the columns you expected.

Saturday, March 19, 2016

PHP - Problems With Long Running Processes

Great article about the problems with using PHP for long running processes:

Describes the main reason why I started using Python for long-running jobs.

Thursday, March 3, 2016

Ansible Vault - storing secrets in repos

When others are deploying a project for you, it's easy for mistakes to be made when secrets must be updated in environmental variables. Ansible-vault takes a different approach and encrypts the secrets - allowing you to store the secrets in your repo.

To encrypt a file: ansible-vault encrypt
To decrypt a file: ansible-vault decrypt

More documentation is available here:

Python - isort, useful tool for sorting python imports

I saw it in the django coding style documentation:

To make an entire project's imports easier to read, all you need to do is:

  • pip install isort
  • isort -rc .

There's also a sublime plugin for it here:

Thursday, February 18, 2016

git commit --amend -C HEAD

Ever committed something and needed to make changes later? Just rebase and squash it, right? Or maybe "git reset --soft HEAD~1" and commit again?

There's an even better solution: "git commit --amend -C HEAD"

It will add the combine your commit with your last commit. If you already pushed, you will need to force push your change.