week 30, 2020

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.

San Francisco

In a reply on Hacker News user JustARandomGuy mentioned that I had misspelled San Francisco in the CSS file for this blog; I had written it as San Fransisco 🙄.

Part of the CSS file with San Francisco misspelled
Part of the CSS file with San Francisco misspelled.

A quick find-grep from within Emacs showed that I had made the same mistake in all Sass source files, files ending with the scss extension, for the tumblelog project. This project is the SSG (static site generator) that generates this blog.

I also noticed that those files had a copyright 2019, to which I added 2020. And all those SCSS files still had the old "same terms as Perl itself" license, which I removed as the entire project is now available under the MIT license.

After those fixes I bumped the version number of the project to 4.0.5 and pushed the new version to GitHub.

Sexing Tarantulas Using Molts

In the afternoon, after I had made some fixes to tumblelog, I finally wrote a short guide on how to sex a tarantula using its cast-off exoskeleton.

The molt of a juvenile female Brachypelma smithi
The molt of a juvenile female Brachypelma smithi.

I used the molt of a Brachypelma smithi that molted the 25th of June, 2020. The exuviae used in the tutorial is show in the above photo. To get an impression of the size of the molt, each square on the paper is 5mm by 5mm and the black line near the bottom is 25mm or about 1 inch.

Explaining RNNs without neural networks

Vanilla recurrent neural networks (RNNs) form the basis of more sophisticated models, such as LSTMs and GRUs. There are lots of great articles, books, and videos that describe the functionality, mathematics, and behavior of RNNs so, don't worry, this isn't yet another rehash. (See below for a list of resources.) My goal is to present an explanation that avoids the neural network metaphor, stripping it down to its essence—a series of vector transformations that result in embeddings for variable-length input vectors.

Source: Explaining RNNs without neural networks, an article by Terence Parr.

Setting Up Haskell Development Environment: The Basics

This post differs from most posts around setting up a Haskell development environment in the sense that it does not directly jump into Cabal or Stack. Instead, it first provides some background information that makes it possible to understand the basics of the development environment in Haskell, the different moving parts, and how those come together in turning Haskell source code into an executable which can then be run.

Source: Setting Up Haskell Development Environment: The Basics.

Docker in 10 minutes

I've been exposed to docker on and off and every time I see it, I seem to need a refresher. In this article we will go through everything you need to know about Docker in order to either jump into an existing project or get started with it.

Source: Blog | Docker in 10 minutes, an article by Victor Parmar.

The Case For CSS-in-JS

CSS-in-JS is the practice of utilising the power of JavaScript to dynamically generate and better organise your application’s CSS. The concept has gained traction over the years due to the popularity of UI frameworks / libraries such as React, Angular and Vue. This post attempts to convince you that CSS-in-JS is an approach worth investigating in the struggle to keep your codebase’s CSS in check.

Source: The Case For CSS-in-JS, an article by Stephen Fairbanks.

Good Logging

To check if a program is doing what it should, you can inspect the output from a given input. But as the system grows, you also need logging to help you understand what is happening. Good log messages are crucial when troubleshooting problems. However, many developers don’t log enough information in the right places.

Source: Good Logging, an article by Henrik Warne.

tumblelog is now available under the MIT license

In order to add tumblelog, the SSG (static site generator) I wrote to create this blog, to StaticGen; a list of static site generators, I had to add a single clear OSS license.

For version 4.0.3 of tumblelog and earlier the license for the Perl version was:

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

and for the Python version:

This program is free software; you can redistribute it and/or modify it under the same terms as Python itself.

In the afternoon I decided to bring all files belonging to the tumblelog project under the MIT license, added a LICENSE file to the project and bumped the version to 4.0.4 😜.

I also added a project description for both the Perl and Python version of tumblelog to a fork of staticgen and did a pull request. If I did all correctly, hopefully in the near future tumblelog will appear on the list.

The tumblelog project is available via GitHub. Feedback is welcome.

Fun With Simulated Typestate in Python 3.8

Typestate is an augmentation to a type system which lets us model objects which have defined states, with certain operations only available in given states, and where operations may alter the state of the object in a defined way. “True” typestate support is quite uncommon in programming languages, but we can use the techniques we’ll illustrate shortly to simulate typestate by turning each state into a distinct type, avoiding duplication by making use of polymorphic (“generic”) types.

Source: Fun With Simulated Typestate in Python 3.8, an article by Derrick W. Turk.

Setting up a Linux Workstation for Software Development

Still, as with any other operating system, optimizing a Linux workstation for software development requires some configuration. In this post, I will present tools and concepts that I think are very helpful, but overlooked by many. I will try to show only things that are not specific to my workflows, but rather useful for almost any software engineer, DevOps specialist, or just regular productivity enthusiast. Naturally, many of the configuration options and tools covered in this post are subjective. Nevertheless, I am confident that my suggestions are a good place to start. They have served me well over the years and I continually try to optimize my setup. Hence, I very much appreciate any improvement you might suggest.

Source: Setting up a Linux Workstation for Software Development, an article by Thomas Kainrad.

Brick Block and Planet

Near the end of the afternoon I played a bit with Brick Block and Planet. Both are made with Unity personal edition by Oskar Stålberg. The former demo has been turned into a full-blown game available on Steam: Townscaper.

Brick Block demo by Oskar Stålberg
Brick Block demo by Oskar Stålberg (house builder).
Planet demo by Oskar Stålberg
Planet demo by Oskar Stålberg (terraformer).

For more information see Oskar's talk at the Breda University of Applied Sciences Everything Procedural Conference 2018: Wave Function Collapse in Bad North (EPC2018).

Scrape HTML Tables Without Leaving Pandas

Webscraping is often a pain. Researching, finding, and installing the libraries you need can be time consuming. Finding the content you need in the HTML can take time. Getting everything to work can be finicky.🙁 In this article, I'll show you how to use the Python pandas library to scrape HTML tables with single line of code! It doesn't work in all cases, but when you have HTML tables on a website it can make your life much easier.

Source: Scrape HTML Tables Without Leaving Pandas, an article by Jeff Hale.

Make your feed discoverable

Time and time again I come across fantastic blogs that I want to subscribe to but can’t find a feed for. First I try putting the site into my RSS reader (Miniflux is my tool of choice) but it often can’t find anything. Then I search around the site for the little RSS icon or a link but come up blank. As a last resort I start sticking common paths on the domain and with some luck I might finally find a feed on /feed.xml or /rss/. RSS feeds aren’t dead, there isn’t a reason for it to be this hard.

Source: Make your feed discoverable, an article by James Loh.

Red Country

They burned her home.

They stole her brother and sister.

But vengeance is following.

Shy South hoped to bury her bloody past and ride away smiling, but she'll have to sharpen up some bad old ways to get her family back, and she's not a woman to flinch from what needs doing. She sets off in pursuit with only a pair of oxen and her cowardly old step father Lamb for company. But it turns out Lamb's buried a bloody past of his own. And out in the lawless Far Country the past never stays buried.

In the evening I started in Red Country, book 3 in the World of the First Law series by Joe Abercrombie.