Plurrrr

week 06, 2022

Faster Python calculations with Numba

For certain types of computation, in particular array-focused code, the Numba library can significantly speed up your code. Sometimes you’ll need to tweak it a bit, sometimes it’ll just work with no changes. And when it works, it’s a very transparent speed fix.

In this article we’ll cover:

  • Why using NumPy on its own is sometimes not enough.
  • The basics of using Numba.
  • How Numba works, at a high-level, and the difference that makes to how your code runs.

Source: Faster Python calculations with Numba: 2 lines of code, 13× speed-up, an article by Itamar Turner-Trauring.

Running your own email server

Email was one of the earliest services for communication via the internet. But, hosting such a simple service is quite complicated nowadays. In this post I have documented how I set up an email server for a business quickly and easily.

Source: Running your own email server, an article by Vimarsh Shah.

How to write better Django code

In this post I will be sharing some tips, which can be used for better code quality. It will also help you not to shoot yourself in the foot later in the process.

As many know, Django is an awesome web framework. It allows building webapps, prototypes etc. blazing fast. I have been using it for most of my projects, and I have never been disappointed. Django works great in small to medium codebases. The problems start to arise, when codebase start to grow to millions of LOC with hundreds of models.

Source: How to write better Django code, an article by Klemen Štrajhar.

Anne Frank House

In the morning we went to Amsterdam. We had planned a visit to the Anne Frank House in the afternoon. When we arrived we first got a short introduction and then could wander through the various room, each with an explanation. The visit was not easy to me and I kept wondering how people could be this cruel to others.

A school desk and a bicycle
A school desk and a bicycle. In the background a photo of Anne's Kindergarten class.

After the tour we paid a visit to the bookshop. Adam wanted the Dutch version of Anne Frank's diary, which we bought. Alice already owned an English edition which I bought in a second-hand store some time ago.

Adam's copy of Anne Frank's diary
Adam's copy of Anne Frank's diary.

On the way back Adam read a little in the diary in the train. But he got tired and gave the book to me and I took the above photo. I am considering to read the book as well.

Combining protocols in Swift

Like with so many things in programming, there are no right or wrong answers here, but I hope that this article has shown a few different ways to combine the functionality of multiple protocols, and what sort of tradeoffs that each approach comes with.

Source: Combining protocols in Swift, an article by John Sundell.

Adding a user to the docker group

At my work, after I had installed Docker I added myself to the docker group as follows:

sudo usermod -aG docker ${USER}

This makes is possible to run docker without sudo. Next, I did:

su - ${USER}

To get a new shell in which I had been added to the docker group. I verified this using:

groups

And indeed as expected the group docker was listed.

How Postgres Stores Rows

Out of curiosity, I was trying to understand how PostgreSQL stores the data onto the disk and there are a few interesting things that I have noticed that might be useful for application developers. In this post, I will try to go into the implementation level details and map out how PostgreSQL row storage really works.

Source: How Postgres Stores Rows, an article by Ketan Singh.

Perl list processing is for hashes, too

In general, I urge you to work through the Perl documentation’s tutorials on references, lists of lists, the data structures cookbook, and the FAQs on array and hash manipulation. Then dip into the various list-processing modules (especially the included List::Util and CPAN’s List::SomeUtils) for ready-made functions for common operations. You’ll find a wealth of techniques for creating, managing, and processing the data structures that your programs need.

Source: Perl list processing is for hashes, too, an article by Mark Gardner.

3 Things I Hate About Kubernetes

Anyone who knows me, or who has read my work, knows that I can not shut up about Kubernetes. In fact, they are probably part of a betting pool about how often I say that word.

I am not sorry, though. The abstraction it offers makes my job far easier and, in general, it is a reliable force-multiplier for any DevOps team. With anything, however, we have to take the good with the bad, and Kubernetes presents plenty of formidable challenges for new users trying to learn how to use it. In my 3+ years of working with Kubernetes I have faced several such trials, with a couple standing out as very memorable headaches. As a word of caution and guidance for new folks, I have compiled a list of what I think are the worst Kubernetes nuisances.

Source: 3 Things I Hate About Kubernetes, an article by Juan Diego Palomino.

The Friendly Cat

In the morning I saw the cat that had visited us a few times in the front of our house. I called it and let it inside. It's a beautiful cat and very friendly. It started to visit us earlier this year.

The friendly cat resting on the floor
The friendly cat resting on the floor.

RAID-Z Expansion Feature for ZFS In the Home Stretch

The Foundation sponsored feature reflows existing data to rewrite it onto a new arrangement of disks thereby freeing space at the end of the logical RAID-Z group

The FreeBSD Foundation funded the project to ensure the completion and release of an easy-to-use and practical application. The project came in under budget despite delays caused by the pandemic. The feature was developed by Matthew Ahrens and is now completed but not yet integrated.

The purpose of this overview is to introduce the feature and explain how it works.

Source: RAID-Z Expansion Feature for ZFS In the Home Stretch.

Font-independent pixel-perfect negative CSS text-indents

The CSS text-indent property is used to offset the first line of text in a text block from the parent element’s inner box (the content area). It behaves like the padding-inline-start property, but only for a paragraph’s first line of text. It’s meant to allow your design to e.g. indent the first line to designate the start of a new paragraph (a more compact alternative to separating paragraphs by empty lines).

The text-indent property has some additional uses with negative values. In this article, I’ll explore how the property can be used to implement hanging punctuation and list item markers. I’ll also discuss how difficult it is to know how many pixels to subtract for the desired effect, and how you should implement it instead. Some familiarity with CSS syntax, layout concepts, and common properties is assumed.

Source: Font-independent pixel-perfect negative CSS text-indents, an article by Daniel Aleksandersen.

Select the most recent record (of many items) with PostgreSQL

Time-series data is ubiquitous in almost every application today. One of the most frequent queries applications make on time-series data is to find the most recent value for a given device or item.

In this blog post, we'll explore five methods for accessing the most recent value in PostgreSQL. Each option has its advantages and disadvantages, which we'll discuss as we go.

Source: Select the most recent record (of many items) with PostgreSQL, an article by Ryan Booz.

Using 'git rebase' to Perfect Commits

I have long tried to get into the good habit of committing as I develop. However, I often fell into the same scenario. On commit №4, I would realise that I should have worked something differently in commit №2.

Naively, my old approach was a combination of adding extra re-work commits and different forms of git reset. git rebase to the rescue!

The git rebase -i command was everything I believed had to be part of git but didn’t know of. The -i flag is the ‘interactive’ mode of git rebase. Which allows you to choose which commits you want to rebase.

Source: Using 'git rebase' to Perfect Commits, an article by Adam Hawley.