Running Linux GUI Applications in Windows

Hi 👋, This is a quick tutorial on how to run Linux graphical interface application in Windows using X Server’s forwarding feature. The first step is to download and install the VcXsrv Windows X Server on your 💻 Windows machine. Then, start VcXsrv with the following configuration: Ensure that VcXsrv is not blocked in Windows Firewall, it should be allowed in Public and Private networks. You may also use more restrictive firewal settings as explained in /wsl-windows-toolbar-launcher#firewall-rules. ...

October 2, 2021 · 1 min · Denis Nuțiu

Improving the throughput of a Producer ✈

Hello 👋, In this article I will give you some tips on how to improve the throughput of a message producer. I had to write a Golang based application which would consume messages from Apache Kafka and send them into a sink using HTTP JSON / HTTP Protocol Buffers. To see if my idea works, I started using a naïve approach in which I polled Kafka for messages and then send each message into the sink, one at a time. This worked, but it was slow. ...

August 28, 2021 · 4 min · Denis Nuțiu

Kubernetes service account for pod

Hi 🙋‍♂️, In this article I will talk about how to authenticate your applications to the Kubernetes API via the service accounts feature. Citing the Kubernetes docs, a service account for a pod: “provides an identity for processes that run in a Pod. When you (a human) access the cluster (for example, using kubectl), you are authenticated by the apiserver as a particular User Account (currently this is usually admin, unless your cluster administrator has customized your cluster). Processes in containers inside pods can also contact the apiserver. When they do, they are authenticated as a particular Service Account (for example, default).” 💡 ...

June 5, 2021 · 4 min · Denis Nuțiu

FastAPI Uvicorn logging in Production

Hello 🙋‍♂️, Running a ⏩FastAPI ⏩ application in production is very easy and fast, but along the way some Uvicorn logs are lost. In this article I will discuss how to write a custom UvicornWorker and to centralize your logging configuration into a single file. To keep things as simple as possible I’ve put all my code in a single Python file. main.py 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 import uvicorn as uvicorn from fastapi import FastAPI, APIRouter router = APIRouter(prefix="") def create_app(): fast_app = FastAPI() fast_app.include_router(router) return fast_app @router.get("/") def read_root(): return {"Hello": "World"} if __name__ == '__main__': app = create_app() uvicorn.run(app=app) Running the code will return a {"Hello": "World"} json when you visit the root endpoint / at http://127.0.0.1:8000. 😁 ...

May 18, 2021 · 3 min · Denis Nuțiu

Kubernetes OpenID Connect Integration with Resource Owner Flow

Hello 😄, In this article, I will demonstrate how to configure Kubernetes (minikube) to use OpenID Connect as an authentication strategy. We will cover the Resource Owner Password flow. Feel free chose the right authentication flow depending on your application’s needs. Please refer to this diagram in order to choose the flow: Note that the Client Credentials flow is not supported by Kubernetes. According to the official docs: “To identify the user, the authenticator uses the id_token (not the access_token) from the OAuth2 token response as a bearer token. “ ...

May 14, 2021 · 6 min · Denis Nuțiu

Context Managers and Cross Cutting concerns in Python

Hello, In this short article I would like to talk about context managers. I personally consider that at the core they are just a form of decorators. If you don’t know what a decorator is check the Decorator Pattern Wikipedia article. Decorators can be used to implement cross-cutting concerns. We have componentA and we need logging and security, we could write the logic for logging and security handling in componentA but some people consider component a should be componentA not componentAthatAlsoKnowsAboutSecurityAndOtherStuff. Since it’s not the component’s responsibility to authorize requests or log calls to a external logging service, we can wrap the componentA into a decorator that does just that. ...

March 7, 2021 · 4 min · Denis Nuțiu

Constructor Injection and Null Object Design Patterns

The Constructor Injection design pattern is a pattern that helps you declare all the required dependencies of a class in it’s constructor. This is useful because it helps you decouple the code, you can specify an interface instead of a concrete type, remember, program to an interface. Also, in the constructor it is easier to guard against null objects. The calling code doesn’t have to worry about null exceptions every time it uses a dependency. ...

November 7, 2020 · 2 min · Denis Nuțiu

Composition Root Pattern: How to Write Modular Software

The composition root is a design pattern which helps you structure a software application by implementing a class that builds all the other classes. In this example we will examine this pattern in Python. Here’s the object graph of the classes that we’re going to implement: I have designed a sample application that we’re going to use. It contains three components: ConsoleInputListener, ConsolePrinter and RomanianTranslator and a value object class: Message. ...

November 6, 2020 · 4 min · Denis Nuțiu

Introduction to Pyenv for Linux Users

Hello, In this article I will introduce you to pyenv, a tool for managing python environments. Installing pyenv is pretty straight forward, you’ll need to clone the repo and add the binaries to the path. For a typical Debian based distro using the Zsh shell the instructions would be: 1 2 3 4 git clone https://github.com/pyenv/pyenv.git ~/.pyenv echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc Then, in order for this to take effect, you need to reload the shell with: source ~/.zshrc, or just restart your terminal. 😀 ...

June 27, 2020 · 4 min · Denis Nuțiu