2021-09-09

Fixing broken sound without restarting chrom{e,ium}

Yesterday I went to the office to meet most of the members of my team who had joined over the last year. In addition to drinking barista made coffees rather than mine, this means disconnecting my laptop from my monitor and, as it sometimes does, causing my machine to lose sound.

Of course I noticed only this morning when joining a meeting and with no time to lose. Sources all looked good etc but no sound in or out and no amount of switching/reconnecting cables/... helped. 

Usual fix (restart pulseaudio using pulseaudio -k) restored it for the system but then chrome didn't see any input or output device anymore. What I usually do in that case is to restart chrome, however this takes about 5 minutes due to the large number of windows and tabs I have open.

Today I decided to instead investigate more and found that there is a separate process called "Utility: Audio Service" in the UI (Shift+Esc) that you can kill and it fixes the sound by correctly reconnecting to pulseaudio! If you prefer to kill it from the terminal, you want the process with "--utility-sub-type=audio.mojom.AudioService" in the command line.

2021-08-11

On location based pay

There has recently been a lot of articles with titles like "Google plans to slash salaries of staff who refuse to return to desks" and a very common position is that Google could afford the current salary, so it could afford to keep current salaries when people decide to work from a remote location.

This is certainly true, but despite not liking a number of things on current policies, it is hard to disagree with this part as it would be very unfair for other employees based on existing location based strong pay differences.

Imagine you have 10000 employees in city A where there is a strong competition so the average salary is 250k, and 5000 employees in an other office in small city B where the average salary is 50k because life is cheap there and no one pays more than that. Now 100 employees from A decide to work remotely from B.

You now have 100 employees in B paid 250k and 5000 employees also in B, doing the same work, only paid 50k. This is the current situation which is very unfair.

Anyone requesting to work from the office in B has always got a pay cut to align to local salaries, but people working from home have a very different salary based on the office they are attached to but never visit.

How would you feel in colleagues leaving in your neighbourhood where paid multiple times your salary because they started in a better office before moving to your city?

There are two fair ways to solve this: give a pay rise from 50k to 250k to everyone working in B (i.e. not have salaries depend on location anymore) or give a pay cut from 250k to 50k to employees moving to work from B even if they work from a home in B rather than the office in B (people working from home in A would receive 250k).

A few companies were already doing the first one which is great, but most companies go for the second one as they would not be able to justify to the shareholders than they doubled the salaries on average globally so that people can work from their preferred location without taking a pay cut.

2021-05-04

Beware of the bug in the NHS England vaccination booking system

TL;DR: Do not visit the vaccination booking website too soon after getting your first shot. It will cancel the second one and it is then impossible to book only the second one, even on the phone.

Last Thursday I went with my wife to the Business Design Center in Islington, and we got our first shot of the Moderna vaccine.


In the evening I wanted to check the date of our second booking to add it to my calendar but the website told me I had missed my first appointment and needed to book both again. At that time I got an SMS that I had cancelled my second appointment.

I first tried to do book both again as it was the only thing offered, thinking I would be able to use the first one for a second shot and then cancel the second one. However I couldn’t as the next first appointment available was in a month and then there was no availability for a second one so it was not possible to book.


I then tried calling 119 and spent more than 10 minutes explaining the problem several times to a confused operator, however it seems they can not book a second appointment either without the first one. At the end I gave up and they booked me an appointment to a local pharmacy on Wednesday which I don’t need to attend and will be wasted as no one will be able to use it, and one at a (different) vaccination center 12 weeks later, so one week later than originally booked. I asked several times but they couldn’t be sure there would be Moderna...



I tried early to reach out to the support website but I got some standard answer to use 119 if I am struggling to use the website.

I then tried to explain the problem on Twitter after finding the Product manager at @nhsdigital (coronavirus vaccination service). I found out I was not the only one trying to report the problem as two other people mentioned it in the same thread ([1], [2]).


NHSuk account asked me for more information in DM, and I sent them the detailed explanation with the booking numbers and my email address and they transmitted it to “the service team who can look into it” on Friday, I haven’t heard back yet.


Does anyone know someone working on the booking system so that they can fix the bug?


