Posted on November 8th, 2022 by whinger. Filed under Uncategorized.

So Mastodon is a thing. Whether it continues to be one remains to be seen.


gzip with sparse output

Posted on February 13th, 2021 by whinger. Filed under Uncategorized.

So I was looking to access some old disk images that I had gzipped, and I knew the original disk was fairly large and I didn’t particularly want that space used up; I was surprised to discover that gzip doesn’t support output to sparse files.

The solution is fairly simple: output to stdout and pipe it to dd with conv=sparse:

gzip -dc myimage.gz | dd of=mysparseimage bs=10240 conv=sparse

Choose a blocksize value that makes sense based on what you know about the expected size of the empty blocks, since (I believe) dd will only create sparse holes if the whole block is empty.


ATV1200 serial console pins

Posted on June 13th, 2020 by whinger. Filed under Uncategorized.

For anyone trying to find out which pins are which on the J21 serial connector on the Geniatech (or mygica) ATV1200 TV box (also sold as a Sumvision Cyclone x2, among others), pin3 is TX, pin2 is GND, pin1 is RX and pin4 is Vcc. 3.3v, 115200 baud.


one-liner: change binary constants in C source file to hex

Posted on January 28th, 2020 by whinger. Filed under Uncategorized.

If you have an old C compiler that won’t work with binary constants like 0b10101010 you’ll end up with a fatal compile error:

invalid suffix “b10101010” on integer constant


grep -l '\b0b[01][01]' . -r | while read f; do perl -np -e 's/\b0b([01]+)/sprintf("0x%X\/*%s*\/", oct("0b$1"), $1)/eg' < $f > $ && mv $ $f; done

This replaces all binary values with hex equivalents, with the binary value in C comments after.

This will fail if you have binary values inside /* comments */; you can remove the comment value from the replacement string if you prefer:

grep -l '\b0b[01][01]' . -r | while read f; do perl -np -e 's/\b0b([01]+)/sprintf("0x%X", oct("0b$1"))/eg' < $f > $ && mv $ $f; done


Why a Labour 12/12 win might actually be the worst long-term outcome for remainers

Posted on October 31st, 2019 by whinger. Filed under Uncategorized.

I’m wary of posting this blog. There’s a lot of people who really won’t like it. But I think it needs saying. It’s a crystallisation of arguments I’ve been having on Twitter for a while, mainly with people who either can’t understand or won’t. I expect most of them will have much the same reaction to me here, which will be to either put me down as (at various points) a fantasist, an idealist, simply an idiot or even (on one particularly memorable occasion) a closet no-dealer.

I don’t generally post political blogs: I don’t usually have much to say that someone else isn’t saying better than I could. No-one seems to be saying this though. Possibly because it’s toxic. Possibly because it will upset people who need to stay onside for now. Possibly because the truth is too painful to admit. Or possibly because I’m wrong I suppose. It has been known.

Either way, this blog is just a way for me to explain to myself, as much as to anyone else, the reasons why I’ve surprised myself by being quite so belligerent about this. Ordinarily I’m all for tactical voting but it feels wrong this time.

There’s a lot of discussion just now about how we remainers must all vote tactically to ensure the Tories are kicked out on 12/12. There are several websites popping up purporting to tell you the best anti-Tory vote for a given constituency. Some of them even agree with each other. But ignoring that, the generally accepted view has become that a Labour government (or a Labour-dominated minority government) will save us from a damaging Tory Brexit, and that even though Corbyn wants his “jobs-first” Brexit (a contradiction in terms if ever there was one) Labour has finally committed to a referendum on their deal (a “people’s vote”, as we’re told to call it by the “grassroots” organisation that isn’t), so (since current polling shows a healthy lead for remain) that’s our least worst option.

It’s not. If anything it could be, at least in the long term, the worst option of all for anyone who values membership of the EU.


There, it’s out of the way. Yes, I really do think that a Corbyn-negotiated Brexit is the worst of all worlds.

Now some of you will have dismissed me as a Corbyn-hater (I’m not) or a Tory (even less so). If so, this article isn’t aimed at you. Feel free to dismiss my views as crackpot centrist nonsense from a Blairite traitor and go back to reading The Canary or Skwawkbox or The Morning Star or whatever. I stand no chance of persuading you that the sky is blue, forgetting anything more contentious.

For those of you still with me, let me go into this more detail.

For a remainer, any Brexit is abhorrent. Some of us pretend that we would have been happy with EFTA but in reality we would have accepted it through gritted teeth. We want our freedom of movement. We want our friends (and for some our families) who have lived here for a generation or more to stay and feel as welcome as they always have.

Brexit destroys our partnerships, puts our relationships with our trading allies at risk and places us at the mercy of the larger powers while we attempt to negotiate trade deals in a world which is showing itself more and more partisan with each news cycle.

As a remainer my end goal must be to remain in the EU. Failing that, if the unimaginable happens, it must be to rejoin, and as quickly as possible because the longer we are out the further from the EU we will become, both legally and politically.

Assuming you agree, let’s look at the options.

Corbyn is planning (assuming the patience of the EU27 holds) on tearing up the negotiation May’s team did to achieve the WA and starting again with some new red lines: a customs union, single market access, an end to freedom of movement.

Ignoring for argument’s sake that the EU27 could legitimately turn around and point out that single market access (whatever that is) is the subject of the forthcoming trade agreement, not anything to do with the withdrawal agreement (which must be signed off first) and assuming that Corbyn does manage to pull off the impossible task and present us with a deal that closely represents what he’s promising, we’ll then have a people’s vote: deal or repeal if you like, or more correctly withdrawal-agreement or revoke-article-50.

That’s the good bit, say our remainer strategists, because we will definitely win a second referendum: all the polls say so.

