a tumblelog

Iterated Local Search From Scratch in Python

Iterated Local Search is a stochastic global optimization algorithm.

It involves the repeated using of a local search algorithm to modified versions of a good solution found previously. In this way, it is like a clever version of the stochastic hill climbing with random restarts algorithm.

Source: Iterated Local Search From Scratch in Python, an article by Shantun Parmar.

Simple Python Profiling with the @profile Decorator

A way of analyzing the performance of any given function or program is to use profilers during its execution. Profilers can help us understand timing, memory usage, and other pertinent information about code. The key to using profilers is to determine which portion of the code is slow or computationally expensive and assist the process of catching errors for optimization.

Source: Simple Python Profiling with the @profile Decorator, an article by Ryan Kuang.

“So what exactly is curl?”

You know that question you can get asked casually by a person you’ve never met before or even by someone you’ve known for a long time but haven’t really talked to about this before. Perhaps at a social event. Perhaps at a family dinner.

So what do you do?

Source: “So what exactly is curl?”, an article by Daniel Stenberg.

Git from the Bottom Up

Welcome to the world of Git. I hope this document will help to advance your understanding of this powerful content tracking system, and reveal a bit of the simplicity underlying it — however dizzying its array of options may seem from the outside.

Source: Git from the Bottom Up, an article by John Wiegley.

Continued Fractions in Haskell

In this article, we’ll develop a Haskell library for continued fractions. Continued fractions are a different representation for real numbers, besides the fractions and decimals we all learned about in grade school. In the process, we’ll build correct and performant software using ideas that are central to the Haskell programming language community: equational reasoning, property testing, and term rewriting.

Source: Continued Fractions: Haskell, Equational Reasoning, Property Testing, and Rewrite Rules in Action, an article by Chris Smith.

Building Large Scale Systems and Products with Python

At the beginning of Soroco’s journey, we had to answer a question that many engineering organizations have had to answer before.

What programming language were we going to use when building and scaling our products?

Source: Building Large Scale Systems and Products with Python, an article by George Nychis.

Animate extruded text

or better or worse, extruded text was a staple of the mid-90s desktop publishing design landscape. It was rare for a party invitation or gaming fanzine not to be blessed by this 3D text effect on its way out the printer.

As design was increasingly destined for screen rather than page, extrusion fell out of favour. But recently, I've noticed a quiet revival.

Source: Animate extruded text, an article by Matt Perry.

Modern CSS Upgrades To Improve Accessibility

Accessibility is a critical skill for developers doing work at any point in the stack. For front-end tasks, modern CSS provides capabilities we can leverage to make layouts more accessibly inclusive for users of all abilities across any device.

Source: Modern CSS Upgrades To Improve Accessibility, an article by Stephanie Eckles

Basic Music Theory in ~200 Lines of Python

I’m a self-taught guitarist of many years, and like a lot of self-taught musicians, am woefully inept at (Western) music theory.

So naturally, I decided to write some code.

This article explains the very basics of Western music theory in around 200 lines of Python.

Source: Basic Music Theory in ~200 Lines of Python, an article by Manohar Vanga.

Internet Search Tips

Over time, I developed a certain google-fu and expertise in finding references, papers, and books online. Some of these tricks are not well-known, like checking the Internet Archive (IA) for books.

Source: Internet Search Tips.

My current HTML boilerplate

Usually when I start a new project, I either copy the HTML structure of the last site I built or I head over to HTML5 Boilerplate and copy their boilerplate. Recently I didn’t start a new project, but I had to document the structure we use at work for the sites we build. So, simply copying and pasting wasn’t an option, I had to understand the choices that have been made. Since I spent quite some time researching and putting the structure together, I decided to share it with you.

Source: My current HTML boilerplate, an article by Manuel Matuzović.

Building a 6kB Containerized HTTP Server!

I set out to build the smallest container image that I could that was still able to do something useful. By taking advantage of multistage builds, the scratch base image, and a tiny assembly based http server, I was able to get it down to 6.32kB!

Source: Tiny Container Challenge: Building a 6kB Containerized HTTP Server!, an article by Sid Palas.


