Some posts have ‘Continue Reading …’

They shouldn’t though. I couldn’t figure it out at all. Why should posts, mostly from the older pages, suddenly start showing the Continue Reading link. Here’s an example:

Continue reading

There are lots of posts like this. All in the later pages. I’ve checked the theme settings and it’s fine. The next obvious thing was the blocks or raw HTML itself to see if there was some sneakily embedded tag that was causing mischief. Nope. All looks fine.

I finally found the problem. White space in the excerpt widget. Easily resolved by deleting it. But why? How has this happened? And it looks like it’s always the same amount of whitespace. In the screenshot below you can see the highlighted whitespace just before deletion.

It’s annoying, and what’s also annoying, is whether it’s going to happen again. I’m wondering whether a recent update caused this but I can’t think why it should.

Mysterious whitespace appearing in the excerpt widget

By copying the whitespace and pasting it into vi, then saving and running od on it I get:

dougie@office:~$ od -c temp
0000000 \n \t \t \t \t \t \t \n
0000010

I’m not sure how meaningful that is, but if it’s accurate it looks like that, for whatever reason, lots of my posts have acquired a newline, 6 tabs, and a newline. I wonder why.

the tacx tyre and the Saris M2

Tacx trainer tyre

So there I was, plodding up some pass in the Czech republic, slogging steadily through the middle of a Rouvy server, minding my own business, when BANG! A mechanical! On a smart trainer. A blowout.

I hopped off my bike and moved to the side of the road. Fished out the tyre levers, which had conveniently appeared on a nearby workbench, and had a look at the problem.

Tacx trainer tyre – exhibit A
Tacx trainer tyre – Exhibit B

I have my doubts about the Saris M2. I miss my Tacx Vortex. It’s a pity that it fizzed and sparkled when I tried to fix it. It’s pretty much unfixable now. It’s now a perfectly functioning not-smart trainer though. The Saris M2, with its scary clutch knob, makes me nervous. So much tyre squashing involved.

Moving to a dedicated trainer tyre was definitely a good move. It’s quieter and smoother. Not sure about the battery life though. Is it connected to the trainer? Is it a co-incidence that since changing to the Saris M2 that the cracks have begun to show in my trainer tyre?

On the surface of things I certainly seemed to have a smoking gun. But I’m a bit puzzled. Admittedly the tyre is not looking its best, but I was surprised it had resulted in such a rowdy blowout. I decided that it was just a fluke, and the tyre had a bit of life in it yet.

Tacx trainer tyre

I wasn’t wrong. There was some life yet. Another 12 minutes to be precise. Then there was another loud bang, not dissimilar to the first one. Luckily I had another nearly new tacx trainer tyre, I just had to find it. I was nearly at the top of the pass too. Annoying.

The new tyre is on, and today I managed to complete the ride without a mechanical. But I’m really, really not sure about the Saris M2. Surely a tyre was never designed to be quite so squashy …

Tacx trainer tyre

algorithms

It’s a long time since I did my A levels. Actually, I never did A levels, I did Highers, but they were almost as good, or better, depending on which side of the Who Cares fence you sit. But algorithms are implicated. Great things algorithms, when they work. Sometimes they don’t.

I’ve been using Teamviewer for years. In a personal capacity. Very personal in fact. Pretty much tautologically selfishly. Friends and Family don’t even come into the frame – it’s pretty much me me me. Or, me and the PC in the garage.

My case use, pretty much my sole case use for the last year or two, is to use one of the PCs in my house, to connect to the PC in my garage. I have a Linux PC, and a Windows PC, and I’ll use one of them (usually the Linux one) to connect to the Windows PC in the garage.

Why? Two reasons. 1. to do the massive upgrades that Microsoft lob into the universe at occasional intervals, and 2. to download videos for Rouvy rides that I take a fancy to. It’s not great when Microsoft decide that your Windows 10 PC wants to do an upgrade, and it’s gotta do it NOW, just when you’re settling into the little cog for a slog up some pretty alpine pass.

My Rouvy rides were getting a bit jumpy, and I realised that garage PC just wasn’t cutting the mustard. Cutting the mustard? Where does that come from …

Hmmm, well I’m not sure I’m any the wiser, but my garage PC, imaginatively named garage, was at the bottom end of the spec for Rouvy. But the spec of my office PC, in my house, was a bit better. With the addition of a bit of memory and a budget graphics card it would be a better fit.

So, long story short, I swapped things round. The Office PC went in the garage, and the dusty garage PC came in the office. And all was well. My Rouvy cycle rides along canal paths and up alpine passes did not get easier, but they did not get easier with a better frame rate.

This hasn’t gone down well with Teamviewer. It starts simply enough. Rather than walk down the stairs, go out the back door, unlock the garage, check the PC for updates/downloads, it’s easier to fire up Teamviewer.

