RSSAmplifier

Blog

Sergi's writing

Blog of Sergi Pons Freixes

sergiswriting.comRSS feed ↗22 posts

Latest posts

This blog got a new favicon thanks to the Small Web

The other day I was checking out what was surfacing on Bubbles , and I ended up reading this post from Matt Stein about how he likes to hand-draw favicons . At the end of the post, he mentions he would love to make favicons for others, so I decided to reach out and ask him to make one for this blog. After a few emails back and forth, I ended up with this beauty in PNG form in my possession: Then I…

Ditch Postman, use Bruno

I had been using Postman since the beginning of my web developer career. Back when I started using it, it was a great tool, and I never felt the need to switch to something else. I remember some terminal-oriented alternatives popping up at some point, but I develop on a desktop environment, so I didn't really had the need to lose the affordances a full graphic user interface offers. I'm a fan of…

My favourite Python library for calculating dice probabilities

Disclaimer: I am not a mathematician, and it has been a long time since I studied statistics and probability, so I'm probably botching or misusing some terms. Every time I get into some miniatures wargame like Marvel Crisis Protocol or Dropfleet Commander , one of the first things I do is checking if there exists some dice roll simulator for that game. I use that to get a better feel of how some…

I tried to opt-out of airlines selling my data to the government, and I am not sure if it worked

