Compress, decompress and manage archives and files with Python in all the formats you might ever need

Photo by Tomas Sobek on Unsplash

Python standard library provides great modules and tools for pretty much any task you can think of and modules for working with compressed files are no exception. Whether it’s basics like tar and zip, specific tools or formats such as gzip and bz2 or even more exotic formats like lzma, Python has it all. With all these options, deciding what might be the right tool for the task at hand might not be so obvious, though. …


A hands-on, practical guide to signing software artifacts the easy way with sigstore project and cosign CLI

Photo by Miltiadis Fragkidis on Unsplash

Signing software artifacts has many obvious benefits such as code integrity or developer (author) authentication. Yet it’s oftentimes neglected, creating a software ripe for supply chain attacks. One of the reasons why people can’t be bothered to sign their code is that existing tools — such as PGP — aren’t very user friendly and require extensive security and/or cryptography knowledge.

Signing software can be easy though thanks to sigstore and its cosign CLI! In this article we will learn how cosign works and integrates with other sigstore components ( fulcio and rekor). …


Everything you need to know about sigstore project and its role in software supply chain trust and security

Photo by Shaojie on Unsplash

In recent months, there’s been a lot of noise in the area of supply chain security, because of the increase in attacks, with notable ones like Microsoft Exchange Server, Colonial pipeline or SolarWinds breach. These attacks could have been prevented with proper tools in place, yet finding the right tool for the job might be difficult as this area is hard to navigate and most of us — developers — aren’t security experts. Recently however, a new project was announced that might solve a lot of problems for all of us. …


Make your code faster, concise, more readable and more functional with help of Python’s little known operator module

Photo by Bilal O. on Unsplash

At the first glance Python’s operator module might not seem very interesting. It includes many operator functions for arithmetic and binary operations and a couple of convenience and helper functions. They might not seem so useful, but with help of just a few of these functions you can make your code faster, more concise, more readable and more functional. So, in this article we will explore this great Python module and make the most out of the every function included in it.

Use Cases

The biggest part of the module consists of functions that wrap/emulate basic Python operators, such as +, <<


Could resources such as Pods, Services or Deployments ever become deprecated and be removed from Kubernetes and how would that happen?

Photo by Gary Chan on Unsplash

In any software project, over time new features and APIs are added and from time-to-time some of them also become deprecated and eventually get removed. Even huge project such as Kubernetes is no exception to this, yet core parts of its API don’t really come to mind when thinking about deprecating and eventual removal. So, the question is — could a core object or API in Kubernetes, such as Pod, Deployment or Service be removed and if so, how would that go?

Long Story Short

If the answer to this question was “no”, then there would be no reason for this article, so…


Take a tour of Python’s functools module and learn how to use its higher-order functions to implement caching, overloading and much more

Photo by Joel Filipe on Unsplash

Python standard library includes many great modules that can help you make your code cleaner and simpler and functools is definitely one of them. This module offers many useful higher order functions that act on or return other functions, which we can leverage to implement function caching, overloading, creating decorators and in general to make our code a bit more functional, so let's take a tour of it and see all the things it has to offer...

Caching

Let’s start off with the simplest yet quite powerful functions of functools module. These are caching functions (and also decorators) - lru_cache, cache


Learn to parse and manipulate YAML files more efficiently using yq command-line utility and this simple cheat sheet

Photo by Matt Artz on Unsplash

Nowadays, YAML is used for configuring almost everything (for better or worse), so whether you’re DevOps engineer working with Kubernetes or Ansible, or developer configuring logging in Python or CI/CD with GitHub Actions — you have to deal with YAML files at least from time-to-time. Therefore, being able to efficiently query and manipulate YAML is essential skill for all of us — engineers. The best way to learn that is by mastering YAML processing tool such as yq, which can make you way more efficient at many of your daily tasks, from simple lookups to complex manipulations. …


Were you taught that function overloading isn’t possible in Python? Here’s how you can do it with generic functions and multiple dispatch!

Photo by Rodion Kutsaev on Unsplash

Function overloading is a common programming pattern which seems to be reserved to statically-typed, compiled languages. Yet there’s an easy way to implement it in Python with help of Multiple Dispatch or as it’s called in Python multimethods.

Overloading

First things first — you might be asking, how can we implement method overloading in Python when we all know that it’s not possible? …


The fastest and easiest way to debug and troubleshoot any application running on Kubernetes

Photo by Jamie Street on Unsplash

Debugging containerized workloads and Pods is a daily task for every developer and DevOps engineer that works with Kubernetes. Oftentimes simple kubectl logs or kubectl describe pod is enough to find the culprit of some problem, but some issues are harder to hunt down. In those cases you might try to use kubectl exec but even that might not be enough as some containers such as Distroless don't even contain shell that you could SSH into. So what do we have left, if all of the above fails? ...

There Might Just Be a Better Way…

Sometimes you need to grab a bigger hammer or just use…


Use these quick and easy tricks to optimize your web application’s size and performance to make it as fast as possible!

Photo by CHUTTERSNAP on Unsplash

Web application load speed is the most basic part of UX. Neglecting performance (load time) of your website can drive away users, because most people tend to leave the page after about 3 seconds if it doesn’t load, therefore it’s very important to make sure that your application loads as fast as possible. But how can you achieve that? There are many tricks and techniques for speeding up load time of an application and most of them don’t involve…

Martin Heinz

Certified Red Hat Professional | DevOps Engineer at IBM | Working with Python, JavaScript, Kubernetes, OpenShift, Docker and more | https://martinheinz.dev/

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