And then the problems begin …

COMMERCIAL USE DETECTED

If you click on More info you get taken to a Teamviewer page where you can explain yourself. I thought, why not. It’s not unreasonable. I wasn’t too chuffed tbh. There was the presumption of guilt. Hints of Capita TVL about the tone. Capita TVL are an organisation that combines incompetence, dishonesty, bullying and cowardice in one easily manageable package, and every year they get the contract to collect the BBC licence fee. It’s what Capita do. Make money out of misery. And blame their own data for the fact that their own data is bad, and somehow make out that it’s someone else’s fault that they’re really bad at what they do. They’re pretty nasty.

But surely Teamviewer aren’t the same as Capita? Surely Teamviewer are quite good with data? I filled in the form, explaining that, it was just me, in my house, connecting to my PC, in my garage. Sorry, but I wasn’t even helping out friends or family. Surely personal use doesn’t get much more personal than that?

Apparently not.

Teamviewer say that it can take a while to respond to their online form. Specifically:

We are aiming to solve all requests within seven days. Please note that we will attend to every request. Sending multiple requests will prolong the process.

https://www.teamviewer.com/en/support/commercial-use-suspected/

So I was a bit surprised when my response came through just a few hours after submitting my form. Almost as if it were, I dunno, automatic, or processed by some algorithm, rather than looked at by sentient entity.

Unable to Confirm the Situation

No matter. There are other ways. I could, for example, get off my arse and go downstairs, outside, unlock the garage, and check for updates. Do me good. Or I could use one of the many free remote desktop utilities available for Linux which would do all I need. All is well.

Horizontal Scrollbars

Are a thing. Quite a big thing. I like to keep an eye on ideas about good practice for presenting information on the web. I still haven’t got my head round the alt tag for images – where and how to use the alternative text and image title attributes for instance. And is opening an image in a separate tab good or bad? And how much do I care?

At the moment I’m using the twentysixteen theme. I quite like it. Nice and simple. Recently I wanted to paste a bit of code so I selected Code Block in the Gutenberg editor. It looked terrible. A sort of unwrapped inverse video that I found not very clear to read.

So I tried it with the preformatted block option. I think it looks better. Cleaner, and with a border. But the code I pasted was wrapped, and I find that difficult to read.

But is it just me? I started searching for how to add a horizontal scrollbar to the code or preformatted block and found it a muddy field. First discovery I made was that this behaviour seemed to be particular to the twenty sixteen theme; the other themes I tried defaulted to horizontal scrolling.

And I seemed to be in a minority in liking horizontal scrolling. All the search results were for people trying to work out how to disable horizontal scrolling, whereas I seemed alone in wishing to find out how to enable it. I’m intrigued to find that on the whole it seems people don’t like horizontal scrollbars in code windows.

But I like it so I tried to work out how to enable it. I think I’ve sorta managed it but whether it’s right I’m not sure. Seems to work. I used the Inspect facility of Firefox to prod and poke and try a few things, then I added:

.wp-block-preformatted {
    white-space: pre;
    overflow-wrap: normal;
}

and

.wp-block-code {
    white-space: pre;
    overflow-wrap: normal;
}

to the Additional CSS section of my theme customisation.

That seemed to work so I went hunting for the settings. I’m using a child-theme and I quite like to know where things live. I looked for recently changed files but there were no likely culprits. I was a bit puzzled so back to the internet, and I discover that these customisations are saved in the database itself. I’m not sure why, but I wasn’t keen on this. I’d prefer it if they were there, in green and black in a text file that I could see.

So I’ve removed the code from my Additional CSS bit, and put it in style.css in my child-theme directory, and it still seems to work.

I do like the way other themes do it though. I think the styling is nicer in twentytwenty but I don’t like the way it displays categories and tags in block capitals. Maybe I’ll tinker in that direction somewhere down the line.

PSU fickleness of Raspberry Pi

I’m not kind to my raspberry pi’s. I have a few, of varying pedigrees, tucked away in the attic or other inhospitable dusty places. A week ago, the imaginatively named pi2 went offline. Irritatingly, it takes the podium of my most inhospitable rpi, tucked in the attic, balanced on a rafter, in a tight spot an uncomfortably long crawl away from the hatch.

Still. Gotta be done. I’d tried switching it off and on again. Many times. That was easy enough, and can be done from a distance. Likewise, I cycled power on its network switch a few times too. I rarely go the wifi route unless it’s unavoidable. I mean, if you can get a power cable to it, it’s usually possible to get a bit of cat5 there too.

No joy. So I brought it down, blew out the dust, and plugged it in again using a spare PSU in my study. Nothing. Except a high pitch whine coming from the, well, where was it coming from? The PSU? The rpi? Yep, definitely the pi.

