[solved] MySQL: Can’t find file ‘./db/table.frm’ (errno: 13)

tl;dr If you’re seeing this and the table does exist- check (and fix) permissions!

I was searching my backups for a database file which contained the entries for an old ranty blog I used to have before I cancelled the domain.

Lo and behold I had a named, dated .tgz file. Unusually, it contained a backup of the MySQL directory structure; rather than a mysqldump‘d set of SQL queries to reconstruct the databases and tables. No matter, I copied the database directory into /var/lib/mysql/db.

Browsing via the command-line interface indicated the database was present (SHOW DATABASES) and usable (USE db). So I tried to SELECT post_title FROM ranty_posts LIMIT 5. But no can do:

Can’t find file: ‘./db/ranty_posts.frm’ (errno: 13)

The problem is permissions, the file is there, slightly-misleading error message notwithstanding. Fortunately, it’s an easy fix- give mysqld the ability to read the files, eg:

# chown mysql:mysql /var/lib/mysql/db/ -R

Which will change the user and group ownership to mysql.


Database and table names changed to protect the innocent

[solved] ‘Because of billing requirements, it is currently not possible to disable auto-renewal’ (1and1)

tl;dr I was within 24 hours of domain renewal, so had to phone +44 333 336 5691 to cancel

I have a bunch of domains that I used at one point but no longer have a need for. I used to handle my domains with 1and1, and they sent me a reminder about an .eu domain which was expiring soon (tomorrow). I looked at what it had been used for — a ranty blog, if you’re wondering — and decided thta since it hand’t been used since ca. 2008 it probably wasn’t worth keeping.

Side note: Getting rid of things like domains is tricky for me, but something I’m just biting the bullet and doing. Tracking my expenses is helpful as well, an worth a bit of exposition at some point.

I went to cancel via the 1and1 admin page but couldn’t through the domain itself or the contract options:

Because of billing requirements, it is currently not possible to disable auto-renewal

Clicking around in an increasingly-frustrated manner didn’t seem to be getting me anywhere, so I phoned their tech support. Their rep told me that helpfully since it was within 24 hours of renewal, I was unable to change the option (?!); but he was able to manually cancel the domain itself.

Which he did:

Sorted.

Better Learning With Anki

Having recently gone through the rigmarole of yet more exams, I’m in a good position to talk about learning things*.

Spaced repetition has been around for ages, as has the wonderful program Anki. Based on the SM2 algorithm, it’s a valuable tool in the would-be reviser’s arsenal. I’m not here to convince you to use Anki in the first place, as that has been well-discussed elsewhere (eg this Reddit discussion or this recap of 10 000 flashcards.

The ’20 rules’

It’s a good idea to start off with SuperMemo’s Twenty Rules of formulating knowledge; this turned me on to Cloze deletion (which can be achieved Anki with a dedicated card type and shortcut for adding them) and better card formulation.

Recognition and two-way connections

I use reversed cards extensively now- wherever possible, basically. It help solidify connections, eg:

Front: What is the Warburg Effect?
Back: What is the name for the process whereby malignant cells gain energy by glycolysis (rather than oxidative phophorylation)

So if a discussion comes up about the Warburg Effect, you know that it’s very roughly about cancer cell metabolism (unless the people discussing it are plant scientists); and if you’re thinking “hey, what’s that thing called where cancer cells get energy differently”, you can easily recall the name too.

Timeboxing

When you see hundreds of cards in the ‘due’ column, finding motivation to sit down and work all the way through can be challenging. So, instead, set a time limit.

You can do that via the ‘timeboxing’ setting in preferences:

Knowing that you’ll only be at it for ten minutes (or less) helps you stay focused. I’ve found myself trying to get as many done in the time limit as possible…

Well, see how many you can lick in an hour. Then try to break that record.


*: Check back in a couple weeks to find out if I did indeed actually pass

Why Won’t My GIMP Python Plug-in Show Up Under Filters?

tl;dr: Did you put it in ~/.gimp-2.8/plug-ins and set the executable bit ?

It’s been a while since I developed a script to automate tasks in GIMP. I figured I would do one for the repetitive tasks for creating a custom YouTube Thumbnail (more on that later perhaps). But my script wasn’t showing up in the Filters menu.

I had found the preference for setting the directory: Edit ? Preferences ? Folders ? Plug-Ins (not that GIMP treats python as plug-ins, not scripts); with the default user folder being ~/.gimp-2.8/plug-ins. But the plug-in dind’t show up.

Restart GIMP. Still nothing.

Ask on IRC. Double check the documentation (always a good idea). Aha!

Scheme and Python plug-ins are readable text files. C-language and Python plug-in files must have permissions set to allow execution.

chmod +x myscript.py later, and it registered!

Hope this saves someone the twenty or thirty minutes it took me to find this out!

Invalid Security Token Issues

tl;dr: Having both AntiSpam Bee and Jetpack Comments causes this, disable one or other

While trying to leave a comment on here on a previous post, I got an error:

Invalid security token

Apparently, AntiSpam Bee and Jetpack Comments are not compatible. I’m not sure when Jetpack comments were enabled as I’ve had relatively recent comments/ I will see if I can find an antispam plugin that is compatible with Jetpack comments, or disable those.

My sincere apologies to anyone who has tried to comment and not been able to as a result!

Better Backups: Pick a System

You have backups, right?

— SuperUser’s chat room motto


This started out as an intro to bup. Somewhere along the way it underwent a philosophical metamorphosis.

I’m certainly not the first person to say that backups are like insurance. They are a bit of a hassle to figure out which one will work best, you set it up and forget about it, and hopefully you won’t need it*.

Many moons ago, I had backups taken care of by a a simple shell script. Later, this got promoted to a python script which handled hourly, daily weekly and monthly rotation; and saved space by using hard links (cp -al ...). It even differentiated between local and remote backups. That was probably my backup zenith, at least when time and effort are factored in.

Really, the more sensible approach is rather than reinvent the wheel, use an existing tried-and-tested solution. So I moved to rdiff-backup and it was good; being simple it meant I could set up ‘fire-and-forget’ backups via cron. I was able to restore files from backups that I had set up and then forgotten about.

With the recent expansion of the fileserver ongoing, now’s a good time to take stock and re-evaluate options. I have created a Xen DomU dedicated to backups (called pandora, aptly) with it’s own dedicated logical volume. From here, I need to decide:

1) whether to keep going with rdiff-backup or switch to eg bup or borg
2) figure out if different machines could use different schedules or approaches (answer: probably); and if so, what those would be (answer: …)