A few weeks ago, somebody posted on my Mastodon feed a link to an old article from 404 Media called How to Opt-Out of Airlines Selling Your Travel Data to the Government (I'm sorry kind stranger, I probably boosted your message but forgot to bookmark it to give you credit here). The article explains that there is a data broker — the Airlines Reporting Corporation (ARC) — that sells flight data to…

Arrow functions are overused

I've noticed something in online articles lately: arrow functions everywhere. It's as if function became a dirty word overnight, and every function declaration got replaced with const myFunc = () => {} . While arrow functions are undeniably useful, I think we've swung too far in the other direction. Let me be clear upfront—there are absolutely cases where arrow functions shine and others where…

Bringing back the scrollbars

I don't like the design pattern of hiding the scrollbars. I am not alone in this; I have frequently read articles complaining about it, like this blog post that made it to Hacker News , Reddit posts , or even posts on Microsoft forums . There are different variations of this pattern. On some cases, the scrollbar is hidden, and it only shows up when hovering the cursors over the area where the…

How to fix a Pixel Watch stuck on Fastboot

I am the owner of a Pixel Watch 2. During the past months, approximately once a week, the battery would suddenly deplete very quickly. For example, I would charge it overnight, put it on around 8am, and when checking the time at 2pm I would find out it was almost dead (or already dead). If I caught this happening before the device died, a reboot would fix it and the watch would keep working as…

Ode to the Kindle Keyboard (Kindle 3)

In 2010, I got a Kindle Keyboard (aka Kindle 3) as a Christmas gift from my parents. It's still my only ebook reader, and it's probably the oldest piece of technology I regularly use. It's 14 years old and still works! The specs The particular model I own is the one with only Wi-Fi. There was a more expensive option with 3G but at the time — and still nowadays — I saw no reason for that feature.…

Refactoring my homepage

In my previous post , I said I wanted to rebuild my blog using the principles of CUBE CSS and Every Layout . But I decided to start with something smaller, my homepage , and see how that turns out. How it looks First, let's have a quick look at the "before and after" of the rendered site: Old homepage rendered at 1920x1080. New homepage rendered at 1920x1080. They look very similar, though not…

I feel excited about writing CSS

I don't feel fully satisfied with the CSS of this blog. I handcrafted it from scratch, and while overall I like it, there are a few quirks here and there (like the spacing of list elements on some edge cases) that bother me. At the beginning of writing the CSS, it was feeling good because I was mostly targeting elements by type . However, as I needed to add exceptions and customizations, I began…

Do not reinvent the wheel

Python's standard library is awesome. Just skim through the list of available packages and modules . I bet that there is something in there that you didn't know existed or that you have forgotten about it. From time to time I like to go through this list or check the Python release notes to see if there is any addition that can make my life easier. It is not uncommon to forget about it and…

SQLAlchemy relationship with five tables

I had to create a relationship that needed to combine five different tables on a project I was working on. The SQLAlchemy documentation about composite secondary joins has an example for combining four tables, and in this blog post, I am extending it to five. We start with a Company model. That model represents, well, a company. That company will have users, which we represent with the User model…

Fix for Rust on Windows not able to find MySQL library

I was tinkering with the Diesel ORM on a Rust project, and when building it I faced the following error: $ cargo run Compiling tokio v1.34.0 Compiling tinyvec_macros v0.1.1 Compiling serde v1.0.193 Compiling tinyvec v1.6.0 Compiling unicode-bidi v0.3.13 Compiling pin-project v1.1.3 Compiling axum-core v0.3.4 Compiling mysqlclient-sys v0.2.5 Compiling byteorder v1.5.0 error: could not find native…

Auto-incrementing IDs on MongoDB

In relational databases, it is a common pattern to use auto-incremental integers as IDs for table rows. On MongoDB, if you don't set an _id field on document creation, the document will get an ObjectId value automatically assigned to it as _id . This is fine in most cases because usually, you don't need to expose that ID to the users of the API (or on the UI presenting that data). But sometimes…

Enabling OpenSSL for Rust in Windows

The other day I was compiling a Rust project on a Windows 11 environment, and when executing cargo run and I got the following error: error: failed to run custom build command for openssl-sys v0.9.93 ... note: vcpkg did not find openssl: Could not find Vcpkg tree: No vcpkg installation found. Set the VCPKG_ROOT environment variable or run 'vcpkg integrate install' According to the openssl crate…

How to rotate Gunicorn log files

A few weeks ago I found myself scratching my head about missing records on the log files of a Flask application running with Gunicorn . I knew that the requests had been performed and should have been logged, but they were nowhere to be found. While investigating, I noticed that the rotated log files had way less records than what I expected. Something was going on. After some online surfing, I…

Best practice for importing the <code>datetime<&#x2F;code> module in Python

The datetime module is one of the most controversial Python imports. That both the module and the class share the same name is unfortunate. I've seen many bugs caused by a developer using one thinking they are accessing the other because they didn't check how the import was done, and their IDE did not warn them. The practice I've been putting in place with great success at the teams I've worked on…

Tip: Speed up Python dictionary lookups

Last week at work, there was a conversation about managing a fairly large key-value data structure using Python. A colleague recommended checking sys.intern to improve performance. I can't add much beyond what's already covered in the documentation : sys.intern(string) Enter string in the table of “interned” strings and return the interned string – which is string itself or a copy. Interning…

Better colors for moved text in Git

If you move a block of text/code around, and then you run git diff , you will see that the moved text is displayed like any other change. If you are using the default colors, the old location will show in red and the new one in green. So, we can't quickly tell if that change only involves moving that block around, or if in addition to the displacement something has actually changed inside the…

How to create a Linux Desktop entry for PyCharm

Unless your Linux distribution offers a package for PyCharm, you have to download a tar.gz from JetBrains' website , unpack it, and then run the PyCharm.sh script. There is no installer; PyCharm launches directly. Since you are likely using a Desktop environment (PyCharm being a graphical IDE), you may want want a convenient Desktop launcher to avoid opening a shell just for that. Well, the folks…

How to pair a Bluetooth keyboard in Windows 11

I am the happy owner of a Leopold FC660MBT Vapor 65% Bluetooth . I decided that this would be my in-office keyboard instead of the cheap one provided at my current company. My work computer is a ThinkPad laptop running Windows 11, so I was expecting the pairing to be smooth as butter. To my surprise, when I tried to pair it, Windows greeted me with a dialog asking for a PIN. Well, that's funny.…

This is a blog

I used to have a blog. It was a mixture of tech articles — mostly about Linux, Open Source and privacy — and random ramblings. I wrote on different languages, depending on whom I thought could be interested on reading a particular article. As many blogs, it eventually died of inactivity. I kept it around for many years in case some tech articles were still useful for somebody. At some point I…