Testing Python projects with Tox

Hi 👋 In this article I will show you how to test your Python projects with Tox. Introduction Tox is a tool for automating testing in Python, their vision is to standardize the testing process. It can be used to easily test your project using multiple Python interpreters and run various commands. Getting Started To get started all you need to add to your project is a tox.ini file. To simplify running the tests we will make use of the following Dockerfile, which contains Python interpreters for 3....

July 29, 2021 · 3 min · Denis Nuțiu

Tail Recursion

Hello everyone! 👋 Today’s article will be about tail recursion, a technique that allows you to optimize certain recursive functions. Introduction In short, when you write a recursive function, each new call it does allocates a frame onto the stack. For example, let us take this following function: private static long RecursiveFib(long n) { if (n <= 1) { return n; } return RecursiveFib(n - 1) + RecursiveFib(n - 2); } If we set a breakpoint at return n and call the function with RecursiveFib(10), we will get the following stack frame....

July 3, 2021 · 3 min · Denis Nuțiu

Docker basics for Developers

Introduction Hello 🙋‍♂️ In this article we will discuss a tool called Docker 🐬 Docker is a platform which allows to package individual applications in containers. This achieves application isolation at the OS level without the need to use virtualization technologies by making use of the OS APIs. Since it can be a little hard to get into Docker if you are new I will try to keep things short and concise....

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

Arduino Simple Simon Says

This article is a re-post, the original one is on another website. Introduction I started this project some time ago in order to get familiar with Arduino. I will provide you the code and the wiring instructions if you have all the components ready it should not take more than 30 minutes. This is also the first time I am writing a guide on Hackster, if you think I’m wrong on some aspects or if you think it can be improved, please leave feedback in the comment section....

June 18, 2021 · 7 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)....

June 5, 2021 · 3 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 import uvicorn as uvicorn from fastapi import FastAPI, APIRouter router = APIRouter(prefix="") def create_app(): fast_app = FastAPI() fast_app....

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

PMS5003 C# Library

Hello everyone, I just want to let you know that I’ve released a C# library for interfacing with the PMS5003 (Particulate Matter Sensor) via UART. The code is available on Github and the package is available on NuGet. If you have any feedback or need some feature into the library, please open an issue on Github. Thank you!

April 11, 2021 · 1 min · Denis Nuțiu

PMS5003 Particulate Matter Sensor Test Run

Hi In this article we’ll test out the PMS5003 sensor in order to see if it works. I’ve forgot to buy a connector board, so we will do a manual connection to the Raspberry Pi 3 B V2. This involves cutting the wires and adding some resistors. Please note that you need: 5 Jumper Wires 2 Resistors 10K Ohm Raspberry Pi Setup Before connecting the sensor to the Pi we need to configure the Pi for this usecase....

March 28, 2021 · 2 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....

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