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=""

Troubleshooting generic file encodings

Some notes on troubleshooting different encodings for sent/received files. Table Encoding å ä ö Å Ä Ö UTF-8 \c3\a5 \c3\a4 \c3\b6 \c3\85 \c3\84 \c3\96 latin1 \e5 \e4 \f6 \c5 \c4 \d6 CP437 \86 \84 \94 \8f \8e \99 CP850 \86 \84 \94 \8f \8e \99 Notes WINDOWS-1252 / CP-1252 is a superset of latin1 All encodings are supersets of ASCII, so \20=SPACE and \0a=NEWLINE Sometimes you will encounter the “ANSI”-encoding. That name is a lie, and means that the creator is stupid in the head. There is no way of knowing what the creator intends, so you will have to try one encoding at a time and hope for the best. Vim commands If you hover over a character and type ga, you will see the VIM interpretation of the encoding. Note that this will NOT necessarily be the FILE-encoding, but instead the VIM-encoding. ...

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  | 

Grayling on Thomism as a dogma

[Thomas Aquinas’] teachings constitute a complete system, which is why, as ‘Thomism’, they provide the Roman Catholic Church with its philosophy, whose official status was further confirmed by Pope Pius X in Doctoris Angelici (June 1914): ‘The capital theses in the philosophy of St Thomas are not to be placed in the category of opinions capable of being debated one way or another, but are to be considered as the foundations upon which the whole science of natural and divine things is based; if such principles are once removed or in any way impaired, it must necessarily follow that students of the sacred sciences will ultimately fail to perceive so much as the meaning of the words in which the dogmas of divine revelation are proposed by the magistracy of the Church.’ This places Thomistic philosophy and theology above all debate, which – at least in the case of philosophy – is precisely contrary to what philosophy should be. ...

Philosophy in the Autumn of 2021

When the autumn comes with its gloom and rain, I get this feeling of melancholy and the need to write down my thoughts on paper. This time I will ramble in the form of a blog post. Please don’t read this as me preaching with a “holier than thou”-attitude. It’s meant by me and for me. Maybe I can read this condescendingly in ten years and think of my then primitive philosophy. ...

Watch Renovation: Altus

Some notes on a watch which I’m renovating Text on dial: Altus - Incabloc Text on case back: 4452 512 199797 Data Measurements are done by me, and might not be the official numbers. Width: ? Length: ? Height: ? Lug-to-lug: ? Movement: Felsa 391? Swiss lever Case: Chrome plated brass Crystal: Acrylic Problems Keyless works very rusted Mainspring is broken Crown needs some locktite, can get loose Watch hands has rust Dial needs some cleaning Troubleshooting steps Opened up, cleaned and oiled all parts. Cleaned the keyless works several times, and it seems to work fine now Media

lsof Cheatsheet

Nice things you can do with lsof # Show all active internet connections lsof -i # Show all active TCP connections lsof -iTCP lsof -iTCP:57123 # Show active TCP connection on port 57123 # Show all active IPv4 connections lsof -i4 lsof -i4:57123 # Show active IPv4 connection on port 57123 # Show all file descriptors for a user lsof -u $USER

August 27, 2021  |  🏷️Lsof

Watch Renovation: Rouan

Some notes on a watch which I’m renovating Text on dial: Rouan - De Luxe - 17 Rubis - Unbreakable mainspring - Shockproof Text on case back: Antimagnetic - Stainless steel caseback Data Measurements are done by me, and might not be the official numbers. Width: ? Length: ? Height: ? Lug-to-lug: ? Movement: Eppler 7 - or a variant thereof Pin lever escapement Metal rocker bar Case: Looks like gold plated nickle. Crystal: Acrylic Problems Doesn’t run despite being fully wound Slightly cracked glass Troubleshooting steps Opened up and cleaned all parts. Media

Watch Renovation: Brac

Some notes on a watch which I’m renovating Text on dial: Shock proof lever - Swiss made Text on case back: Data Measurements are done by me, and might not be the official numbers. Width: ? Length: ? Height: ? Lug-to-lug: ? Movement: The BR-logo stands for Brac-Werke AS according to this page. Very similar to a Lapanouse. Pin lever escapement Case: Looks like brass. Crystal: Acrylic Problems Doesn’t run despite being fully wound Crown doesn’t want to move between winding mode and setting mode. Troubleshooting steps Opened up and cleaned all parts. Very dirty movement. Media