a tumblelog
Mon 29 Jun 2020

Using Bash traps in your scripts

It's easy to detect when a shell script starts, but it's not always easy to know when it stops. A script might end normally, just as its author intends it to end, but it could also fail due to an unexpected fatal error. Sometimes it's beneficial to preserve the remnants of whatever was in progress when a script failed, and other times it's inconvenient. Either way, detecting the end of a script and reacting to it in some pre-calculated manner is why the Bash trap directive exists.

Source: Using Bash traps in your scripts, an article by Seth Kenlon.

How to add support for dark mode on a website

In recent years, dark mode has grown in popularity as more and more devices and browsers are adding support for it.

Those reasons make it a great little feature that we can add on our websites to improve the experience of the users who prefer to use dark mode.

Let’s see how we can support this feature in 3 steps!

Source: How to add support for dark mode on a website, an article by Ioannis Diamantidis.

Python's reduce(): From Functional to Pythonic Style

Python’s reduce() is a function that implements a mathematical technique called folding or reduction. reduce() is useful when you need to apply a function to an iterable and reduce it to a single cumulative value. Python’s reduce() is popular among developers with a functional programming background, but Python has more to offer.

In this tutorial, you’ll cover how reduce() works and how to use it effectively. You’ll also cover some alternative Python tools that can be more Pythonic, readable, and efficient than reduce().

Source: Python's reduce(): From Functional to Pythonic Style, an article by Leodanis Pozo Ramos.

Machine Learning From Scratch

A quick start “from scratch” on 3 basic machine learning models — Linear regression, Logistic regression, K-means clustering, and Gradient Descent, the optimisation algorithm acting as a driving force behind them.

The purpose of this article is for coders to understand the inner workings of basic machine learning algorithms. To make the best use of the article, it is recommended to follow the code on your own development environment to understand the process.

Source: Machine Learning From Scratch: Classification, Regression, Clustering and Gradient Descent, an article by Jet New.