Update: My booking was fixed. The booking on the phone was for AstraZeneca, they deleted it and I could book again at the original place, date and time. However they didn't tell me if the bug was going to be fixed, they just explained that it is as I expected. They hadn't got the record of my attendance yet so the system guessed I had missed it « This error message can be displayed when a dose 1 vaccination has been administered however the central vaccination systems (from which we pull information) have not been updated with this information. »


2021-01-13

BIOS Update

I noticed my new machine does not have /sys/firmware/acpi/tables/BGRT or /sys/firmware/acpi/bgrt so I decided to update the BIOS before looking more into it.

I knew Richard Hughes had been working on firmware updates for many years so I decided to try updating it from Linux. Sadly Asus is still "Evaluating the service" so no automated firmware update for me.

I downloaded the firmware from Asus website and the zip contained a single file named .cap so based on some reading it should be possible to use it, and fwupdate says it can update that firmware:

# fwupdate -l
system-firmware type, {e820d9ce-ff2c-5ce6-8ba1-c0c1c5703f44} version 1046 can be updated to any version above 1045

But when trying it failed with an error "failed: is not valid format", and verbose logging did not help:

# fwupdate  -a '{e820d9ce-ff2c-5ce6-8ba1-c0c1c5703f44}' PN50-ASUS-0611.CAP --esp-path=/boot/EFI -v 
(fwupdate:2815): FuCommon-DEBUG: 12:02:31.707: device /org/freedesktop/UDisks2/block_devices/nvme0n1p2, type: 0657fd6d-a4ab-43c4-84e5-0933c84b4f4f, internal: 1, fs: swap
(fwupdate:2815): FuCommon-DEBUG: 12:02:31.721: device /org/freedesktop/UDisks2/block_devices/nvme0n1p1, type: c12a7328-f81f-11d2-ba4b-00a0c93ec93b, internal: 1, fs: vfat
(fwupdate:2815): FuCommon-DEBUG: 12:02:31.729: device /org/freedesktop/UDisks2/block_devices/nvme0n1p3, type: 0fc63daf-8483-4772-8e79-3d69d8477de4, internal: 1, fs: ext4
(fwupdate:2815): FuCommon-DEBUG: 12:02:31.748: reading PN50-ASUS-0611.CAP with 16781312 bytes
(fwupdate:2815): GLib-GIO-DEBUG: 12:02:31.750: _g_io_module_get_default: Found default implementation local (GLocalVfs) for ‘gio-vfs’
(fwupdate:2815): FuPluginUefi-DEBUG: 12:02:31.751: deleting /boot/EFI/EFI/mageia/fw/fwupd-e820d9ce-ff2c-5ce6-8ba1-c0c1c5703f44.cap
(fwupdate:2815): FuPluginUefi-DEBUG: 12:02:31.755: maximum size is not configured
(fwupdate:2815): FuDevice-DEBUG: 12:02:31.756: installing onto (null):
FuFirmware:
  FuFirmwareImage:
  Data:                 0x1001000
(fwupdate:2815): FuCommon-DEBUG: 12:02:31.756: writing /boot/EFI/EFI/mageia/fw/fwupd-{e820d9ce-ff2c-5ce6-8ba1-c0c1c5703f44}.cap with 16781312 bytes
(fwupdate:2815): FuPluginUefi-DEBUG: 12:02:31.795: DP type:0x04 subtype:0x01 size:0x002a
(fwupdate:2815): FuPluginUefi-DEBUG: 12:02:31.795: DP type:0x04 subtype:0x04 size:0x0084
(fwupdate:2815): FuPluginUefi-DEBUG: 12:02:31.795: DP type:0x7f subtype:0xff size:0x0004
failed: is not valid format

After building it from source and adding some debug, it was failing to parse the GUID because the {} which are displayed by fwupdate -l must not be given in the parameter, and it does a lot of work before validating the arguments 🤦

Anyway, after calling it correctly all went fine:

# fwupdate -l
system-firmware type, {e820d9ce-ff2c-5ce6-8ba1-c0c1c5703f44} version 1553 can be updated to any version above 1552

