Jan Buchar's blog


Using Cython to protect a Python codebase

Published on July 31, 2017

Recently, I worked on a Python project that required the whole codebase to be protected using Cython. Although protecting Python sources from reverse engineering seems like a futile task at first, cythonizing all the code leads to a reasonable amount of security (the binary is very difficult to disassemble, but it’s still possible to e.g. monkey patch parts of the program).

This security comes with a price though - the primary use case for Cython is writing compiled extensions that can easily interface with Python code. Therefore, the support for non-trivial module/package structures is rather limited and we have to do some extra work to achieve the desired results.

Continue reading...

Custom modifier-only shortcuts in Plasma 5.8

Published on October 7, 2016

The latest release of KDE Plasma (5.8) brought a new feature - it can open the desktop menu when the meta (super, Windows…) key is pressed. Like in Windows XP, remember? Alas, it’s not yet possible to configure this to do something more useful in the GUI, however weird this seems in a LTS release. After digging in KWin’s source code for a while, I found a way to set custom shortcuts in the config files.

First, make sure KWin isn’t running. I recommend opening a terminal and running killall kwin_x11. Now let’s say we’d like to open krunner when Meta is pressed and the desktop menu should be opened with Shift. Edit ~/.config/kwinrc and add the following lines:

[ModifierOnlyShortcuts]
Meta=org.kde.krunner,/App,,display
Shift=org.kde.plasmashell,/PlasmaShell,org.kde.PlasmaShell,activateLauncherMenu
Alt=
Control=

The double comma in the Meta value is not a typo. It means something like that the called function is not in a namespace, in contrast to the function in the Shift value. An empty value means no action will be bound to the modifier.

Now, you just need to run KWin again with kwin_x11 --replace and everything should work. Note that it should be possible to bind any qdbus call to a modifier key like this. Try using qdbusviewer to explore the possibilites!

Update (June 2024): Since Plasma 6.1 has been released, you can configure modifier-only shortcuts in the system settings, just like any other shortcut.

My web development setup with uWSGI

Published on September 5, 2016

Until recently, I’ve used pretty much the same LAMP environment I installed when I started with GNU/Linux. It had many drawbacks, the most important being cryptic configuration (hello, mod_rewrite) and the need to edit files as root when adding new applications using VirtualHosts. Also, running Python applications is quite a pain with Apache and mod_wsgi - most of the time, I just went with whatever development server my framework offered.

Then I stumbled upon uWSGI. I was blown away with how versatile this web application server is - it supports a plethora of programming languages, has a powerful routing system and loads of other features. I experimented with it for some time and this is the result - a flexible web development environment using uWSGI and Nginx.

Continue reading...