RSSAmplifier

Blog

Marcelo Fernandes

marcelofern.comRSS feed ↗16 posts

Latest posts

Profiling a Django Migration in Postgres

Profiling a Django Migration in Postgres Created at: 2025-02-17 In this post I want to start from the end. I want to look into the SQL for a particular schema change, and then verify whether a Django migration that produces this change is safe to run in production or not. Let's start with a question: Is the following schema change safe to run in a production database? ALTER TABLE foo ADD…

Should you not use Postgres varchar(n) by default?

Should you not use Postgres varchar(n) by default? Created at: 2025-02-01 The Postgres wiki has a page called "Don't Do This" where general good practices are discussed. Amongst them, there is a session titled: "Don't use varchar(n) by default" which is copied verbatim below: Why not? varchar(n) is a variable width text field that will throw an error if you try and insert a string longer…

Code Reviews In Vim

Code Reviews In Vim Created at: 2024-11-21 A common way of reviewing code today is by performing the review using the repository host UI (GitHub, GitLab, etc.). I have done that for awhile, and I still do it when code changes are trivial. "Trivial" means I don't need to play with the branch locally first to have confidence the changes are correct. However, often I will work with code that is…

About That Postgres Json Field

About That Postgres Json Field Created at: 2024-10-10 The json type was introduced in Postgres 9.2. Since then, the json type has gone through multiple enhancements, including the addition of the jsonb type (9.4). Because the json type stores an exact copy of the input text, it will preserve semantically-insignificant white space between tokens, as well as the order of keys within json objects.…

Thoughts on 3 years of management

Thoughts on 3 years of management Created at: 2024-10-08 I've been managing for the past 3 years at my current job. This is not extensive experience and I still see myself as a junior manager. As I reflect on my journey, I talk through lessons learnt from managing other developers and on recurring patterns I have observed. Now, a post about management is not cringe enough unless it includes…

On Git Commit Messages

On Git Commit Messages Created at: 2024-10-05 There are two web pages that provide a great summary on Git Commits best practice. I recommend reading them before going through the rest of this post: Git Commit Good Practice - OpenStack Tim Pope's note about commit messages Those articles are "old". One is from 2008 and the other is from 2014. This means that the following occasional comment…

Postgres Unique Constraints Without Downtime

Postgres Unique Constraints Without Downtime Created at: 2024-10-01 Updated at: 2024-10-08 The syntax for adding a unique constraint in Postgres is as follow: ALTER TABLE "table_name" ADD CONSTRAINT "unique_constraint_on_foo" UNIQUE ("foo"); This constraint will prevent multiple rows having the same value stored in the foo column. However, this operation acquires an ACCESS EXCLUSIVE lock, blocking…

Why Is This Site Built With C

Why Is This Site Built With C Created at: 2024-08-26 I've been writing about things on a personal website since 2017 . Most of what I have written features in the category of notes-to-self. Mostly on how to do A or B. Only recently I've started polishing notes together and forming posts on specific topics. One thing I realised was preventing me of writing more frequently wasn't the…

The Dumbest Compiler Imaginable

The Dumbest Compiler Imaginable Created at: 2024-08-20 Python is about having the simplest, dumbest compiler imaginable, and the official runtime semantics actively discourage cleverness in the compiler like parallelizing loops or turning recursions into loops. − Guido van Rossum (creator of Python). source This might be a shocking statement to read for someone used to languages that compile to…

Managing Python Environments

Managing Python Environments Created at: 2024-08-06 The ecosystem for managing Python environments is huge, and so is the number of tools that are used to manage these environments. We have: pyenv , virtualenv , virtualenvwrapper , asdf , conda , anaconda , uv , poetry , pipenv etc. It is very easy to break your local environment if you are new to all of this. This cartoon from xkcd sums it up…

Which Assembly Syntax to Choose?

Which Assembly Syntax to Choose? Created at: 2024-07-24 Updated at: 2024-08-13 TLDR : Use the Intel syntax, but AT&T isn't that bad. I usually prefer not to post content that is already easily searchable on the internet. But the problem is, the really great information on this topic seems to be distributed across just a few different places which sometimes are tricky to find and often not…

mov edi, edi

mov edi, edi Created at: 2024-06-08 Updated at: 2024-07-27 I had a surprise today when I saw the instruction mov edi, edi as the first instruction of a function call. This is my C code: unsigned int func(unsigned int idx) { static unsigned int my_table[] = {10, 20, 30, 40}; return my_table[idx]; } Which returned the following x86 assembly (compiled via gcc): func: mov edi, edi lea rax,…

Goodbye ZSH

Goodbye ZSH Created: 2024-05-08 Updated: 2024-07-06 After 7 years using zsh and oh-my-zsh , I've completely ditched both of them today. I would like to state at the top that there isn't anything inherently bad or wrong with zsh and oh-my-zsh. It is just that these technologies don't fit well within my way of doing things, and have become unnecessary over time. There are many reasons…

Branchless Programming Experiments in C++ and Python

Branchless Programming Experiments in C++ and Python Created: 2023-08-22 Updated: 2024-07-28 This article talks about high-level theoretical concepts of branchless programming, along with examples of branchless programming in C++ and Python. What's branchless programming and why does it matter? A branchless program is a program that doesn't include any conditional operator ( if , else ,…

A Critique of SOLID

A Critique of SOLID Created: 2023-04-15 Updated: 2024-07-06 Introduction SOLID is an acronym coined by Robert C. Martin (also known as uncle Bob), particularly focused at making Object Oriented Programming designs easier to understand, maintain, and adapt. The original paper (archived) introducing the term in 2000 is a quick read worth checking, even if only for historical context. Before the…

Linux Rice

Linux Rice Created: 2020-08-30 Updated: 2024-07-06 Introduction When someone is "ricing" their unix system, they are making functional and visual customisations to their desktop. These changes could be anything from changing the colour of a status bar to completely restructuring their computer environment. Why? Productivity : You can customise your applications and keyboard shortcuts to satisfy…