week 52, 2022

PostgreSQL and Software Development

As much as we all enjoy writing SQL and “doing everything in Postgres,” we are very well aware that databases do not live in a vacuum and were not invented for our pleasure and enjoyment. We may come up with new extensions and innovative indexes; we may improve the query planner and speed up backups, but if application developers don’t use these features, nobody will appreciate our efforts.

Source: PostgreSQL and Software Development.

Binary search is a workhorse of competitive programming. There are occasional easy problems where binary search is the solution in and of itself; more often, it’s used as a primitive building block of more complex algorithms. It is often presented as a way to find the index of something in a sorted array in O(lg n) time, and many languages have such a thing in their standard library (for example, see Arrays.binarySearch in Java, the bisect library in Python, or the binary_search function in C++). However, the idea of binary search is more general than searching in a sorted array; we’re doing binary search any time we repeatedly halve a search interval. For example, we can use it to find the smallest or largest number with a given property, or to find an optimal, “just right” measurement that is neither too small nor too big.

Source: Competitive programming in Haskell: better binary search, an article by Brent A. Yorgey.

Learning Rust in 2023: A Call For Discussion

Rust has a steep learning curve.

Once you're fully immersed in it, as with any skill, it becomes very difficult to properly remember what exactly made Rust difficult to learn. In a general sense, it could be the fact that it exposes the average programmer to some new features, most of them not present or only just beginning to show up in mainstream languages, and some that are close to unique.

Source: Learning Rust in 2023: A Call For Discussion, an article by Eshan Singh.

Emacs: Macro me some SF Symbols

For inserting SF Symbols in SwiftUI, I typically rely on Apple's SF Symbols app to browse the symbols's catalog. Once I find a symbol I'm happy with, I copy its name and paste it into my Swift source. This works fairly well.

With Christian Tietze recently posting how he rendered SF Symbols in Emacs, I figured there may be a way to shift the above workflow to rely on Emacs completion instead. While I initially went down a rabbit hole to programmatically extract SF symbols (via something like SFSafeSymbols), I took a step back to rethink the strategy.

Source: Emacs: Macro me some SF Symbols, an article by Álvaro Ramírez.

You don't always need a queue

A few weeks ago my colleague and I were talking about the pros of using a queue to take some work out of the request cycle. He read an article that suggested that queues should be used for all external calls. I disagreed. Making broad recommendations like that generally don't pan out because there are always tradeoffs. It's bound to be much nuanced than that. In this article I want to explore a few considerations worth exploring before you jump to using a queue.

Source: You don't always need a queue, an article by Jean-Mark Wright.

Me Time (2022)

Follows a dad who finds time for himself for the first time in years while his wife and kids are away. He reconnects with a friend for a wild weekend.

In the afternoon Alice, Esme, and I watched Me Time. I liked the movie and give it a 7 out of 10.

Bean (1997)

The bumbling Mr. Bean travels to America when he is given the responsibility of bringing a highly valuable painting to a Los Angeles museum.

In the early evening Alice, Esme, and I watched Bean. I liked the movie and give it a 7 out of 10.

The Weekend Away (2022)

A weekend getaway to Croatia that goes awry when a woman is accused of killing her best friend. As she attempts to clear her name and uncover the truth, her efforts unearth a painful secret.

In the evening Esme and I watched The Weekend Away. I liked the movie and give it a 7 out of 10.

Deploying Django apps with Github Actions and Django Up

For the last few years I've been using Django Up to deploy my small Django side projects. It's implemented as a Django management command that under the hood uses Ansible to deploy to an Ubuntu 22.04 server.

In the past, I've typically run deployments from my local machine. However, this year I've been encouraging more teams to focus on CI/CD practices, so I've decided to migrate a number of projects to deploy from Github Actions (thanks, work!).

With that in mind, I wanted to share a quick guide on how to deploy a new Django project to a VPS using Github Actions.

Source: Deploying Django apps with Github Actions and Django Up, an article by Brenton Cleeland.

Why I'm still using Python

I’ve been using Python since 2006, and every year I ask myself if it’s still the right language for me. I don’t want to get stuck using a language just because it’s the one I’ve become comfortable using. Languages are constantly evolving, and if there’s a language that better suits my needs I’ll happily invest the time needed to make a change. In the end, though, Python is still right for me, for the same reasons it was right in 2006: it lets me get the work done that I want to do, enjoyably and efficiently. There’s also the added bonus of getting to be part of one of the best communities I’ve ever been involved in.

