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.