Recent Posts (all)

Start using ddclient

Posted on 26 Mar 2024

For more than 10 years, I’ve been a happy client of Tweak (how long will that link work?). One of the many features it offered was a fixed IP address.

Now that I’m forced to switch to Odido, I will lose this affordance, which serves me greatly whenever I need to connect to my VPN at home. In fact, my phone and laptop are configured to just connect to a subdomain of lanzani.nl, which pointed to my home address, and that address never changed.

I then started looking for ways to update my IP address automatically. Luckily, there seems to be a service that’s been designed for this, ddclient that I’ve set up in my home server as follows:

  • First of all, as my DNS is managed by Porkbun, I have to enable API access to change DNS parameters programatically;
  • Configuring it is as easy as writing in ~/code/ddclient the following
# ddclient.conf
daemon=600
use=web
protocol=porkbun
apikey=APIKey
secretapikey=SecretAPIKey
subdomain.lanzani.nl
  • Then, as I don’t want to install Perl and what not, I decided to leverage docker to run the script. The yaml for docker-compose couldn’t be easier:
services:
  ddclient:
    image: lscr.io/linuxserver/ddclient:latest
    container_name: ddclient
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
    volumes:
      - /path/to/code/ddclient:/config
    restart: unless-stopped
  • Start the service and see the logs coming in
[migrations] no migrations found
usermod: no changes
───────────────────────────────────────
      ██╗     ███████╗██╗ ██████╗
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝
   Brought to you by linuxserver.io
───────────────────────────────────────
To support LSIO projects visit:
https://www.linuxserver.io/donate/
───────────────────────────────────────
GID/UID
───────────────────────────────────────
User UID:    1000
User GID:    1000
───────────────────────────────────────
[custom-init] No custom files found, skipping...
Setting up watches.
Watches established.
[ls.io-init] done.
/config/ddclient.conf MODIFY 
ddclient has been restarted
Setting up watches.
Watches established.
SUCCESS:  updating ipv4: skipped: subdomain.lanzani.nl address was already set to ...

That’s it. Just a few lines of code, and the problem is gone!

Bitten by timezones and Docker

Posted on 15 Mar 2024

I am building a Telegram chatbot to remind me to take out the trash.

I’m overengineering it, so of course it has Docker and a (sqlite) database.

One component of the chatbot does an hourly check. If tomorrow the trash will be collected, and the current time is later than the time I want to receive the notification (and if I haven’t been notified today), I should get a message.

However, I was not getting the messages. The code seemed solid

SELECT 
  user 
FROM
  users
WHERE
(
  TIME('now', 'localtime') > TIME(time_of_day) AND
  DATETIME('now', 'localtime', '-1 day') >= 
  DATETIME(last_executed_run, TIME(time_of_day))
)
OR
  last_executed_run IS NULL

Worse of all, when I was running on the Docker host, I would get notified at the right time.

It turns out Docker doesn’t respect the host timezone, but you need to be explicit about it, adding a TZ environment variable (in my case TZ=Europe/Amsterdam).

Automatically add images for Open Graph in Hugo

Posted on 14 Mar 2024

While using a static site generator is a low-maintenance endeavor, it also means that complex requirements need to be coded if nobody has done it before. Today, I automated image previews that can be used to display a nice preview through for Open Graph (and Twitter cards!).

The Open Graph protocol enables any web page to become a rich object in a social graph. My blog, however, is text-heavy and often misses the images, so I had to come up with something else.

In the end, I settled with a solution (code below) that displays a static image with some text on top, including the title, a snippet of the blog, and the URL.

The snippet can be explicitly set in the front matter with the snippet key, otherwise it will take the first characters of the post itself.

To make it all work, you need a couple of things in your Hugo theme

├── assets
│  ├── Inter-Medium.ttf
│  ├── Inter-SemiBold.ttf
│  └── og_base.png
├── layouts
│  ├── partials
│  │  ├── opengraph.html
   

Here, og_base.png is just the empty image used to write text on, like:

The fonts are just the fonds, and opengraph.html contains:

In the, then, every blog post will be accompanied by an image as

Men Children

Posted on 23 Feb 2024

An interview with Lyz Lenz

In the quoted toot, Lyz Lenz offers the wrong solution to a wide-spread societal problem: men who have remained children.

