Author Archives: Alex Forbes

Compressing a PDF file on macOS

Sometimes people create PDF files with large images, resulting in files that are too large to email or sometimes even upload on web forms.

A quick and dirty way to compress such files is using ghostscript in a terminal, which you can install on macOS using homebrew (brew install ghostscript):

gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dPDFSETTINGS=/screen -dEmbedAllFonts=true -dSubsetFonts=true -dColorImageDownsampleType=/Bicubic -dColorImageResolution=192 -dGrayImageDownsampleType=/Bicubic -dGrayImageResolution=144 -dMonoImageDownsampleType=/Bicubic -dMonoImageResolution=144 -sOutputFile="${1%.*}.compressed.pdf" myfile.pdf

Replace “myfile.pdf” with the file to compress.

For convenience, you can create a function:

pdfc() {
  command gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dPDFSETTINGS=/screen -dEmbedAllFonts=true -dSubsetFonts=true -dColorImageDownsampleType=/Bicubic -dColorImageResolution=192 -dGrayImageDownsampleType=/Bicubic -dGrayImageResolution=144 -dMonoImageDownsampleType=/Bicubic -dMonoImageResolution=144 -sOutputFile="${1%.*}.compressed.pdf" "$1"
}

Use like so:

pdfc myfile.pdf

And a smaller pdf file will be written to myfile.compressed.pdf.

This isn’t without cost. The resulting PDF file will contain lower resolution images which have less detail and will look worse zoomed in, but you can tweak the resolution settings to see what works for you. Generally I find the above settings acceptable for most documents at normal reading size. It will reduce a file with 3 large images captured with a phone from 6Mb to around 100Kb.

Samba config for Apple Time Machine

I’ve been using samba’s vfs_fruit module to enable backing up my mac laptop to my ubuntu-based NAS. I’ve found the configuration fiddly, and it occasionally breaks with macOS upgrades.

Anyway, I thought I would document my settings in case it helps anyone else out there. The file system backing my Time Machine share is ZFS, and I am using Samba 4.15 and MacOS Sonoma 14.4.1.

Global config

In /etc/samba/smb.conf under the [global] section, I have the following (not complete config, just the relevant settings):

protocol=SMB3
vfs objects = acl_xattr fruit streams_xattr aio_pthread
fruit:aapl = yes
fruit:model = MacSamba
fruit:posix_rename = yes
fruit:metadata = stream
fruit:nfs_aces = no
recycle:keeptree = no
oplocks = yes
locking = yes

Some comments:

  • I believe SMB3 is required – Time Machine struggles with older protocols.
  • The order of vfs objects is important – aio_pthread must go last.
  • Without aio_pthread, my backups fail while scanning. I suspect Time Machine is heavily threaded and does a lot of requests in parallel – apparently too much for a single samba thread.
  • fruit:posix_rename = yes appears to be the default and can probably be omitted
  • fruit:metadata = stream was a copy-paste and not thought through by me – I’m unsure of the implications of this

These work for me as a general set of settings for mac clients – I don’t use Windows or Linux clients often, so I don’t know how well it works for them. It’s possible some of these options are not required, as they’ve accumulated over time.

Share Config

The share itself is configured like so:

[TimeMachine NAS]
path=/pool1/backup/timemachine
comment=Time Machine
valid users = alex
writable = yes
durable handles = yes
kernel oplocks = no
kernel share modes = no
posix locking = no
ea support = yes
browseable = yes
read only = no
inherit acls = yes
fruit:time machine = yes

According to the docs, “fruit:time machine = yes” sets durable handles, kernel oplocks, kernel share modes and posix locking – you can probably omit these.

/pool1/backup/timemachine is a ZFS volume with a quota, which was set with “zfs set quota=3TB pool1/backup“. The available space is reported correctly to the client (Finder), so I’d expect it to work fine for restricting disk usage, and for time machine to manage its snapshots.

See also

