I recently came across this video on YouTube. It's a short tutorial on generating a Julia set fractal image in Rust. I've used Rust before but never with image generation or mathematics, so it looked interesting, and I followed along. By the end of the video, you have some code …
read moreOther articles
Terminal Input Selector in Python
When writing a cli program that needs the user to make a choice, you might want to present a list of options and get a selection. The simplest way might be to print each option and get the user to type the one or the index of the one they …
read moreMuting Linter Errors in Python
Linters and static type checker are great for finding bugs in your code, but sometimes they misunderstand or you have some other reasons for leaving the code as is. In that case you might want to mute the error(s) to allow the linting or type checking to pass, either …
read moreSmart CLIs with Typer
The go-to library for adding CLI functionality in python is the built in
argparse
library. This works really well, but there is a relatively new 3rd party library calledtyper
that boasts a number of improvements.Firstly, with typer, rather than configuring a parser with each argument, you can simply …
read moreInvestigating Deadlocks in Postgres
When performing transactions on the same tables in Postgres from multiple apps, you might face deadlocks.
You might get an error like this one (example from here):
read moreDBAPIError: (TransactionRollbackError) deadlock detected DETAIL: Process 61086 waits for ExclusiveLock on tuple (7217,55) of relation 626383 of database 380717; blocked by process …
Property Based Testing With Hypothesis
This is a summary based on this article.
Rather than specifying test cases, define properties that your functions must fulfil, and let
hypothesis
generate dozens of test cases automatically.read morefrom hypothesis import given, strategies as st @given(st.integers(), st.integers()) def test_func(a, b): # get result c = func(a …
Local Network Speed Test
There are multiple reasons why you might want to test the speed of you local network. For example you can test the speed between your router and your device. Or the speed between your device and a home server. For me it was the former. I wanted to make sure …
read morePublishing a Pelican site to GitHub Pages using GitHub Actions
I decided a while ago that I wanted to to start a blog, but despite GitHub Pages natively supporting Jekyll, I was put off because I didn't want to setup Ruby and the other dependencies just for a static site. Sometime later I was reading this article and I noticed …
read more