Modularising your shell config for a cleaner setup

Note: The setup described in the following sections can be applied to shells like bash, zsh, fish and other common unix shells. However, keep in mind that the command(s) might differ a bit.

I’m using custom shell commands, aliases, and functions quite heavily. As my .bashrc and .zshrc grew too big, I decided to mudularise my config and want to share with you how I’ve done it.

First of all, I’ve created a dedicated directory in my root directory for all of my custom shell commands, aliases, and functions:

$ mkdir ~/.shell_config


Solving the black screen Screen Capture (XSHM) issue occurring under Debian

Recently, I wanted to use OBS Studio (Open Broadcast Software) to record some of my coding sessions. As I switched from Windows to Debian a lot of things are still new to me.

As I followed along there (unofficial) build instructions, I got OBS Studio up and running except the most important feature: Screen Capture.

That’s why I also tried building it from source and installing it via snap. However, audio and Window Capture just worked fine, but the Screen Capture did not.

It seemed to be a display…


After publishing my last article, which was about list.sort() and sorted(list), I was asked, why I was using the boxx library instead of built-in functionalities to measure the execution time of certain pieces of code. I responded, that it’s only personal preference and that you can simply create your own context manager measuring the execution time of code pieces.

In this article I will show you how to create your own timing context manager. Furthermore, different ways to accomplish that are covered.

Time Measurement

What’s already available?

Python provides you different ways to measure the execution time. For instance you can use Python’s built-in timeit


A closer look at Python’s built-in List Sorting Methods concerning Memory Consumption and Time Efficiency

Introduction

Recently, I came across the question, which method to sort a list is more efficient: Using Python’s built-in sorted function or relying on the list.sort method. To answer this question I started a little investigation described in this article. You can find the repository I’m referring to on GitHub.

The starting point is a Python list containing 1.000.000 random numbers (integers) built using the random module:

import randomarr = [random.randint(0, 50) for r in range(1_000_000)]

The generated numbers are in the range from 0 (inclusive) to 50 (inclusive).

Memory Consumption

Let’s have a look at the memory consumption of both functions…


After the emersion of the runC container runtime bug it’s finally the time to run processes in Docker containers as non-root user. This article shows you how to achieve that with your Python applications.

Using requirements.txt

If your project uses a plain requirements.txt , you can use the following snippet to run your application as non-root process in the Docker container.

pip is upgraded before using a worker user, because it’s installed as root and can’t be accessed by a non-root user. …


Recently, I wanted to start my open source journey by contributing to an open source project called wily. The issue I was working on was to first add a version flag to print the current version of the tool and second to add the version to the help page.

As the project uses click to create a user friendly command-line interface, the help page is auto-generated based on the docstrings. That’s great, but refuses to inject custom dynamic texts. To recall the example of adding the version to the help page, you need to update your version twice: Inside of…


A few months ago I’ve seen a tweet from a Python learner with a code snippet containing f-strings. I asked, why she’s not using format() . She answered, that this is the new way of formatting strings. I was curious about it as I didn’t hear about it before. Seeing other people using it, I started to do it as well.

Two weeks ago I spotted a Pull Request on GitHub where somebody used f-strings to convert a value to a string as in the example below.

I was surprised by the usage of f-strings in this particular case…


Ending up the #100DaysOfCode-challenge with informing about newer Python releases, asynchronous programming and community work.

With this article I not only summarise my past two weeks of learning and coding, but also end up my #100DaysOfCode-challenge. Two weeks ago I had ten days left before finishing the challenge and decided to spread them over two weeks to have some more time to get into Python a little deeper.

More insights into Python

The past two weeks I spent more on getting deeper into Python itself than working on a specific project like my personal portfolio page. Therefore, I read different PEPs at the official…


A simple face recognition application based on a predefined model.

A week on the subject of image recognition and Python secrets everybody should know about.

Image and Video Recognition

This week I started with the focus on learning more about image recognition with a predefined model instead of a neural network. I already worked with OpenCV manipulating existing images and created a package for colour manipulation.

To keep things simple I searched for a predefined model, which would detect faces in an image if implemented correctly. I found a useful set of cascade classifiers and imported the one for face recognition. After that I made use of OpenCV’s multi-scale detection method detectMultiScale() to find…


Playing around with IPython. Working on the command line. Going on finishing my portfolio page.

This week was the first week I was back studying in Mannheim. After two months of internship it was quite challenging to find back into routine. That’s actually the major reason, why I wasn’t able to code as much as I usually do and as I wanted to. Nevertheless, I coded around most of the days and provide a summary of the challenges I had to deal with and the insights I’ve got.

Playing around with IPython

For one year now, I do most of the things via the…

Florian Dahlitz

Student, Developer, IBMer. Member of the RealPython.com team. Coding and sports are my passion. Python | C/C++ | Java

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store