ZFS compression and encryption

Up until a recent overhaul, I was using btrfs in raid1 to manage the 4 drives I had in my NAS. However it’s been clear for a while that the momentum is behind zfs. It has more features, better stability, and generally inspires much more confidence when things go wrong. btrfs still has its place in managing single-device boot volumes, but for multiple physical devices, I would definitely recommend zfs over btrfs.

When I added a couple of new 16TB disks, I opted to create a new pool with a single mirror vdev. If I need to expand it in future, I’ll add another mirrored vdev to the pool.

Continue reading

Auto-focusing a Canon EF 135mm f/2L with the Sigma MC-21 on a Panasonic S5 II

When I searched myself before getting the Sigma MC-21 EF adapter I didn’t find much information on using this particular combination, so I thought I’d report my findings. This is not a scientific test, just my impressions after using it for a while, and comparing it subjectively to a 5D mark IV. I’ve also tried it out on the original S5.

In short – it works fairly well in photo mode on the S5 II, but not as quickly as a 5D, and you should use continuous AF mode to avoid contrast-detect AF. It is basically unusable on the original S5 and thus the S1, S1H and all micro four thirds models older than the G9 mark II.

For video I wouldn’t consider it usable outside of a controlled environment – it’s too noisy and slow, and I couldn’t get it to work as well as it does in photo mode with continuous AF (C-AF).

Continue reading

Vaccine Scepticism is stupid, but not for the reason you might think

Recently I was sent a video by a certain Dr John Campbell titled “Immunology of mRNA vaccines”, which I won’t link to here, but it essentially casts doubt about the safety of mRNA vaccines with no evidence or sources whatsoever. In a discussion with a fellow retired crank named Robert Campbell, he leaps to unlikely conclusions from official statistic, misrepresents the effectiveness of the vaccines at preventing disease, invokes broader concern about genetic science, ignores the overwhelming evidence of effectiveness, and fails to see wood for trees.

In this post, I want to talk briefly about the vaccine scepticism industry, of which Dr Campbell is a part, as he is evidently profiting from it.

Continue reading

Home Server – new HBA edition

Some long time readers of this blog may remember my home server articles, the most recent being “Ubuntu Home Server 14.04 – A DIY NAS“. There haven’t been any more recently because there’s not been much to report. The server described in that article, built in 2014, has been backbone of my home network ever since.

Since then, I have swapped out hard drives a couple of times (it now contains 2x16TB Seagate Exos and 4x4TB Seagate IronWolf), doubled the ram to 8GB, and added a NVME riser card (along with a cheap 128GB NVME SSD), so I could have a separate boot drive while using all 6 SATA ports for hard drives.

Along the way it also lost HTPC and media player duties to an Apple TV, so now it’s little more than a file and backup server with Plex Media Server, Syncthing, and Duplicati installed. And the operating system has been upgraded from Ubuntu 14.04 to 16.04, 18.04, 20.04 and now 22.04.

A couple of weeks ago though, it failed. And by failed I mean, all I got was blank screen when powering on. No post, and no signs of life other than spinning fans.

My immediate thought was a loose connector, or possibly memory or motherboard failure, so I disconnected everything, blew the dust out and plugged everything back in. With the hard drives unplugged, everything worked. With 4 hard drives plugged in it still worked. Then it failed again when I connected the last two.

By now I figure I’m looking at a dodgy SATA cable, SATA port, or hard drive, but the core components are obviously fine. So why not give it a minor overhaul at the same time?

Continue reading

Age vs Crypto

1. Anything that is in the world when you’re born is normal and ordinary and is just a natural part of the way the world works.
2. Anything that’s invented between when you’re fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it.
3. Anything invented after you’re thirty-five is against the natural order of things.”

Douglas Adams, The Salmon of Doubt

It’s commonly known that younger generations tend to be more enthusiastic adopters of new technology. It’s easy to see why – younger people are more hungry to learn, are still forming habits, and have more to gain (and less to lose) from technological revolution.