Now I’m not one of these people who go “polls have been wrong, look at 2010/2015/2017/1992/the Pop Idol final”. Yes, ok, everyone thought Gareth would win. But I tend to believe that in general and if you take an unbiased long view of multiple polls on behalf of different sides you can get a pretty strong view of a likely result.

No, my problem with the Labour-second-reffers is that they’re missing the point. Remain has a healthy lead at the moment precisely because Johnson’s deal is so diabolically bad that even an idiot can see we should reject it. And when faced with the bad-deal-or-no-deal choice most people are sensibly picking the third option – remain.

But if Lexit is negotiated, with the customs union but no single market (and bear in mind that survey results like these suggest the vast majority don’t understand what they are) I reckon those numbers wouldn’t look nearly so healthy.

Worse still, if Saint Jeremy gets his way at the emergency meeting of the NEC or whoever it is that gets to decide and Labour end up campaigning for the deal in the second ref, we might as well pack up and go home, because we lose a good 10-20% of remain voters in that one action. Because Some People Really Trust Corbyn.

Then the final nail in the remain coffin: a customs union will be nowhere near as bad as no-deal. That sounds like a good thing but by the time we’ve got through the transition period the chances are we’ll have got onto arguing about whether Jo Swinson should have been out of Strictly after her Samba by the time it comes to even noticing that we’ve left to any great extent. Getting together a fight to rejoin, especially after a 70:30 trouncing in ref2, is going to be a hard and ultimately unrewarding slog.

So what’s my suggestion?

Remainers should be voting for remain parties. It’s as simple as that. 422 of 632 constituencies are now majority remain. If we all have the strength of feeling to back our position, we will win. What will lose us the election is falling prey to the fearmongering of the two major parties who are desperate not to lose their stranglehold on traditional FPTP British politics.

I guess there’s not much chance of this working. Most people will continue to tell me that I don’t understand (I do) or that it’s impossible (it isn’t). It is however highly unlikely and I see that. But I also see that, if you actually want the UK in the EU, handing Corbyn the keys to no 10 is no better (and could be much worse) than another catastrophically poor Tory government.

Tags: .

    Comments Off on Why a Labour 12/12 win might actually be the worst long-term outcome for remainers

undefined reference to gzopen64

Posted on July 9th, 2019 by whinger. Filed under Uncategorized.

So building postgres v11 on an old legacy centos server produced this error:

pg_basebackup.o(.text+0xed0):postgres-11.4-build/../postgresql-11.4/src/bin/pg_basebackup/pg_basebackup.c:1019: undefined reference to `gzopen64

Turned out a new version of zlib had been manually installed in /usr/local and the included zlib.h pointed to the new version (which used gzopen64), while the old version in /usr/lib (and which had no gzopen64 symbol) was being linked. Adding LDFLAGS=-L/usr/local/lib to the configure line was enough to make it build successfully.


rsync error: protocol incompatibility (code 2)

Posted on November 14th, 2018 by whinger. Filed under Tech.

I needed to push a lot of files from a (very) old server (RHEL3) to a newer one (RHEL7). rsync seemed like a smart choice, because I will need to rerun the command to push any updated files at a later date.


Problem is, rsync complains

rsync error: protocol incompatibility (code 2) at compat.c(62)


There are loads of webpages suggesting this is a problem with your .bashrc outputting text when it shouldn’t, but in my case that wasn’t it; turns out rsync rather stupidly uses the latest protocol version without checking to see if both ends will support it. The new version on the target machine was blithely talking a version that the old version wouldn’t run.


Anyway, to cut a long story short, adding


--rsync-path="rsync --protocol=30"


to the rsync command line worked for me.



Loved Love Island? Like silly SMS notifications? I have a file for you…

Posted on September 28th, 2017 by whinger. Filed under Uncategorized.

How to redirect stdout to one pipe and stderr to another in bash or bourne shell

Posted on August 11th, 2017 by whinger. Filed under Tech.

So I couldn’t find an answer to this when I searched for it… how can I redirect stdout to one pipe and stderr to another?

In my head, it seems like you should be able to do

mycommand |stdoutpipecmd 2|stderrpipecmd

but you can’t.

There are many answers knocking around stackexchange that seem to not-quite do what I wanted, plus in bash you can apparently do command-redirection with 2>(stderrpipecmd); however I was using bourne shell (embedded system) so that didn’t help me.


Of course the answer is really ridiculously simple: simply encapsulate the redirect into a subshell, and redirect the stderr of the subshell into stdout and pipe that.


( mycommand | stdoutpipecmd ) 2>&1 | stderrpipecmd

It’s really that simple.


If you want to make the result of stdoutpipecmd not be piped through stderrpipecmd (you probably don’t), you can do


( mycommand | stdoutpipecmd 1>&3 ) 3>&2 2>&1 | stderrpipecmd

which will pipe the output from stdoutpipecmd to stderr, while the output from stderrpipecmd will be on stdout.

To fix that, so the output from stdoutpipecmd ends up back on stdout while the output from stderrpipecmd is on stderr, it gets a bit messier:

( ( mycommand | stdoutpipecmd 1>&3 ) 2>&1 | stderrpipecmd ) 3>&1 1>&2

What fun 🙂

Tags: , , , .

Fritz!Box remote SIP with different auth username

Posted on June 15th, 2016 by whinger. Filed under Uncategorized.

So I was given “username” and “auth username” parameters for my SIP trunking account, and it’s non-obvious where those values go in the fritz UI.

The answer, to save you the trouble of faffing with various possible options, is that the “username” goes in the “*Telephone Number for Registration” field at the top, while the auth username goes in the “Account Information” “User name” field. Make sure you check the “Use Internet telephone number for registration” checkbox too.