Our society tries to delay or prevent people growing up: making irreversible decisions, taking responsibility, caring for someone else more than for yourself, suffering.

Women are forced to much of the above when they become mothers (an irreversible decision, they take responsibility for the newborn, they will defend their child with their life, and laboring is a lot of suffering).

Men, on the other hand, can skip everything when they become fathers: they can leave and, when they stay, they can pretend to continue as nothing happened.

The tragedy is a that the situation creates a vicious cycle: as the father is absent or doesn’t take up his duties as a father, the mother protects her child even more, making it hard for the child to grow.

Public Appearances

Posted on 15 Feb 2024

I’ve added a page about my public appearances throughout the years. I still have to figure out how to make it load faster with all those pesky videos coming from youtube!

China's Economy

Posted on 09 Feb 2024

Has Xi Jinping lost control of the markets?

What’s happening in China is really interesting. If we trust their official figures and estimates, the economy was driven by 3 things:

  1. Real estate (who’s crashing hard)
  2. Consumer spending (who’s in decline, as their population is not growing and aging)
  3. Exports (who are threatened by India and South East Asia)

As 1. is crashing, consumers—who put most of their savings in, guess what, real estate—are more conscious about spending, hurting another good 30% of their economy.

So, 2/3 of their economy is hurting and will hurt more badly in 2024.

The Chinese’s and Hong Kong’s markets are also spooked, having shed USD 1.5 TRN in January alone.

It’s going to be an interesting 2024.

Decode your URLs

Posted on 06 Feb 2024

Today, I read Terence Eden’s article about the abundance of Microsoft’s safelinks systems. One example he gives is

https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcfa.nhs.uk%2Fabout-nhscfa%2Fcorporate-publications%2FSIA-23%2FSIA-2023-foreword&data=05%7C01%7CAnnualReport%40dhsc.gov.uk%7C26af6f102198492b3bcd08dbca6a3cc3%7C61278c3091a84c318c1fef4de8973a1c%7C1%7C0%7C638326329851162850%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=WK%2FuqOZJ0ixZpvJIyJiCWRt5hxTwBfcwbONaUxJViBw%3D&reserved=0

As my work email is hosted by Microsoft, I’m bugged to no end by this system, which doesn’t make it easy to extract the URL in a readable format (read the blog if you want to know more shortcomings of the system).

For a couple of years, I have a Typinator snippet that decodes the URL, so that by typing ;dec, the following script is triggered

{/JavaScript
let URI = "{clip}".split("=", 2)[1].replace("&data", "")
let encURI = decodeURIComponent(URI)

encURI
}

Converting the above link to

https://cfa.nhs.uk/about-nhscfa/corporate-publications/SIA-23/SIA-2023-foreword

The script is not perfect, but, since defining it, Typinator analytics tell me I’ve used it some hundred times and I can’t recall when it didn’t just work.

Mark Apple Music song as favorite in the background

Posted on 09 Jan 2024

I often listen to Apple Music in the background and sometimes I casually listen to a song I want to add to my favorites.

Instead of jumping around, I created a small AppleScript script (that can be executed through Launchbar or Keyboard Maestro).

I report it here for posterity!

tell application "Music"
	set favorited of current track to true
end tell

American universities face a reckoning over academic freedom

Posted on 13 Dec 2023

American universities face a reckoning over academic freedom

Too often universities reflexively try to mollify students rather than have them grapple with ideas they find unsettling, says Edward Hall, a philosophy professor at Harvard. Administrators see an angry or upset student in their office and instantly try to make them feel better.

A failure of good parenting for those who grew up in the wave of the 60s and 70s?

Use the Grammarly language server with helix

Posted on 23 Nov 2023

Lately, I’ve been playing around with helix, a relatively new modal editor.

One of the things I was missing was an LSP for Grammarly (the only reason I can put the commas where they belong).

After struggling a bit with the configuration, I’ve finally found what works

[[language]]
name = "markdown"
auto-format = false
file-types = [ "markdown", "md", "mdown", "txt" ]
language-servers = [ "grammarly" ]

[language-server.grammarly]
command = "grammarly-languageserver"
args = ["--stdio"]
config = { clientId = "client_BaDkMgx4X19X9UxxYRCXZo"}

Note that:

  • You need to install the Grammarly language server before.
  • clientId is not a secret and is the same for all installations.
1/10