Plurrrr

a tumblelog
week 17, 2020

Web-Apps on Flask: How to Deal With Cyclic Imports

Flask is one of the most popular Python frameworks, but some mistakes that occur when using it may lead to certain difficulties. In this article, we will present the topic on how to prevent cyclic imports in a project.

Source: Web-Apps on Flask: How to Deal With Cyclic Imports.

Learn X in Y minutes: Emacs

Emacs started its life as “the extensible, customizable display editor” and grew over the years into a full-blown ecosystem. Many tasks, usually relegated to a diverse set of tools can be accomplished from within Emacs in a consistent, familiar interface. Examples include directory management, viewing PDF documents, editing files over SSH, managing git repos,… (the list is quite long). In short, Emacs is yours to make of it what you will: the spectrum of users varies from those who use it to edit text files to extreme purists who use it to virtually replace their operating system.

Emacs is extensible via a specialized dialect of Lisp known as Emacs Lisp (Elisp) which has a lot of macros geared towards editing text and managing text buffers. Any key (combination) you use in Emacs is bound to an Emacs Lisp function and may be remapped to any other function, including ones you write yourself.

Source: Learn X in Y Minutes: Emacs a contribution by Joseph Riad.

My NixOS Desktop Flow

NixOS is built on a more functional approach to package management called Nix. Parts of the configuration can be easily broken off into modules that can be reused across machines in a deployment. If Ansible or other tools like it let you customize an existing Linux distribution to meet your needs, NixOS allows you to craft your own Linux distribution around your needs.

Source: My NixOS Desktop Flow, an article by Christine Dodrill.

Knife: excellent

In the early afternoon I finished Knife, a new Harry Hole novel by Jo Nesbø. An excellent story; highly recommended.

Eve of Snows

Five hundred years ago the world shattered, banishing the gods from the Sister Continents and stealing the memories of the mortal peoples in an event known as the Great Forgetting. In seventeen days the stars will align, and a religious cabal will summon the gods back to the realms of men. In the northern tundra priests search the Steaming Lakes, a place tormented by the Wakened Dead. Deep in the mountains, demonic shadows assail priests at a holy shrine. In the south, the clans know something foul is afoot, and dispatch warriors to seek answers, but instead they find horrors.A young priestess named Eliles stands in the heart of this conspiracy; on her shoulders rest decisions which could prevent a holy war or demonic genocide. Through lies, manipulation, and murder, everyone is on a seventeen day march to fulfill or defy prophecy; the world will end or begin anew, come the Eve of Snows.

In the afternoon I started in Eve of Snows, Sundering of the Gods book 1, by L. James Rice.

New Features in Python 3.9 You Should Know About

The release of Python 3.9 is still quite a while away (5.10.2020), but with the last alpha (3.9.0a5) release out and first beta in near future, it feels like it’s time to see what new features, improvements and fixes we can expect and look forward to. This article won’t be an exhaustive list of every change, but rather a list of the most interesting and noteworthy things to come with the next version for us — developers. So, let’s dive in!

Source: New Features in Python 3.9 You Should Know About, an article by Martin Heinz.

Disabling Snaps in Ubuntu 20.04

Don't get me wrong, snaps are great in theory - If you aren't familiar, a snap package is like a sandboxed application that is packaged in such a way that:

  • You can be sure you're running exactly what the app developer intended, as all dependencies and assets are bundled into the snap application package
  • The snap application generally doesn't own your entire system, it runs in an application sandbox of sorts
  • Snaps are cross-platform and distributed independently from apt/deb packages, and as such are usually more up to date than those found in apt

Now this all sounds great, and it is in some ways (especially for app developers), but it comes at a cost: and that is generally performance and annoyances with application theming, access to user folders, and the like. I personally find that if I want to run a sandboxed application I lean more toward Flatpak as it is more performant and seems a bit more mature than Canonical's snap system.

In any event, I usually disable snaps entirely on a fresh install of Ubuntu, and I'll show you how to do that in the new Ubuntu 20.04 release.

Source: Disabling Snaps in Ubuntu 20.04, an article by Kevin Custer.

Intermediate Sed Usage

If you’ve been using Linux for any small length of time, you’ve likely used sed before. Most of the time, you’ve seen it in the form of sed "s/find/replace/g", so you simply go to it whenever there’s a replacement you want to do.

But sed stands for stream editor, and as a tool it can do more than just find and replace.

Source: Intermediate Sed Usage.

Doing Python Configuration Right

Let's talk about configuring Python applications, specifically the kind that might live in multiple environments – dev, stage, production, etc...

The tools and frameworks used in the application are not super important because the approach that I will outline below is based on vanilla Python. The impetus for this approach was caused by frustration with Django's settings, but this is my go-to for any kind of Python application I might be working on.

Source: Doing Python Configuration Right, an article by Michael Whalen.

Warnings are Errors

We all know what to do when our compiler spits out an error. The error indicates that we’ve made a mistake somewhere. What we do with errors is obvious: fix the error to get things running again.

But what about compiler warnings? They indicate that there might be a problem lurking somewhere. They most often indicate a potential bug, a small mishap or some other problems.

I think we should treat warnings with the same respect and severity as errors. We should stop work and fix them immediately. We should not continue with other matters before these problems have been resolved.

