Snippets of Python code, mostly in Flask.

Using model callbacks in SQLAlchemy to generate slugs

Feb 7th, 2017 in Python

Dive into SQLAlchemy's little known `event.listen` method to automatically generate slugs when saving a model instance.

Overriding default Jinja dictionary attributes in Python view templates

Jan 29th, 2017 in Python

How to use the `do` Jinja extension to modify an existing dictionary in your view template.

Custom Jinja template filters in Flask

Oct 30th, 2016 in Python

A short snippet for creating a template filter, to present datetime objects in Jinja templates.

JSON field type in SQLAlchemy (Flask / Python)

Sep 8th, 2016 in Python

Want to store JSON-serialized data in your database? But sick of calling `json.loads()` and `json.dumps()` when dealing with this data in your Flask app? Read on!

Resolving alembic merge branch conflicts

May 23rd, 2016 in Python

How to fix alembic's "Multiple head revisions are present for given argument 'head'" error.

Using Python's Watchdog to monitor changes to a directory

A small Python script to take action whenever a new file is uploaded to a directory or its contents change.

Data Pipelines - Airflow vs Pinball vs Luigi

Review of 3 common Python-based data pipeline / workflow frameworks from AirBnb, Pinterest, and Spotify.

Line-by-line code profiling in Python

Oct 1st, 2015 in Python

How to find slow sections in your Python code.