Perl script for mangling SRT subtitle files

I had a set of SRT files with pretty good subtitles, but with one annoying problem: When there was a song in the background, the translation of the song would pop up and interrupt of the dialogue’s subtitles, so it became impossible to understand what’s going on. Luckily, those song-translating subtitles had all have a [...]

Perl: “$” doesn’t really mean end of string

Who ate my newline? It’s 2023, Perl is ranked below COBOL, but I still consider it as my loyal working horse. But even the most loyal horse will give you a grand kick in the bottom every now and then. So let’s jump to the problematic code: #!/usr/bin/perl use warnings; use strict; my $str = [...]

Using git send-email with Gmail + OAUTH2, but without subscribing to cloud services

Introduction There is a widespread belief, that in order to use git send-email with Gmail, there’s a need to subscribe to Google Cloud services and obtain some credentials. Or that a two-factor authentication (2fa) is required. This is not the case, however. If Thunderbird can manage to fetch and send emails through Google’s mail servers [...]

Blocking bots by their IP addresses, the DIY version

Introduction I had some really annoying bots on one of my websites. Of the sort that make a million requests (like really, a million) per month, identifying themselves as a browser. So IP blocking it is. I went for a minimalistic DIY approach. There are plenty of tools out there, but my experience with things [...]

Google Translate, LaTeX and asian languages: Technical notes

Introduction These post contains a few technical notes of using Google Translate for translating LaTeX documents into Chinese, Japanese and Korean. The insights on the language-related issues are written down in a separate post. Text vs. HTML Google’s cloud translator can be fed with either plain text or HTML, and it returns the same format. [...]

Random notes on Perl Regular Expressions

It’s 2022, Perl isn’t as popular as it used to be, and for a moment I questioned its relevance. Until I had a task requiring a lot of pattern matching, which reminded me why Perl is that loyal companion that always has an on-spot solution to whatever I need. These are a few notes I [...]

Thunderbird: Upgrade notes

Introduction These are my notes as I upgraded Thunderbird from version 3.0.7 (released September 2010) to 91.10.0 on Linux Mint 19. That’s more than a ten year’s gap, which says something about what I think about upgrading software (which was somewhat justified, given the rubbish issues that arose, as detailed below). What eventually forced me [...]

Perl: Matching apparently plain space in HTML with regular expression

I’ve been using a plain space character in Perl regular expressions since ages, and it has always worked. Something like this for finding double spaces: my @doubles = ($t =~ / {2,}/g); or for emphasis on the space character, equivalently: my @doubles = ($t =~ /[ ]{2,}/g); but then I began processing HTML representation from [...]

Systemd services as cronjobs: No process runs away

But why? Cronjobs typically consists of a single utility which we’re pretty confident about. Even if it takes quite some time to complete (updatedb, for example), there’s always a simple story, a single task to complete with a known beginning and end. If the task involves a shell script that calls a few utilities, that [...]

Perl + DBI: Measuring the time of database queries

It’s often desired to know how much wall clock time the SQL queries take. As with Perl, there’s more than one way to do it. This is a simple way, which involves overriding DBI’s execute() method, so it measures the time and issues a warn() with basic caller info and the time in milliseconds. The [...]