In the afternoon my aunt messaged me that firebugs, Pyrrhocoris apterus, could be found close to her house. Later, Esme and I walked to her house and I took a photo of the colorfull insects.

Firebugs, Pyrrhocoris apterus
Firebugs, Pyrrhocoris apterus.

Onboarding with an M1

This is my first week at Authzed as a software engineer and I’ve been provided with a new M1-based MacBook Pro as my primary development machine. Apple’s new M1 chip has been receiving high praise for being quiet, battery efficient, and performant, so naturally I was excited to use my new laptop. Turns out, I wasn’t the only one excited to start using M1 MacBook Pros…

Source: Onboarding with an M1, an article by Sam Kim.

Content-aware image resizing in JavaScript

There are many great articles written about the Seam Carving algorithm already, but I couldn't resist the temptation to explore this elegant, powerful, and yet simple algorithm on my own, and to write about my personal experience with it. Another point that drew my attention (as a creator of javascript-algorithms repo) was the fact that Dynamic Programming (DP) approach might be smoothly applied to solve it. And, if you're like me and still on your "learning algorithms" journey, this algorithmic solution may enrich your personal DP arsenal.

So, with this article I want to do three things:

  • Provide you with an interactive content-aware resizer so that you could play around with resizing your own images
  • Explain the idea behind the Seam Carving algorithm
  • Explain the dynamic programming approach to implement the algorithm (we'll be using TypeScript for it)

Source: Content-aware image resizing in JavaScript, an article by Oleksii Trekhleb.

Opting your Website out of Google's FLoC Network

Google recently announced the rollout of their Federated Learning of Cohorts (FLoC), a new advertising-surveillance initiative that seeks to replace third-party cookies with a new user profiling technique that garners data generated by the browser itself.

The EFF has written an overview of FLoC and it’s threats and has also developed a useful tool to test if a user’s browser is being used for data collection and fingerprinting.

Plausible Analytics has also chimed in with an article explaining FLoC as in relation to users and developers — which was the inspiration for this short guide.

Source: Opting your Website out of Google's FLoC Network, an article by Paramdeo Singh.

A zero-overhead linked list in Rust

Let’s implement an immutable, singly-linked list. Singly-linked means that each node contains a reference to the next node, but not vice versa. To make this data structure really performant, let’s use plain references instead of heap-allocated types. This would be dangerous in memory-unsafe languages like C, because it could easily cause vulnerabilities because of dangling pointers, but Rust’s lifetimes protect us from this. We’ll see what this means in a moment.

Source: A zero-overhead linked list in Rust, an article by Ludwig Stecher.

How I get work done with Emacs and org-mode

I've been a freelance developer for 12 years, and Emacs has been at the center of my working environment for 10 of those. I use it for a lot of things - including writing this post - but today I'm concentrating on my workflow.

Here's how I use Emacs and org-mode during a regular day.

Source: How I get work done with Emacs and org-mode, an article by Phil Newton.

Org-Mode Is One of the Most Reasonable Markup Languages to Use

Disclaimer: this is a very nerdy blog entry. It is about lightweight markup languages and why I think that Org mode is the best lightweight markup language for many use-cases. And with lightweight markup language, I do mean the syntax, the way you express headings, lists, font variations such as bold face or italic, and such things.

Source: Org-Mode Is One of the Most Reasonable Markup Languages to Use for Text an article by Karl Voit.


You might have heard people say that functional programming is more academic, and real engineering is done in imperative style. I’m going to show you that real engineering is functional, and I’m going to illustrate it using a computer game that is designed by engineers for engineers. It’s a simulation game called Factorio, in which you are given resources that you have to explore, build factories that process them, create more and more complex systems, until you are finally able to launch a spaceship that may take you away from an inhospitable planet. If this is not engineering at its purest then I don’t know what is. And yet almost all you do when playing this game has its functional programming counterparts and it can be used to teach basic concepts of not only programming but also, to some extent, category theory. So, without further ado, let’s jump in.

Source: Functorio, an article by Bartosz Milewski.

Say Hello To CSS Container Queries

I haven’t been more excited for a CSS feature like I’m now in the past six years I spent as a front-end developer. The prototype of container queries is now available behind a flag in Chrome Canary. Thanks to efforts from smart people like Miriam Suzanne and other folks.

I remember seeing a lot of jokes about the support for CSS container queries, but they are finally there. In this article, I will walk you through why we need container queries, how they will make your life easier, and most importantly, you will achieve more powerful components and layouts.

Source: Say Hello To CSS Container Queries, an article by Ahmad Shadeed.

Debugging random slow writes in PostgreSQL

n this post I’ll showcase a real-life example of debugging a seemingly weird database performance degradation. While I obviously intend to share the solution and what to avoid, I’d also like to take you through the journey and show you some tools & processes that can help you dig into SQL performance.

Source: Debugging random slow writes in PostgreSQL, an article by Sergios Aftsidis.

How Python dictionaries work

The goal of this post is to learn how CPython implements hash tables. But understanding all the aspects of hash table design can be hard, and CPython's implementation is especially sophisticated, so we'll approach this topic gradually. In the first part of this post, we'll design a simple fully-functional hash table, discuss its capabilities and limitations and outline a general approach to design a hash table that works well in practice. In the second part, we'll focus on the specifics of CPython's implementation and finally see how Python dictionaries work behind the scenes.

Source: Python behind the scenes #10: how Python dictionaries work, an article by Victor Skvortsov.

Rust shenanigans: return type polymorphism

In this article, I will describe Rust return type polymorphism (a.k.a. generic returns), a feature that I recently discovered and that I have been pretty intrigued about.

Source: Rust shenanigans: return type polymorphism, an article by Luciano Mammino.

Rust in Production: MeiliSearch

In this interview, I talk with Thomas Payet, the co-founder and COO of MeiliSearch. MeiliSearch is an open-source search engine that is among the top 20 most starred Rust projects on GitHub at the time of writing. We talk about MeiliSearch and how Rust and its ecosystem have helped them create it.

Read further to learn about their experience with Rust and discover tips for starting your own open-source project.

Source: Rust in Production: MeiliSearch, an article by Gints Dreimanis.

The k-Nearest Neighbors (kNN) Algorithm in Python

In this tutorial, you’ll get a thorough introduction to the k-Nearest Neighbors (kNN) algorithm in Python. The kNN algorithm is one of the most famous machine learning algorithms and an absolute must-have in your machine learning toolbox. Python is the go-to programming language for machine learning, so what better way to discover kNN than with Python’s famous packages NumPy and scikit-learn!

Source: The k-Nearest Neighbors (kNN) Algorithm in Python, an article by Joos Korstanje.

Build a Raspberry Pi Linux System the Hard Way

The instructions below will explain how to build a Linux environment for a Raspberry Pi 3B from scratch, focusing on extreme minimalism. I will build most components from source code and use BusyBox as the only user application on the target. The focus is on minimalism for the sake of learning. Optimizations like network boot, secondary bootloaders, compressed filesystems, etc.. will not be covered.

Source: Build a Raspberry Pi Linux System the Hard Way, an article by Rick Carlino.

The Beauty of Bresenham's Algorithm

This page introduces a compact and efficient implementation of Bresenham's algorithm to plot lines, circles, ellipses and Bézier curves.

Source: The Beauty of Bresenham's Algorithm, an article by Alois Zingl.

Use console.log() like a pro

Using console.log() for JavaScript debugging is the most common practice among developers. But, there is more…

The console object provides access to the browser’s debugging console. The specifics of how it works vary from browser to browser, but there is a de facto set of features that are typically provided.

Source: Use console.log() like a pro, an article by Marko Denic.

Using the Switch(true) Pattern in JavaScript

The fundamental principle of the switch true pattern is that you can match against expressions as well as values. An expression in a case will be evaluated before matching. If the expression in your case evaluates to true - it will be matched.

Source: Using the Switch(true) Pattern in JavaScript, an article by Seán Barry.

Bloom filters

A Bloom filter is a probabilistic data structure present in many common applications. Its purpose is answering the question: "is this item in the set?" very fast and not using a lot of space. The answers can be NO, or MAYBE YES.

Source: Bloom filters an article by Ricardo Ander-Egg Aguilar.

Using PyTorch + NumPy? You're making a mistake.

Bugs in ML code are notoriously hard to fix - they don’t cause compile errors but silently regress accuracy. Once you have endured the pain and fixed one of these, the lesson is forever etched into your brain, right? Wrong. Recently, an old foe made a comeback - a familiar bug bit me again! As before, the performance improved significantly after fixing it.

The bug was subtle and easy to make. How many others has it done damage to? Curious, I downloaded over a hundred thousand repositories from GitHub that import PyTorch, and analysed their source code. I kept projects that define a custom dataset, use NumPy’s random number generator with multi-process data loading, and are more-or-less straightforward to analyse using abstract syntax trees. Out of these, over 95% of the repositories are plagued by this problem. It’s inside PyTorch’s official tutorial, OpenAI’s code, and NVIDIA’s projects. Even Karpathy admitted falling prey to it.

Source: Using PyTorch + NumPy? You're making a mistake, an article by Tanel Pärnamaa.

Rust async is colored, and that’s not a big deal

In this article I will show that Rust async functions are colored, by both the original definition and in practice. This is not meant as an criticism of Rust async, though – I don’t see function colors as an insurmountable issue, but as a reflection of the fundamental difference of async and sync models of the world. Languages that hide that difference do so by introducing compromises that might not be acceptable in a systems language like Rust or C++ – for example, by entirely forbidding the use of system threads, or by complicating the invocation of foreign or OS-level blocking calls. Colored functions are also present in at least C#, Python, Kotlin, and C++, so they’re not a quirk of JavaScript and Rust. And additional features of Rust async do make it easier to connect async code with traditional blocking code, something that is just not possible in JavaScript.

Source: Rust async is colored, and that’s not a big deal.

Best practices for writing SQL queries

This article covers some best practices for writing SQL queries for data analysts and data scientists. Most of our discussion will concern SQL in general, but we’ll include some notes on features specific to Metabase that make writing SQL a breeze.

Source: Best practices for writing SQL queries.

"this" Is Weird: Understanding JavaScript "this" Keyword

The this keyword is a fundamental concept in JavaScript. However its behavior may appear very strange, especially if you are familiar with similar constructs in other languages, for example this in Java, or self in Python.

Source: "this" Is Weird: Understanding JavaScript "this" Keyword, an article by Linton Ye.

Nix is the ultimate DevOps toolkit

At Channable we use Nix to build and deploy our services and to manage our development environments. This was not always the case: in the past we used a combination of ecosystem-specific tools and custom scripts to glue them together. Consolidating everything with Nix has helped us standardize development and deployment workflows, eliminate “works on my machine”-problems, and avoid unnecessary rebuilds. In this post we want to share what problems we encountered before adopting Nix, how Nix solves those, and how we gradually introduced Nix into our workflows.

Source: Nix is the ultimate DevOps toolkit, an article by Ruud van Asseldonk, Reinier Maas, Falco Peijnenburg, Fabian Thorand, and Robert Kreuzer.

Why Do Long Options Start with Two Dashes?

Around 1990, Richard Stallman (RMS) and I were writing the GNU C library getopt() and he wanted to extend it to support long (multi-character) option names for user-friendliness.

Source: Why Do Long Options Start with Two Dashes?

3 reasons I use the Git cherry-pick command

Here is an example to help you understand the importance of cherry-picking. Suppose you have made several commits in a branch, but you realize it's the wrong branch! What do you do now? Either you repeat all your changes in the correct branch and make a fresh commit, or you merge the branch into the correct branch. Wait, the former is too tedious, and you may not want to do the latter. So, is there a way? Yes, Git's got you covered. Here is where cherry-picking comes into play. As the term suggests, you can use it to hand-pick a commit from one branch and transfer it into another branch.

Source: 3 reasons I use the Git cherry-pick command, an article by Manaswini Das.