development

Articles under this tag

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:

Edit file as another user in Emacs
Gergely Polonkai
Nov 10, 2016 :: 08:57

I have recently found this article by Bozhidar Batsov on opening the current file as root. I barely use tramp for sudo access, but when I do, I almost never use root as the target user. So I decided to fix it for my needs.

Emacs package to generate GObject boilerplate
Gergely Polonkai
Sep 28, 2016 :: 15:40

Before I started using Vala (and sometimes even after that) I often needed to generate new classes based on GObject.

Vala interface madness
Gergely Polonkai
Feb 26, 2016 :: 13:07

Although I have just started making it in C, I decided to move my Matrix GLib SDK to Vala. First to learn a new language, and second because it is much easier to write GObject based stuff with it.

Emacs: Implement a GObject’s virtual function
Gergely Polonkai
Jan 13, 2016 :: 13:31

I have recently started creating a GLib implementation of the Matrix.org API. For that, I have created a GObject interface, MatrixAPI, which has as many virtual functions as API calls (which is a lot, and expanding). This way I ended up with the following scenario.

F/OSS Fail meter
Gergely Polonkai
Aug 19, 2015 :: 10:12

I have recently bumped into this article. Naturally, I quickly calculated the FAIL metrics for all my projects (most of them are pretty high). To ease calculation, I made up a small page based on this list (although I have divided the points by 5; I really don’t understand why spot is using such big points if all of them can be divided by 5). Feel free to use it, and if you have any recommendations (point additions/removal, new categories, etc.), leave me a comment!

Rounding numbers to N decimals in Emacs
Gergely Polonkai
Oct 7, 2014 :: 10:28

I have recently faced a problem, where I had a bunch of SVG files with a large amount of fraction numbers in the path definitions. These images were displayed in small size, so this amount of precision was irrelevant, and these numbers took almost half of my SVG images’ size. So I created an Elisp defun to round these numbers to 2 decimals:

Registering an enum type in GLib, glib-mkenums magic
Gergely Polonkai
Aug 16, 2014 :: 15:10

In this post I said I will get through the GLib Makefiles to add an enum type to GLib in a more sophisticated way.

From Symfony to Django in two days
Gergely Polonkai
Sep 24, 2013 :: 14:05

I was a Python hater for a long time, although I can’t really tell why. It didn’t fit in my mind, maybe. I was programming in BASIC, Pascal (none of these would come to my mind, though), C, PHP, Perl, JavaScript, and different shell “languages” like awk, sed or bash.

SWE-GLib final release
Gergely Polonkai
Sep 16, 2013 :: 21:37

Few of you may know that I’m interested in astrology. About two months ago I have decided to create an astrologers’ software for the GNOME desktop. Since then, I have contacted Jean-André Santoni, who created a software called Astrognome some years ago. We exchanged some e-mails, and after several weeks of coding, I’m proud to present SWE-GLib 1.0.1. This is “just” a library which wraps around Swiss Ephemeris, creating a nice GLib-ish interface around it. See the project page and the built-in GTK-Doc document for more information.

Renaming a Symfony 2 bundle
Gergely Polonkai
Apr 9, 2013 :: 22:29

Today I’ve realised that the name I gave to one of my Symfony 2 bundles should be something else. To rename a bundle, one must do four things (at least).

Haversine in MySQL
Gergely Polonkai
Mar 5, 2013 :: 12:49

Just insert it in your database, feed them two Google coordinates, and you get the distance in kilometres. If you happen to need it in miles, change the constant 12756.200 in the RETURN row to 7922.6 instead.

Why I stopped using annotation based routing in Symfony today
Gergely Polonkai
Feb 27, 2013 :: 23:10

I have read several opinions about routing configuration in Symfony. I stayed with annotation based routing as it was convinient for me to see the URL right above the controller action. This was because by just checking the URL, I remembered the controlling code, as they always were fresh ones. Well, until today.

git rm --cached madness
Gergely Polonkai
Jan 14, 2013 :: 21:38

I have recently learned about git rm --cached. It’s a very good tool, as it removes a file from tracking, without removing your local copy of it. However, be warned that if you use git pull in another working copy, the file will be removed from there! If you accidentally put the configuration of a production project, and remove it on your dev machine, it can cause a lot of trouble ;)

Registering an enum type in GLib’s type system
Gergely Polonkai
Jan 6, 2013 :: 02:34

I faced a problem in my GLib self-teaching project, wMUD today. I wanted to register a signal for a GObject, whose handler should accept two enum parameters for which I had to register a new GEnum type in the GObject type system. However, the documentation on this feature (thanks for pointing out goes to hashem on #gnome-hackers) is not… uhm… obvious. Making the long story short, I have checked with the GIO sources for an example, and using that, I have created this small, working chunk:

Development man pages on Fedora
Gergely Polonkai
Jan 5, 2013 :: 18:20

If you use Fedora (like me), and can’t find the development manual pages for e.g. printf(3) (like me), just yum install man-pages (like me).

Changing the session cookie’s name in Symfony 2
Gergely Polonkai
Oct 13, 2012 :: 12:49

I have a development server, on which I have several Symfony 2.x projects under the same hostname in different directories. Now I’m facing a funny problem which is caused by that the cookies Symfony places for each of my projects have the same name.

SmsGateway and SmsSender
Gergely Polonkai
Oct 7, 2012 :: 00:10

I have just uploaded my SmsGateway, SmsSender and SmsSenderBundle packages to GitHub and Packagist. I hope some of you will find it useful.

How to start becoming a web developer
Gergely Polonkai
Sep 7, 2012 :: 18:12

A friend of mine asked me today how to become a web developer. It took me a while, but I made up a checklist. It’s short, but it’s enough for the first steps.

Why you should always test your software with production data
Gergely Polonkai
Dec 11, 2011 :: 12:14

I’m writing a software for my company in PHP, using the Symfony 2 framework. I’ve finished all the work, created some sample data, it loaded perfectly. Now I put the whole thing into production and tried to upload the production data into it. Guess what… it didn’t load.

Gergely Polonkai is a systems engineer of a telco company, and also a freelancer self- and software developer.

He is learning about different IT subjects since the late 1990s. These include web development, application building, systems engineering, IT security and many others. He also dug his nose deeply into free software, dealing with different types of Linux and its applications, while also writing and contributing to some open source projects.

On this site he is writing posts about different stuff he faces during work (oh my, yet another IT solutions blog), hoping they can help others with their job, or just to get along with their brand new netbook that shipped with Linux.

“I believe one can only achieve success if they follow their own instincts and listen to, but not bend under others’ opinions. If you change your course just because someone says so, you are following their instincts, not yours.”