But I still don't have /sys/firmware/acpi/tables/BGRT.

2020-12-31

New machine

8 years after the previous one, I bought a new computer and available hardware has changed quite a lot!

I bought an Asus PN50 with an AMD Ryzen 4800U, which is probably 30 or 40 times smaller than my previous machine but more powerful while using a lot less power...

Asus PN50 next to a credit card for size reference

I fit it with 32GB ram (with a second slot free to go to 64 later) and WD BLACK SN750 1TB NVME SSD and performance is really impressive for such a small machine with low power consumption (building an x86_64 Linux kernel with defconfig takes 2m35s). 

Writing to a file is far from the announced 3000MB/s Sequential Write Performance but still crazy high compared to what I was used to:

$ dd bs=16M count=512 if=/dev/zero of=test oflag=sync
512+0 records in
512+0 records out
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 11.4705 s, 749 MB/s

It also gives me accessible USB-A, USB-C and micro SD ports which is very convenient for example to write images to USB sticks or SD cards.

2020-12-10

Playing with Chrome extensions

After a few days trying to book a Visa appointment with TLS Contact which had 0 availability and the consulate telling me to just often refresh, I decided to write a Chrome extension to check when they add them and notify me in case I would be around.

In the past I had done that with scripts after saving the cookies/tokens but this time I decided to try doing it in the browser. 

Pros:

  • I just need to login in a tab and let it there. It keeps refreshing so the session remains valid, but if it expired I would just need to login again.
  • I get to learn extensions APIs
Cons:
  • I will not be notified while not in front of my computer, however they seem to be manually adding the appointments so only during working hours
The first part was to create a content script to be run in the context of the page each time I visit a page matching the given URL. This is achieved by adding this to the manifest.json:

"content_scripts": [
  {
    "matches": ["https://*.tlscontact.com/*/myapp.php*"],
    "js": ["contentScript.js"]
  }
],

In that script I made it reload the page every 10 minutes (as the data is directly in the response from the PHP script) and when the page is loaded to parse it to find available appointments. I then used the storage API to preserve that list between reloads and compare to know if there are new appointments.

I used the sync API, meaning it is shared between my browsers, just because I can.

chrome.storage.sync.get('available', function(result) {
  var av = result['available'] || {};
  // Diff, log changes and notify of new ones
  chrome.storage.sync.set({available: available}, function() {});
});

The next interesting part is the notifications, as user scripts are very restricted and can not use the notification API. What I had to do was to add a background script, which has more power, by adding this to the manifest.json:

"background": {
  "scripts": ["background.js"],
  "persistent": false
},

Now when the content script wants to notify of a new appointment, it sends a message:

chrome.runtime.sendMessage({Appointment: a}, function(response) {});

In the background script, I listen to those messages and create notifications:

chrome.runtime.onMessage.addListener(
  function(request, sender, sendResponse) {
    chrome.notifications.create(request.Appointment, {
      type: 'basic',
      title: 'New appointment available!',
      message: request.Appointment
    }, function(notificationId) {});
    sendResponse({response: ""});
  }
);

And that's it! It turned out to be much simpler than expected, and we booked an appointment the next day.


2020-12-02

Enlarging an AWS NVMe root disk

There are plenty of documentations/questions about enlarging partitions but I had a problem before reaching that stage as the kernel does not seem to notice that the size of the disk changes (and I did not want to reboot).

AWS documentation says it should work Linux kernel 4.2 or later but this does not work for me with 5.7.19. It also suggests hdparm -z but that fails as the disk is busy.

After a bit of digging I found the right sysfs entry:

# echo 1 > /sys/block/nvme0n1/device/rescan_controller

Now the kernel notices:

[472580.761678] nvme0n1: detected capacity change from 107374182400 to 214748364800

And everything else works as expected:

# growpart /dev/nvme0n1 1
CHANGED: partition=1 start=206848 old: size=209508319 end=209715167 new: size=419223519 end=419430367
# resize2fs /dev/nvme0n1p1
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/nvme0n1p1 is mounted on /; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 25
The filesystem on /dev/nvme0n1p1 is now 52402939 (4k) blocks long.