I don’t want to spend too long on this — premature optimisation being the root of all evil — but the aim is to create a backup system which is:

  • robust
  • reliable
  • maintenance-minimal

: If you *do use your backups or insurance a lot, it’s probably a sign that something is going wrong somewhere

File creation time on ext4 (Linux)

tl;dr: since coreutils stat does not show file ‘birth’ time, use debugfs -R stat <inode> FS

I was curious as to when I wrote a particular time-saving script, so I figured I would look up the file creation time:

$ stat ~/scripts/goprofootage.sh
 File: /home/robert/scripts/goprofootage.sh
  Size: 1001            Blocks: 8          IO Block: 4096   regular file
Device: fe01h/65025d    Inode: 792618      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: ( 1000/  robert)   Gid: ( 1000/  robert)
Access: 2018-01-07 08:23:04.816666962 +0000
Modify: 2017-05-13 19:09:30.760094062 +0100
Change: 2017-05-13 19:09:30.760094062 +0100                        
 Birth: -

Err, well. No birth date? ext4 does support file creation timestamps, so it’s just a simple matter of getting at them.

Enter debugfs, part of e2fsprogs (at least on this Arch install). We can stat an inode to get a creation time:


$ stat -c %i ~/scripts/goprofootage.sh
792618
# debugfs -R 'stat <792618>'  /dev/mapper/840ssd-home
debugfs 1.43.7 (16-Oct-2017)
Inode: 792618   Type: regular    Mode:  0755   Flags: 0x80000
Generation: 3863725318    Version: 0x00000000:00000001
User:  1000   Group:  1000   Project:     0   Size: 1001
File ACL: 0    Directory ACL: 0
Links: 1   Blockcount: 8
Fragment:  Address: 0    Number: 0    Size: 0
 ctime: 0x59174bda:b53875b8 -- Sat May 13 19:09:30 2017
 atime: 0x5a51d8e8:c2b56548 -- Sun Jan  7 08:23:04 2018
 mtime: 0x59174bda:b53875b8 -- Sat May 13 19:09:30 2017
crtime: 0x58efaf27:2234f628 -- Thu Apr 13 18:02:31 2017
Size of extra inode fields: 32
EXTENTS:
(0):5096134

Or, if you’d rather combine the above into a one-liner (NB needs root):

 # debugfs -R "stat <$(stat -c %i ~/scripts/goprofootage.sh)>"  /dev/mapper/840ssd-home 2>/dev/null  | grep crtime | cut -d ' ' -f4-9
Thu Apr 13 18:02:31 2017

Quick beets import tip

Starting with beets to manage and organise your music library? Read the ‘getting started‘ guide? An additional quick tip:

Import your first few albums individually using

beet import -t $album_directory

The -t flag is for timid(ly).

Why? If you’re like me, you might not be in 100% agreement with how MusicBrainz represents the match metadata; and -t will ask for confirmation which you can either accept ([Enter] or A) or reject (U for ‘Use as-is’).

If the first few matches are fine, you can drop the flag; if not, you can figure out how to finesse it to import files to your liking via beets‘s excellent plugins.

[Fixed] No LED light on Logitech K750 Keyboard

K750 charging under a lamp

tl;dr: Use a combination of a bright light and the reset technique (off ? CAPSLOCK + some keys ? on)

Background

A few years ago while on holiday in sunny SC — a lovely place to visit, incidentally — I took the opportunity to purchase a Logitech K750 keyboard. The K750 was is a ‘solar’ keyboard- no changeable batteries, only solar cells to power it. I had been frustrated by other keyboards which needed battery changes timetabled in accordance with Sod’s Law.

They keyboard got passed on to my folks and all was well. However, since my dad passed away my mum has not used the computer as much, and so the lights in that room haven’t been on. When I went to use the computer there recently the keyboard was completely dead. Not even the red ‘sad face’ LED would light even if held close to a light source, which would normally elicit some response.

Leaving the keyboard in a decent amount of ambient light for a few days seemed to do very little to help.

Revivifying a K750

Enter Nut and his Tech, wherein they describe the reset procedure:

1. Turn off the keyboard.
2. While holding onto CAPS lock, keep pressing a few keys for the next 5 or more seconds.
3. Turn on the keyboard.

I did the above and held the K750 very close to a fairly bright bulb, and the LEDs sprang to life!

First the green happy face when still next to the light, then the red unhappy face when I took it out of full illumination.

So it works, for now. I was even able to type from the next room over where it sits charging beneath a mini anglepoise-type lamp.