I’ve never skimped on PSUs for the rpi. I’ve never much understood them either. Opting usually for the recommended product rather than skimping on a cheaper option. Although buying anything branded on Amazon nowadays is a bit of a gamble. What you see in the nice picture is not always, or even often, what you get.

Still, here’s the situation. The rpi is a, er, well, what is it? It’s back up the loft, far away in dustville, but, according to the University of Google, it’s:

root@pi2-driveway:~# cat /proc/device-tree/model
Raspberry Pi 2 Model B Rev 1.1

… and the PSU that it had been happily running on since it was sent up the attic, was:

NorthPanda Model LA-520WF

In the study I plugged it in to a spare rpi PSU, an old RS favourite. And that’s where I heard the high-pitched whine …

I was assuming the rpi was goosed but had a final visit to the University of Google, and, even though the noise was definitely coming from the rpi itself, and not the PSU, I tried one more time with a different PSU.

AAA Products MUSB2A PSU

I’m not sure when or where I bought this. According to my Amazon order history I bought this item on the 6 aug 2017 for an anker bluetooth speaker. I’m guessing that whatever it was once bought for is now jammed in a power bank, and the PSU was no longer required, until now. I’m glad I hung on to it though, because it fired up the rpi fine, and it’s back up the loft.

Another layer of security for WordPress

A simple way of deflecting brute-force attacks is to require an additional password to access the WordPress login screen. Lots of security plugins will do this for you, but again, sometimes it’s better to DIY.

I put a .htaccess file in the wp-admin directory and that almost completely worked, but mystifyingly, and irritatingly, there would be regular failed login attempts. Not very often. About very 20 minutes or so. But I was irked (I tell you), as I couldn’t work out why they were happening.

My .htaccess file looked a bit like this:

<RequireAll>
AuthName "my site"
AuthType Basic
AuthUserFile <myauthfile>
Require valid-user
</RequireAll>

A few searches made references to differences between apache 2.2 and 2.4, and I thought that perhaps it was a syntax thing. But that didn’t seem to be it.

I did two things in the end, so I’m not sure what fixed it.

  1. I modified the .htaccess entry to specifically reference the file wp-login.php.
  2. I moved the .htaccess file to the parent directory.

So the relevant code looks something like:

<FilesMatch "wp-login.php">
AuthType Basic
AuthName "Secret stuff"
AuthUserFile <my auth file>
Require valid-user
</FilesMatch>

Disable xmlrpc.php

Thanks to the Simple History plugin, the first thing I noticed on my new WordPress install was hundreds of brute-force login attempts:

Anonymous user from x.x.x.x 4:25 pm (less than a minute ago)              Failed to login with         username "dougie" (incorrect password entered) warning       Showing 212 more     

And then more alarmingly, immediately the same thing on a new test user I set up a few minutes later. Of course, just because frustratingly I can’t work out how the attacker extracts the new WP username immediately doesn’t mean it ain’t happening. But the attack vector, so to speak, was the xmlrpc.php file.

Several ways to tackle this, and initially I used a security plugin to fix it. But given the choice, I’d rather do things like this manually so I have a better idea what’s going on, and maybe learn something too.

I pasted the code suggested from https://www.hostinger.com/tutorials/xmlrpc-wordpress into my .htaccess file:

    # Block WordPress xmlrpc.php requests
    <Files xmlrpc.php>
    order deny,allow
    deny from all
    allow from xxx.xxx.xxx.xxx
    </Files>

changing the allow from to the static IP for my regular connection, although strictly speaking I don’t think I need that and will try taking it out altogether sometime.

Publishing failed – JSON error

Migrating WP blog to my VM. New install of WordPress. Test posts with Guttenberg (Block) Editor. Following error:

Publishing failed. Error message: The response is not a valid JSON response.
Publishing failed. Error message: The response is not a valid JSON response.

An interesting rabbit hole. Lots of searches rightly suggested that using the classic editor would get round the problem. Or that by changing the permalinks settings to Plain would fix it. It did, but not much help if you want your permalink settings set to something else.

Eventually I discovered that the issue for me was with the .htaccess file not being processed, which was fixed by adding something along the lines of

<Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

to the /etc/apache2/apache2.conf file (on Debian Buster). This worked for me, but I get the impression it’s better practice to edit the files in /etc/apache2/sites-available instead for any local code in case apache2.conf gets overwritten on an upgrade. Probably also need to do a:

a2enmod rewrite
systemctl restart apache2

So for me the cause of the error message was quite obscure. Useful link:

Findster Duo – First Impressions

Cats are a worry. On the one hand we want to let them come and go as they please so they can go out, play, chase mice, climb trees, and be cats. The trouble is, they go out, play, chase mice, climb trees, and get into all sorts of scrapes. Being cats.