Source: Warnings are Errors, an article by Ari Autio.

Why I Prefer systemd Timers Over Cron

systemd has become a mainstay for the Linux world, but one of the things that still seems to stick around is cron jobs. It’s understandable, as cron is a tool that we have been using for a long time. Change is hard, but I think systemd Timers make the change well worth it. Here are a few reasons why…

Source: Why I Prefer systemd Timers Over Cron, an article by Thomas Stringer.

Ubuntu 20.04 LTS arrives

Canonical, the publisher of Ubuntu, today announced the general availability of Ubuntu 20.04 LTS, with a particular emphasis on security and performance.

Source: Ubuntu 20.04 LTS arrives.

Knife

Harry Hole is not in a good place. Rakel--the only woman he's ever loved--has ended it with him, permanently. He's been given a chance for a new start with the Oslo Police, but it's in the cold case office, when what he really wants is to be investigating cases he suspects have ties to Svein Finne, the serial rapist and murderer who Harry helped put behind bars. And now, Finne is free after a decade-plus in prison--free and, Harry is certain, unreformed and ready to take up where he left off. But things will get worse. When Harry wakes up the morning after a drunken night with blood that's clearly not his own on his hands, it's only the very beginning of what will be a waking nightmare the likes of which even he could never have imagined.

In the early afternoon I started in Knife, a new Harry Hole novel by Jo Nesbø.

Aphonopelma seemanni terrarium

In the evening I managed to get the lid off the plastic tub I keep an Aphonopelma seemanni in without disturbing the large spider. The tarantula was partially outside of its hide; a great opportunity to take some photos of my current set up.

Aphonopelma seemanni terrarium
Aphonopelma seemanni terrarium; a large plastic tub.

In the above photo you can see fake plants, a cork tube cut in half for a hide, a plastic bottle cap for water and some real moss. I keep the moss moist and let the rest of the substrate dry out more; it's still quite moist. The substrate is a mix of coco peat and sand.

I bought the Aphonopelma seemanni the 7th of March and so far it has been doing great in my care. I feed it regularly either Tenebrio molitor larvae or pupae.

Things I Wished More Developers Knew About Databases

A large majority of computer systems have some state and are likely to depend on a storage system. My knowledge on databases accumulated over time, but along the way our design mistakes caused data loss and outages. In data-heavy systems, databases are at the core of system design goals and tradeoffs. Even though it is impossible to ignore how databases work, the problems that application developers foresee and experience will often be just the tip of the iceberg. In this series, I’m sharing a few insights I specifically found useful for developers who are not specialized in this domain.

Source: Things I Wished More Developers Knew About Databases, an article by Jaana B. Dogan.

Masked Prey: good

In the early afternoon I finished Masked Prey, the 30th Prey novel by John Sandford. While not as good as the previous book; Neon Prey, which was excellent, it was still a good read. Recommended.

The iPad Magic Keyboard

Once I let go of my preconceptions, I fell in love. This took all of 15 minutes. I went from that “I don’t like the way this thing feels at all” first impression to “I can’t wait to start raving about how great this thing is” in 15 minutes. The iPad Magic Keyboard is to iPad-as-laptop accessories what AirPods were to earbuds: a game changer.

Source: The iPad Magic Keyboard, an article by John Gruber.

Partially hide data fields

On a web site, but maybe even an API, there might be cases when you would like to display only part of a value. For example you might want to display the last 4 digits of a credit card number. Or the first 4 letters of an e-mail address.

Source: Partially hide data fields, an article by Gabor Szabo.

Patterns for Managing Source Code Branches

Modern source-control systems provide powerful tools that make it easy to create branches in source code. But eventually these branches have to be merged back together, and many teams spend an inordinate amount of time coping with their tangled thicket of branches. There are several patterns that can allow teams to use branching effectively, concentrating around integrating the work of multiple developers and organizing the path to production releases. The over-arching theme is that branches should be integrated frequently and efforts focused on a healthy mainline that can be deployed into production with minimal effort.

Source: Patterns for Managing Source Code Branches, an article by Martin Fowler.

Effective Python Testing With Pytest

Testing your code brings a wide variety of benefits. It increases your confidence that the code behaves as you expect and ensures that changes to your code won’t cause regressions. Writing and maintaining tests is hard work, so you should leverage all the tools at your disposal to make it as painless as possible. pytest is one of the best tools you can use to boost your testing productivity.

Source: Effective Python Testing With Pytest, an article by Dane Hillard.

From chunking to parallelism: faster Pandas with Dask

When data doesn’t fit in memory, you can use chunking: loading and then processing it in chunks, so that only a subset of the data needs to be in memory at any given time. But while chunking saves memory, it doesn’t address the other problem with large amounts of data: computation can also become a bottleneck.

How can you speed processing up?

One approach is to utilize multiple CPUs: pretty much every computer these days has more than one CPU. If you have two CPUs, you can often run your code (almost) twice as fast; four CPUs and you might approach a 4× speedup, and so on.

Even better, the chunking technique that helps reduce memory can also enable parallelism. Let’s see why, and then learn how the Dask library can easily enable parallelism of your Pandas processing code.

Source: From chunking to parallelism: faster Pandas with Dask, an article by Itamar Turner-Trauring.