So it’s worth casting my own resistance to crypto through this lens. I have always been an enthusiastic adopter of the internet and technology, and that attitude has served me very well; I owe my livelihood to it. It would be easy for me to jump on the Web3 bandwagon and go all-in on crypto.

Or would it?

Continue reading

Essential Reading on Crypto

Since penning a post on the libertarian ideology of Bitcoin, and the inherent unfairness of a deflationary currency (Bitcoin is the thin end of a far-right libertarian wedge), I’ve come across more articles on the subject that articulate the problems with crypto-currencies far better than I every could.

First up, the Folding Ideas video Line Goes Up – The Problem With NFTs, is a must-watch for anyone remotely interested in the space, or considering an investment in any form of crypto. Despite the headline being NFTs (you thought crypto-currency was bad? wait till you see this dumpster fire), it goes fairly deep into crypto-currencies and blockchains in general. At 2 hours and 18 minutes, it’s a very long video by YouTube standards, but the presentation is excellent, the research solid, and it never drags. Since it was posted 5 days ago, it has racked up 2 million views, so it’s certainly having an impact.

If two hours is too long though, I strongly recommend reading The Case Against Crypto, by software developer Stephen Diel. He nicely summarises the anti-crypto argument under 4 headings:

Continue reading

Keybase – sadly it’s time to jump ship

Because the captains did a while ago.

Exhibit A – the github activity graph for the keybase client:

Development basically ceased in 2020 when the team joined Zoom.

This means no further improvements, including support for Apple Silicon.

This was a skills acquisition for Zoom no doubt – they needed the talent after they were taken to task over the state of their security before the pandemic. I’m sure the Keybase team has made a huge contribution to their product. But I highly doubt they have any commercial interest in continuing the Keybase project.

I’ll miss the encrypted git feature. And the Stellar Lumen giveaway was neat. But every problem it solved for me is easily solved with other tools today.

Au revoir.

A Brief Review of Beer52

Our company uses Perkbox as an employee benefits program. It has some nice freebies, but on the whole I find it’s mostly marketing – I.E. “benefits” that make little sense except as paid promotions.

So while I was happy to see a “get a case of craft beers delivered free” as one of the employee perks, I was fairly skeptical going in…

Free beer! Sounds good right!

The catch is that you have to sign up to monthly deliveries from Beer52 which are very much not free. Not free, to the tune of £24 per month. And that’s a pretty price to pay for 8 beers.

Perkbox’s take on how it works

I didn’t want to be “that guy” who just orders the free case and cancels, so I decided to let it run for another month and cancel after. But of course I ended up letting it run for about 5 months, because, hey, it’s beer! But when I did decide to cancel, I found a cancellation process designed to be as sticky as possible.

Firstly – you can’t cancel until the first box is delivered. OK, fair enough I guess.

Secondly – you can’t cancel online. You can do everything else – order beer, pause your subscription for a month, switch to 2-monthly deliveries, update payment details, all the usual stuff. Except cancel, of course.

Nope, to cancel you have to phone them up, sit in the hold queue (it took 15 mins for me), answer a question on why you want to leave, listen to two offers (I was offered an £8 discount on the next box in exchange for not cancelling), and only then will they cancel your subscription for you.

In doing so they hope you’ll carry on paying £24/month after the discounted one, just like you did after the free one.

Getting the most out of it

Sign up with a “free case” code. Log in. Switch to 2 or 3-monthly deliveries. Skip the next one. All this can be done online as soon as you’re signed up.

That way you won’t be automatically paying for a case for about 3 months, which is plenty of time to cancel if you just want the free box. And if you want more, you can order an extra case at any time, which is better than having it sprung on you when you don’t.

Making customers phone to cancel is asshole design

There is no reason for it, other than customer retention. Retention, of customers that would rather not spend their money on your product.

Don’t feel bad about canceling after the free case.