Node profiling

Some links and stuff for profiling node

Programming Design Patterns

General programming design patterns

Pure ESM package

What to do with pure ESM packages

Golang: In search of lost transitive dependencies

What is go.mod?

September 6, 2024  |  🏷️Golang

The regex [,-.]

A funny post I wanted to archive

May 29, 2022  |  🏷️Regex

Thoughts on having a sorted, modifiable list in MySQL

I had a discussion with a colleague on how to persist a sorted (linked?) list in MySQL, and would like to write down my thoughts on this since this is likely a problem I will face in the future. There must be a better way of thinking about this than I’ve come up with. If you have an idea, don’t hesitate to send me an email. Problem description We have a sorted list of a generic length. It should be possible to reorder the items in a generic fashion (e.g you can drag and drop the items to change the list order from the GUI). This means supporting both swapping items and inserting items between two existing items. Then list should also gracefully handle growing and shrinking. ...

November 24, 2021  | 

Simple Docker MySQL-Server on RAM

A simple docker command to start MySQL on a tmpfs. Things to note: Mounting localtime affects MySQL server timezone You need to have a my.cnf at the given location ($HOME/docker/mysql/my.cnf) You probably need to create /var/lib/mysql before running the command Setting sql_mode="" is probably not needed for most applications. sudo docker run -d \ --name mysql7 \ -v/usr/share/zoneinfo/Europe/Stockholm:/etc/localtime:ro \ -v$HOME/docker/mysql/my.cnf:/etc/my.cnf \ -e MYSQL_ROOT_PASSWORD=root \ -e MYSQL_ROOT_HOST='%' \ -p3306:3306 \ --mount type=tmpfs,destination=/var/lib/mysql \ mysql/mysql-server:5.7 \ --sql_mode=""

Thoughts on collation in an international database in MySQL

When you have an international database, how do you make sure that the collation is correct for all locales? Here are some thoughts. Note that you have to be careful when mixing collations in queries or SQL will complain. Table with virtual, generated columns CREATE TABLE `note` ( `id` bigint NOT NULL AUTO_INCREMENT, `text` varchar(256) DEFAULT NULL, `text_swedish` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_swedish_ci GENERATED ALWAYS AS (`text`) VIRTUAL, `text_danish` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_danish_ci GENERATED ALWAYS AS (`text`) VIRTUAL, ... PRIMARY KEY (`id`), KEY `text` (`text`), KEY `text_swedish` (`text_swedish`), KEY `text_danish` (`text_danish`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci There is support for generating columns from another column. I’m unsure how this affects memory usage. ...

October 6, 2021  | 

Curated list of interesting programming talks / lessons

Curated list of interesting talks / lessons Psychology Jonathan Blow - Techniques for dealing with lack of motivation, malaise, depression Lists Conf42: Cloud Native 2021 Logging Making Logs Work for you with Fluentd Caching Architectural Caching Patterns (for Kubernetes) - Good caching primer Docker Images Securing Containers by Breaking In - Good image security primer

Java Tools Cheatsheet

I have always neglected to write down java tools and commands that I use for troubleshooting. I will try to put in on this page. Memory and Threads There are many tools to measure java memory. In my experience, the easiest way to troubleshoot locally is to hook your development environment up to VisualVM. There are even plugins for it in e.g. IntelliJ. It is probably possible to do this to a production server as well, but that would likely impact performance. If you have access to the server, and have nothing prepared, you can do a heap-dump, which you can copy over and analyze in your local VisualVM. Taking heap dumps is done by jcmd 1 GC.heap_dump /tmp/dump.hprof. ...