• Check if the last Git commit has test coverage

    Gergely Polonkai
    Jul 26, 2018 :: 12:49

    I use Python at work and for private projects. I also aim to write tests for my code, especially recently. And as I usually don’t start from 100% code coverage (TDD is not my game), I at least want to know if the code I just wrote have full coverage.

  • Please welcome Calendar.social

    Gergely Polonkai
    Jun 26, 2018 :: 05:36

    I started looking at decentralised/federated tools some years ago, but other than Matrix I didn’t use any of them until recently. Then this February I joined the Fediverse (federated universe) by spinning up my own Mastodon instance. I’m not going to lie, this place is pure awesome. I follow only 53 people but unlike on Twitter or Facebook, I can’t just scroll through my timeline; I have to read the all. These 53 accounts are real persons over the Internet with meaningful posts. I could never find this on the noisy Twitter or Facebook timeline during the last 10 or so years.

  • Add SysAdmin day to Emacs Calendar

    Gergely Polonkai
    Oct 2, 2017 :: 09:37

    I’m a SysAdmin since 1998. Maybe a bit earlier, if you count managing our home computer. This means SysAdmin Day is also celebrating me. However, my Emacs Calendar doesn’t show it for some reason.

  • Category-based logging with Flask

    Gergely Polonkai
    Mar 26, 2017 :: 22: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 :: 09: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 :: 09: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 :: 12: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 :: 07: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: