Plurrrr

a tumblelog
home

My Guide for Rubber Duck Debugging: A Better Process

Would you believe it if I told you that something called "rubber ducking" is actually one of the most insightful debugging techniques ever suggested? When you run into a programming snag you can't figure out, just find a rubber duck and start talking to it about your problems. Sold, right? Me neither.

I actually love rubber duck debugging, but not in the way it's usually explained. Turns out, it's hard for adults to take seriously the idea of talking to a literal rubber duck on their desk. And even if you guessed the duck is not really the point, you'd be surprised by how many engineers miss the point entirely. In this article, I'm going to explain what rubber ducking is, why it does actually work, and provide a step-by-step process for the way I do it that I think can change your debugging chops for good.

Source: My Guide for Rubber Duck Debugging: A Better Process (with No Rubber Ducks), an article by Joseph Pacheco.

Saving a Third of Our Memory by Re-ordering Go Struct Fields

In past projects at Qvault we had an application that typically ran with ~2GB in memory at any given time. By simply changing the order of some uint variables we managed to drop the memory usage to less than 1.4GB. The vast majority of this allocated memory is due to an enormous slice of stats structs.

Source: Saving a Third of Our Memory by Re-ordering Go Struct Fields, an article by Lane Wagner.

Pseudorandom numbers using Cellular Automata - Rule 30

There are lots of techniques to generate Pseudorandom numbers, namely: Blum Blum Shub algorithm, Middle-square method, Lagged Fibonacci generator, etc. Today we dive deep into Rule 30 that uses a controversial science called Cellular Automaton. This method passes many standard tests for randomness and was used in Mathematica for generating random integers.

Source: Pseudorandom numbers using Cellular Automata - Rule 30, an article by Arpit Bhayani.

Pysa: An open source static analysis tool

Pysa is a security-focused tool built on top of our type checker for Python, Pyre. It’s used to look at code and analyze how data flows through it. Analyzing data flows is useful because many security and privacy issues can be modeled as data flowing into a place it shouldn’t.

Source: Pysa: Open Source static analysis for Python code, an article by Graham Bleaney, and Sinan Cepel.

Mac keyboard shortcuts

By pressing certain key combinations, you can do things that normally need a mouse, trackpad, or other input device.

Source: Mac keyboard shortcuts

First Impressions of Rust

I've been wanting to write a big project in Rust for a while as a learning exercise, and actually started one in late 2018 (a FUSE server implementation). But then life happened and I got busy and never went anywhere with it. Due to certain world circumstances I'm currently spending a lot of time indoors so rust-fuse (docs) now exists and is good enough to write basic hello-world filesystems. I plan to polish it up a bit more with the goal of releasing a v1.0 that supports the same use cases as libfuse.

I took some notes along the way about things that struck me as especially good or bad. Overall I quite like Rust the language, have mixed feelings about the quality of ancillary tooling, and have strong objections to some decisions made by the packaging system (Cargo + crates.io).

Source: First Impressions of Rust, an article by John Millikin.

Post 500

For 500 days I have been blogging on Plurrrr non-stop, one post a day. Thank you for reading and following!

The JavaScript Promise Tutorial

This post is intended to be the ultimate JavaScript Promises tutorial: recipes and examples for everyday situations (or that’s the goal 😉). We cover all the necessary methods like then, catch, and finally. Also, we go over more complex situations like executing promises in parallel with Promise.all, timing out APIs with Promise.race, promise chaining and some best practices and gotchas.

Source: The JavaScript Promise Tutorial, an article by Adrian Mejia.

Debugging Python server memory leaks with the Fil profiler

Your server is running just fine, handling requests and sending responses. But then, ever so slowly, memory usage creeps up, and up, and up–until eventually your process runs out of memory and crashes. And then it restarts, and the leaking starts all over again.

In order to fix memory leaks, you need to figure out where that memory is being allocated. And that can be tricky, unless you use the right tools.

Let’s see how you can identify the exact lines of code that are leaking by using the Fil memory profiler.

Source: Debugging Python server memory leaks with the Fil profiler, an article by Itamar Turner-Trauring.

The new CSS property that boosts your rendering performance

The content-visibility property, launching in Chromium 85, might be one of the most impactful new CSS properties for improving page load performance. content-visibility enables the user agent to skip an element's rendering work, including layout and painting, until it is needed. Because rendering is skipped, if a large portion of your content is off-screen, leveraging the content-visibility property makes the initial user load much faster. It also allows for faster interactions with the on-screen content. Pretty neat.

Source: content-visibility: the new CSS property that boosts your rendering performance, an article by Una Kravets and Vladimir Levin.

Defunctionalization and Freyd’s Theorem

The main idea of functional programming is to treat functions like any other data types. In particular, we want to be able to pass functions as arguments to other functions, return them as values, and store them in data structures. But what kind of data type is a function?

Source: Defunctionalization and Freyd’s Theorem, an article by Bartosz Milewski.

Bayes Theorem: A Framework for Critical Thinking

This 9,000 word blog post is a complete introduction to Bayes Theorem and how to put it to practice. In short, Bayes Theorem is a framework for critical thinking. By the end of this post, you’ll be making better decisions, realise when you’re being unreasonable, and also understand why some people believe in UFOs.

Source: Bayes Theorem: A Framework for Critical Thinking, an article by Neil Kakkar.

What Are Python Wheels and Why Should You Care?

Python .whl files, or wheels, are a little-discussed part of Python, but they’ve been a boon to the installation process for Python packages. If you’ve installed a Python package using pip, then chances are that a wheel has made the installation faster and more efficient.

Wheels are a component of the Python ecosystem that helps to make package installs just work. They allow for faster installations and more stability in the package distribution process. In this tutorial, you’ll dive into what wheels are, what good they serve, and how they’ve gained traction and made Python even more of a joy to work with.

Source: What Are Python Wheels and Why Should You Care?, an article by Brad Solomon.

Unlearn rotation matrices as rotations

Rotation matrices just describe the unit vectors of a new coordinate system.

Source: Unlearn rotation matrices as rotations, an article by Markus Lindelöw.

How to read code: the next generation

Reading type signatures will become the part of basic computer literacy curriculum taught in elementary schools.

While they taught you how Microsoft spreadsheets operated kids in future will learn some lambda calculus instead.

Types will be the standard user interfacing element to access computer systems. It will replace the buttons and text boxes of the present day and ordinary people will use them every day.

This article tells what these "types" are and gives a taste of how to read type signatures. Then I explain why I think this is useful and conclude with an example of reading code with types. I assume that you understand a bit of basic algebra.

Source: How to read code: the next generation, an article by Henri Tuhola.

How Link-Begging Became the Most Annoying Search Engine Tactic

Businesses want to show up on the front page of a specific search term, and they’re willing to annoy you to get a backlink from you. Please never do this.

Source: How Link-Begging Became the Most Annoying Search Engine Tactic, an article by Ernie Smith.

The earliest domestic cat on the Silk Road

We present the earliest evidence for domestic cat (Felis catus L., 1758) from Kazakhstan, found as a well preserved skeleton with extensive osteological pathologies dating to 775–940 cal CE from the early medieval city of Dzhankent, Kazakhstan. This urban settlement was located on the intersection of the northern Silk Road route which linked the cities of Khorezm in the south to the trading settlements in the Volga region to the north and was known in the tenth century CE as the capital of the nomad Oghuz. The presence of this domestic cat, presented here as an osteobiography using a combination of zooarchaeological, genetic, and isotopic data, provides proxy evidence for a fundamental shift in the nature of human-animal relationships within a previously pastoral region. This illustrates the broader social, cultural, and economic changes occurring within the context of rapid urbanisation during the early medieval period along the Silk Road.

Source: The earliest domestic cat on the Silk Road, an article by A. F. Haruda, A. R. Ventresca Miller, J. L. A. Paijmans, A. Barlow, A. Tazhekeyev, S. Bilalov, Y. Hesse, M. Preick, T. King, R. Thomas, H. Härke & I. Arzhantseva

git log – the Good Parts

If you’re managing a complex git codebase with multiple developers, then you may well be using a tool like GitHub or BitBucket to delve into the history and figure out branch and merge issues.

These GUIs are great for providing a nice user interface for managing pull requests and simple histories and the like, but when the workflow SHTF there’s no substitute for using git log and its relatively little-known flags to really dig into the situation.

Source: git log – the Good Parts, an article by Ian Miell.

Time Traveling In Haskell: How It Works And How To Use It

I recently got to use a very curious Haskell technique in production: time traveling. I say this with the utmost seriousness. This technique worked like magic for the problem I was trying to solve, and so I thought I’d share what I learned. In addition to the technique and its workings, I will also explain how time traveling can be misused, yielding computations that never terminate.

Source: Time Traveling In Haskell: How It Works And How To Use It, an article by Danila Fedorin.

A Visual Tour of Backpropagation

At their core, neural networks are functions. They take some input, perform a series of computations, and produce an output. Though most networks operate in the realm of vectors and matrices, it can be a useful exercise to see them without the extra barrier of linear algebra. For this purposes of this explanation, we will only cover single variable functions, but the principles we will see can be extended into any number of dimensions.

Source: A Visual Tour of Backpropagation, an article by Jinay Jain.

Perl7 is a fork of values

And while everyone is wondering where perl7 is going, the other crucial question is where perl5 is going; will it stop where it is now (the current official plan), will there be a 5.34 (something I have repeated argued for because it makes no sense for the sunsetting release to have experimental features, and is lacking a perl5 executable out the box), will perl5 development continue as it did before? This is something that isn't talked about much and I'm not sure yet what will happen, but I am pretty sure that decision shouldn't be taken by the people who don't want to use it.

Source: Perl7 is a fork of values, an article by Leon Timmermans.

Exactly-Once Initialization in Asynchronous Python

A common situation in asyncio Python programs is asynchronous initialization. Some resource must be initialized exactly once before it can be used, but the initialization itself is asynchronous — such as an asyncpg database. Let’s talk about a couple of solutions.

Source: Exactly-Once Initialization in Asynchronous Python, an article by Chris Wellons.

Gripes With Go

You’ve read a lot of posts about the shortcomings of the Go programming language, so what’s one more.

  1. Lack of sum types
  2. Type assertions
  3. Date and Time
  4. Statements over Expressions
  5. Erroring out on unused variables
  6. Error handling

Source: Gripes With Go, an article by Akshay Oppiliappan.

The Case Against OOP is Wildly Overstated

You can’t rule the development world for decades without attracting some enemies. And object-oriented programming, which provides the conceptual underpinning for dozens of languages old and new, certainly has some enemies.

Maybe that’s why we’ve suffered through a never-ending series of hot takes about OOP. They’ve described it as a productivity-destroying disaster, a set of deceitful programming patterns, and a mediocre tool designed to help poor programmers hide their incompetence. OOP was even proclaimed dead (14 years ago, so take that one with a grain of salt).

What all these rants have in common is that they point out (rightfully) some of the pitfalls in modern software design and then conclude (wrongfully) that this indicates a terrible rot at the core of the programming world. Yes, object-oriented programming doesn’t look so great if you conflate it with sloppy design practices and fuzzy architectural thinking. But are these crimes really an unavoidable part of OOP? Or are they just one of the wrong paths we sometimes wander as programming neophytes, armed with too much confidence and too much curiosity?

Source: The Case Against OOP is Wildly Overstated, an article by Matthew MacDonald.

Aliasing in computer graphics

Most people who have come in contact with computer graphics know that aliasing commonly refers to jagged edges that occur when rendering triangles. In this article, we look at other manifestations of aliasing in 3D graphics, and attempt to theoretically unify them. We won't properly look at how to solve aliasing, only focusing on reasoning about the problem instead.

Source: Aliasing in computer graphics, an article by Apoorva Joshi.

Writing Robust Bash Shell Scripts

Many people hack together shell scripts quickly to do simple tasks, but these soon take on a life of their own. Unfortunately shell scripts are full of subtle effects which result in scripts failing in unusual ways. It’s possible to write scripts which minimise these problems. In this article, I explain several techniques for writing robust bash scripts.

Source: Writing Robust Bash Shell Scripts, an article by David Pashley.

Volucella zonaria

In the afternoon, when walking back to our house, I spotted what I believe to be a female Volucella zonaria; the hornet mimic hoverfly.

Side view of a Volucella zonaria female
Side view of a Volucella zonaria female.

The first of July my aunt contacted me on Messenger asking if I could identify an insect she had taken a photo of. I couldn't. But I used an app on my iPhone 5 (can't recall which one) which identified it as Volucella zonaria. Hence, why I believe the above insect to be a Volucella zonaria as well. And since males have less space between the eyes, I assume that this is a female.

The vocal red cat

On the way back to our house I encountered a very vocal red cat. It kept meowing at me, insisting to be petted which I did. It kept rolling on the sidewalk meowing and purring, requesting to be petted some more.

The vocal red cat rolling on the sidewalk
The vocal red cat rolling on the sidewalk.

Different approaches to HTTP routing in Go

There are many ways to do HTTP path routing in Go – for better or worse. There’s the standard library’s http.ServeMux, but it only supports basic prefix matching. There are many ways to do more advanced routing yourself, including Axel Wagner’s interesting ShiftPath technique. And then of course there are lots of third-party router libraries. In this article I’m going to do a comparison of several custom techniques and some off-the-shelf packages.

Source: Different approaches to HTTP routing in Go, an article by Ben Hoyt.

Referer and Referrer-Policy best practices

  • Unexpected cross-origin information leakage hinders web users' privacy. A protective referrer policy can help.
  • Consider setting a referrer policy of strict-origin-when-cross-origin. It retains much of the referrer's usefulness, while mitigating the risk of leaking data cross-origins.
  • Don't use referrers for Cross-Site Request Forgery (CSRF) protection. Use CSRF tokens instead, and other headers as an extra layer of security.

Source: Referer and Referrer-Policy best practices, an article by Maud Nalpas.

Caribena versicolor: first molt in my care

Just before 4pm I noticed that the Caribena versicolor I keep had molted for the first time in my care. In the early afternoon I had added water to the enclosures of each of the ten tarantulas I keep, mostly slings. And I guess the increase in humidity triggered the molting process in the little spider. Or maybe it was just ready.

Caribena versicolor after molting
Caribena versicolor after molting.

After I had taken two photos with my iPhone 5 with a LED ring light plus macro lens I noticed a small mealworm crawling around in the enclosure. I always crush the head of mealworms prior to feeding them to my spiders, but I guess I didn't do it right with this one.

As the Caribena versicolor shouldn't eat for at least a week after molting I removed the mealworm and tried to feed it to the Hapalopus sp. Colombia "large" I keep. This spider also molted recently; I found an exuviae with it the 21st of this month. But it was not interested in eating the small mealworm.

Hapalopus sp. Colombia "large"
Hapalopus sp. Colombia "large".

In the end I fed the small mealworm to the Chromatopelma cyaneopubescens, which detected the wriggling prey item and picked it up to eat it.

Random Strings and Integers That Actually Aren’t

Recently the topic of generating random-looking coupon codes and other strings came up on internal chat. My go-to for something like that is always this solution based on Feistel networks, which I didn’t think was terribly obscure. But I was surprised when nobody else seemed to recognize it, so maybe it is.

Source: Random Strings and Integers That Actually Aren’t, an article by Josh Williams.

Related: Avoiding Confusion With Alphanumeric Characters, an article by Matthew Grissinger.

Sudoku Solver in Python

This post describes a Sudoku solver in Python. Even the most challenging Sudoku puzzles can be quickly and efficiently solved with depth first search and constraint propagation.

Source: Sudoku Solver in Python, an article by Lior Sinai.

Making beautifulsoup Parsing 10 times faster

I was making a quick project that require to scrape some information from a website. BeautifulSoup is the library of choice.

Download takes 1-2 seconds per page, with high network latency because the server is in US and I am in London.

After writing the downloader, it takes more like 4-5 seconds per page, which is noticeably slow. How come? Could it be that large HTML is slow to parse?

Source: Making beautifulsoup Parsing 10 times faster.

Pterinochilus murinus having dinner

In the evening I noticed that the Pterinochilus murinus Red Color Form (RFC) I keep was out in the open, eating a mealworm that I had given to it earlier. Normally it eats inside its burrow, but now it was outside!

Pterinochilus murinus eating near its burrow entry
Pterinochilus murinus eating near its burrow entry.

I carefully moved the enclosure; a plastic container, and moved the clips away from the lid. Next, I got my iPhone 5 ready with a LED ring light and a macro lens.

Pterinochilus murinus eating on top of its burrow
Pterinochilus murinus eating on top of its burrow.

While I carefully took several photos the tarantula moved around a bit while holding its prey.

The spider has grown and changed a lot since it arrived at our house. As far as I know it has molted once while in my care.

Mastering sed: part 1

In this tutorial, we will go over the basics of using sed, an ancient and powerful text manipulator. This tutorial assumes basic experience with bash.

We will go over real sed examples that you can copy paste into your own terminal which explore various features and fundamental ideas of sed. At the end, we will have a summary of the fundamentals.

Source: Mastering sed: part 1, an article by Tyler Adams.

My Favorite JavaScript Tips and Tricks

Most of the programming languages are open enough to allow programmers doing things multiple ways for the similar outcome. JavaScript is no way different. With JavaScript, we often find multiple ways of doing things for a similar outcome, and that's confusing at times.

Some of the usages are better than the other alternatives and thus, these are my favorites. I am going to list them here in this article. I am sure, you will find many of these in your list too.

Source: My Favorite JavaScript Tips and Tricks, an article by Tapas Adhikary.

Highlights from Git 2.28

The open source Git project just released Git 2.28 with features and bug fixes from over 58 contributors, 13 of them new. We last caught up with you on the latest in Git back when 2.26 was released. Here’s a look at some of the most interesting features and changes introduced since then.

Source: Highlights from Git 2.28, an article by Taylor Blau.

A Complete Guide to Data Attributes

you can make up your own attributes. You just need to prefix them with data-* and then you’re free to do what you please!

Source: A Complete Guide to Data Attributes, an article by Chris Coyier.

Every self-help book ever, boiled down to 11 simple rules

Why not condense the repeated lessons of an entire genre into one article? That's what I've attempted here, after reading dozens of history's biggest bestsellers so you don't have to. Here is the essence of the advice I've seen delivered again and again.

The complete list of rules is:

  1. Take one small step.
  2. Change your mental maps.
  3. Struggle is good. Scary is good.
  4. Instant judgment is bad.
  5. Remember the end of your life.
  6. Be playful.
  7. Be useful to others.
  8. Perfectionism = procrastination.
  9. Sleep, exercise, eat, chill out. Repeat.
  10. Write it all down.
  11. You can't get it all from reading.

Source: The best self-help book advice distilled to 11 simple rules, an article by Chris Taylor.

The Strange Numbers That Birthed Modern Algebra

The 19th-century discovery of numbers called “quaternions” gave mathematicians a way to describe rotations in space, forever changing physics and math.

Source: The Strange Numbers That Birthed Modern Algebra, an article by Charlie Wood.

Cleaner code with functional programming

Functional programming is a style of programming and modern languages support this style to a greater or lesser extent. In this article I want to explain how programming in a functional style provides you with powerful abstractions to make your code cleaner. I will illustrate this with examples in Raku and Python, which as we will see are both excellent languages for functional programming.

Source: Cleaner code with functional programming, an article by Wim Vanderbauwhede.

Some CSS comics

Hello! I’ve been writing some comics about CSS this past week, and I thought as an experiment I’d post them to my blog instead of only putting them on Twitter.

I’m going to ramble about CSS at the beginning a bit but you can skip to the end if you just want to read the comics :)

Source: Some CSS comics, an article by Julia Evans.

10 design principles for delightful CLIs

With thousands of apps created with the CLI so far and glowing feedback from Forge developers, here are our 10 principles for designing successful CLIs. If you’re building a CLI to support your service, resource, or platform, we hope that you might use these principles, too!

Source: 10 design principles for delightful CLIs, an article by Michael Belton and Natalie Johnson.

How to write cleaner code with JavaScript

Destructuring is one of my favorite tools in JavaScript, in simple terms, destructuring allows you to break down a complex structure (like an array or an object) into simpler parts, though there’s a bit more to it than that.

Source: How to write cleaner code with JavaScript, an article by Juan Cruz Martinez.