The real worry is not seeing them for days on end though. Brothers Willow and Mr Mittens like the summer. In the summertime, when the weather is fine, they go and talk to the students, pretending to be unloved and unfed. It’s only by putting webcams on their feeding bowls and bed that we realised they still lived with us.

On a recent holiday we left the cats at home with a homesitter as normal. But on four separate days we had phone calls from Chapel Heights, from alarmed students who’d found Willow mooching around their flats. As the crow flies Chapel Heights is only a few hundred metres from our house, but it’s near a busy dual carriageway and Willow doesn’t have any road sense.

I’ve tried a tech approach. Tile works ok. But its range is short and its use is limited. So now I’m trying another tech approach.

You’d think there’d be tons of tech for monitoring your pets. And there is, but it’s still a maturing market and there’s a long way to go. Trackers for dogs seem a lot more common than those for cats, which makes a lot of sense. The devices are still quite bulky and cats a quite small.

Half an hour ago I attached a Findster Duo to Willow’s collar. It’s light, but bulky, but he seems ok with it. I took it off its supplied strap and threaded Willows collar onto it directly. Let’s see how it goes.

Willow trying out the Findster Duo
Willow unimpressed by the big Findster Duo

Permissions on /dev/video0 running motion on Raspberry pi

[ Update: 1 July 2020 ]

I can’t say my blog sees a lot of action or sets the world on fire. That’s the way I like it. But, and I’m not saying it keeps me awake at nights, this blog post regularly sees a lot of hits. It’s about 4 years old now, and in raspberry pi times, that’s a long time. I can’t recall having had this problem for ages, and on all my new-builds it seems to have just, gone away. I still have issues with the rpi deciding on its device file, and I still don’t understand them, but I’ll get around to that one day …

Wisdom of the ancients

Post from Feb 2017

It pretty much happens that every time I setup motion on a new build that it doesn’t work right away. There’s usually a few things I miss. Usually it’s an error reading from the camera, the logs reporting something like:

Feb 17 10:51:21 pi2 motion: [1] [NTC] [ALL] motion_init: Thread 1 started , motion detection Enabled
Feb 17 10:51:21 pi2 motion: [1] [NTC] [VID] vid_v4lx_start: Using videodevice /dev/video0 and input -1
Feb 17 10:51:21 pi2 motion: [1] [ALR] [VID] vid_v4lx_start: Failed to open video device /dev/video0:

which invariably means the camera is broken or I’ve misconfigured my motion setup.

This one was puzzling me a little though. It’s on a raspberry pi, imaginatively titled pi2, and it was failing to read from the camera. The reason I was puzzled was that the hardware combination had worked before. What had gone wrong was the micro-SD card, and I’d done a new raspbian build, copying over the relevant motion configuration files from the old card.

Clearly the difference had to be something to do with the OS. So what was different? I’d taken the opportunity of the SD failure to download and install the latest version of raspbian and everything looked good to go.

Running motion as root worked fine, both against the vanilla configuration file, and the customised config file I wanted to use. So let’s have a look at the video file:

root@pi2:~# ls -l /dev/video0
crw-rw----+ 1 root video 81, 0 Feb 17 11:17 /dev/video0

Looks about right. Ah, the video group. I need to be in the video group. That might be it:

root@pi2:~# usermod -G video dougie

Restart motion and try again. Nope. Let’s have a closer look at that file.

On pi2 (with a new version of raspbian):

crw-rw----+ 1 root video 81, 0 Feb 17 11:17 /dev/video0

and on pi1 (another rpi, running motion fine, with a slightly older version of raspbian):

dougie@pi1:~ $ ls -l /dev/video0
crw-rw---- 1 root video 81, 0 Jan 8 22:54 /dev/video0

Very similar, but not identical. The newer version of the device file has and extra + at the end of the permissions bit, which means the file has extra security permissions set. I’ve not had cause to use Access Control Lists (ACLs) before, and it was a temptation just to chmod 777 on the file as a quick and dirty, and lazy, fix, but I thought it’d be better to take a closer look. Using the getfacl command:

root@pi2:~# getfacl /dev/video0
getfacl: Removing leading '/' from absolute path names
# file: dev/video0
# owner: root
# group: video
user::rw-
user:pi:rw-
group::rw-
mask::rw-
other::---

I could see that I (me: dougie) did not appear on the list, although the default rpi user pi does. I rarely use the pi account. One of the first things I do is change its password, create my own user, and use that instead. So it looks like the default install for raspbian allows user pi to access /dev/video0. It also looks like I can’t access the file, despite being a member of the group video.

I found a good command summary on the (now a dead link) centos documentation website, and using that gave myself access:

root@pi2:~# setfacl -m u:dougie:rw /dev/video0

That did the trick.