• Category-based logging with Flask

    Gergely Polonkai
    Mar 27, 2017 :: 00:00

    I’m in a team who are developing a Flask-based web application, which uses logging extensively. For a while now it spews out a lot of lines so the need arose to index them in ElasticSearch, and more importantly, to search through them for auditing purposes. This latter user story brought up one more question: why don’t we categorize our log messages? I quickly came up with an extended log format ([auth] is the new category name):

  • Rename automatically named foreign keys with Alembic

    Gergely Polonkai
    Jan 2, 2017 :: 10:41

    I have recently messed up my Alembic migrations while modifying my SQLAlchemy models. To start with, I didn’t update the auto-generated migration files to name the indexes/foreign keys a name, so Alembic used its own naming scheme. This is not an actual problem until you have to modify columns that have such constraints. I have since fixed this problem, but first I had to find which column references what (I had no indexes other than primary key back then, so I could go with foreign keys only). Here is a query I put together, mostly using this article.

  • Finding non-translated strings in Python code

    Gergely Polonkai
    Dec 22, 2016 :: 10:35

    When creating multilingual software, be it on the web, mobile, or desktop, you will eventually fail to mark strings as translatable. I know, I know, we developers are superhuman and never do that, but somehow I stopped trusting myself recently, so I came up with an idea.

  • Slugify in Python 3

    Gergely Polonkai
    Dec 8, 2016 :: 13:54

    Today I needed a function to create a slug (an ASCII-only representation of a string). I went Googling a bit, and found an excellend Flask snippet. Problem is, it is designed for Python 2, so I came up with a Python 3 version.

  • Add Python docstring to the beginning of anything in Emacs

    Gergely Polonkai
    Nov 30, 2016 :: 08:52

    Now that I write Python code for a living, I write a lot of functions, classes, and modules. What I still tend to forget, and also find tedious, is adding docstrings. Unlike many developers, writing documentation is not an enemy of mine, but it usually comes to my mind when I finish implementation. The procedure, roughly, is this:

  • How I started with Emacs

    Nov 3, 2016 :: 10:58

    Sacha Chua has a nice Emacs chat intro article back from 2013. I write this post half because she asks there about my (OK, anyone’s) first Emacs moments, and half because I plan to do it for months now.

  • git-merge stages

    Gergely Polonkai
    Oct 4, 2016 :: 14:46

    This was a mail to my company’s internal Git mailing list, after I realised many colleagues can’t wrap their heads around merge conflicts.