How to Design and Implement a Plugin Architecture in Python

We tend to think that plugin-based architectures are hard to develop. And that is certainly true for many advanced plugin-based architectures such as those for browsers. But sometimes we may be looking for a simple yet powerful plugin-based architecture. If that’s your case, then read on. I’ll show you how to design and implement one in Python. I’ll explain how I designed utt’s plugin system and how you can apply the same pattern to your application.

Main function in Node.js

Unlike most other programming languages or runtime environments, Node.js doesn’t have a built-in special main function to designate the entry point of a program. But there is an easy way to achieve this in Node.js, which we will show in this article. The pattern is to check if the current module is the main module: require.main === module. If this is true, the current file has been run directly - as opposed to have been imported by another file - and in this case we can call the main function.

Ubuntu 19.10 on Lenovo ThinkPad X1 Carbon 7th Gen

The audio, microphone and wifi don’t work out of the box with Ubuntu 19.10 on a Lenovo ThinkPad X1 Carbon 7th Gen laptop. Here are the steps I made to fix them. Update: I upgraded to Ubuntu 20.04 and now everything works with the default settings. I’m on kernel 5.4.0-26-generic and reverted my changes to /etc/modprobe.d/blacklist.conf and /etc/pulse/ (steps 3 and 4 below). Note 1: Even if I tried to make as little customization as possible to make the upgrade easy to Ubuntu 20.

Decoding CAPTCHAs

There are two types of CAPTCHAs. Those that are solved by bots and those that will eventually be solved by bots. It’s hard to tell if a CAPTCHA is secured or not. But, if the text-based CAPTCHA on your website can be decoded with two lines of code (as shown in this article), it’s time to upgrade it. Approach Two-line approach: Preprocess the image with convert (ImageMagick). Use Tesseract - an OCR engine - to extract the text from the image.

Understanding Python Variables

In this article, you will learn the behavior of variables in Python and, in particular, the semantics of the assignment operator (=). Variables or names? Just before we start, I would like to tell you that what you call a variable in other programming languages is called a name in Python. Of course not everyone agrees with that, as you can see in this thread. But the official documentation and almost all articles written on the execution model of Python use the word name, so I’ll use it here as well.

How Prototype Works in JavaScript

A prototype in JavaScript is an object with a special role: it’s the parent of another object. And the role of a parent is to provide properties to its children. Let’s see how a prototype is linked to another object. Internal Property [[Prototype]] Every object has an internal property named [[Prototype]]. The value of [[Prototype]] is either a reference to another object or null. Example: Observations: a has no prototype.

Choosing the Right Data Structures

About a year ago, I was using NetworkX (a Python package for studying graphs) for one of my projects. While I was working on it, I found that the topological sort implementation in NetworkX was very slow on large-scale instances. So I decided to take a look at it, hoping I can figure out what’s wrong and fix it. In the end, I sped up considerably the implementation. Here is how I did it.

Function Composition in Python

While I don’t consider myself a functional programming expert, all those hours spent in Haskell, Lisp and Scheme definitively changed my way of programming. So, after seeing a lot of unnecessarily complex implementations of function composition in Python on the Web, I decided to write this article to present a simple yet powerful solution that covers all use cases. If you are familiar with function composition, you may want to go to the solution.