Source: Why I'm still using Python, an article by Eric Matthes.

Load Testing Tips

Over a decade plus of getting retailers ready for a smooth Black Friday I’ve collected a few tips, tricks, and stories related to keeping busy applications online during big events.

In fact there’s one simple (not easy!) trick to it: the best way to ensure your website can handle a big event is to have your website handle a big event. That may seem like a tautology, but it’s where this post starts and it’s where it ends.

Source: Load Testing Tips, an article by Shane Hansen.

White Noise (2022)

Dramatizes a contemporary American family's attempts to deal with the mundane conflicts of everyday life while grappling with the universal mysteries of love, death, and the possibility of happiness in an uncertain world.

In the evening Esme and I watched White Noise. I didn't like the movie much and give it a 5 out of 10.

5 Reasons a Raspberry Pi Belongs in Your Network Lab

It’s Pi Day, everyone — my favorite crowd-sourced holiday. And not just because of my deep affection for fruit/sugar-filled pastries. Nope, since it was first released ten years ago, I’ve loved the Raspberry Pi microcomputer. So, when I was asked if I had any ideas for a Pi-Day blog, I knew exactly what I wanted to write. So, I bring you… 5 Reasons a Raspberry Pi Belongs in Your Network Lab!

Source: 5 Reasons a Raspberry Pi Belongs in Your Network Lab, an article by Hank Preston.

Billions of unnecessary files in GitHub

The way to make sure that neither we nor anyone else adds these files to the git repository by mistake is to create a file called .gitignore, include patterns that match the files we would like to exclude from git and add the .gitignore file to our repository. git will ignore those file. They won't even show up when you run git status.

Source: Billions of unnecessary files in GitHub, an article by Gabor Szabo.

Detecting the use of "curl | bash" server side

Installing software by piping from curl to bash is obviously a bad idea and a knowledgable user will most likely check the content first. So wouldn't it be great if a malicious payload would only render when piped to bash? A few people have tried this before by checking for the curl user agent which is by no means fail safe - the user may simply curl the url on the commandline revealing your malicious code. Luckily the behaviour of curl (and wget) changes subtely when piped into bash. This allows an attacker to present two different versions of their script depending on the context :)

Source: Detecting the use of "curl | bash" server side.

Extending Python with Rust

Sometimes a pure Python script can't just deliver the performance we need. When that's the case we have to resort to writing our logic in a "fast" compiled language like C or Rust and expose the function with through a Python module. This way we get the best of both worlds. Today I focus on how to use Rust for writing such extensions. I choose Rust over C because it is just nicer to use and less of a minefield of gotchas waiting for you trip them. Also, since as a data scientist I spend spend most of the time manipulating Numpy arrays so I will focus on how to pass them and return them from Rust. To accomplish this I'll make use of the PyO3 and Numpy crates.

Source: Extending Python with Rust, an article by Maxwell Rules.

Rust 2023

The core team used to put out a yearly call for blog posts. My colleage Nick published their "Rust in 2023" post last week, and encouraged others to do the same. I like the idea of taking a moment to reflect on larger topics, and so well, why not write a post!

I want to do this a bit differently from the usual formula though. Rather than writing something with the specific intent to build some sort of "Rust 2023 roadmap", I want to instead take this as an opportunity to reflect on the state, values, and priorities of the Rust project. More of a snapshot of my current perspectives, than a concrete list of action items I think should be tackled. Here goes!

Source: Rust 2023, an article by Yoshua Wuyts.

Modularizing a static website with HTML Modules and PostHTML

Our landing page is a static site that consists of a simple set of HTML pages, with a tiny sprinkling of JavaScript here and there. We started with a single HTML page and for links like our Privacy Policy and Terms of Service, we copied and pasted everything into a new file for each page.

This was fine for a little while, but eventually it became annoying to keep updating each html file, so we wanted to add a way to modularize our pages. The idea is to keep the footer, header, nav bar and other components the same across the site, in a DRY way.

Rather than bring in a new static site framework, we wanted something we could easily add to our existing NPM scripts that we already have for including TailwindCSS and hosting a local dev server.

Source: Modularizing a static website with HTML Modules and PostHTML.