QZ qz thoughts
a blog from Eli the Bearded
Tag search results for 2021 Page 5 of 7

Special Breakfast

Once a month my dogs need to get dosed up. There's a pill for flea and tick prevention and a "treat" for heartworm. Willie hates them. The treat is inedible to him and the pill a terror. He is not tricked by embedding medicine in tasty things like cheese or hot dogs. So how to get him to take it?

Special Breakfast.

This is a literal dog's breakfast of a meal. Crush the pill, finely chop the "treat".

Dog food bowl with medicine.

Add to that some of this and some of that, basically any dog-tasty leftovers in the fridge. Maybe like pesto linguini, grilled chicken, and french fries, then top with some crushed cheese crackers. Looking good, right?


Now add a few pieces of kibble and dress with mayo and water. I use hot water to make it a warm meal. Delicious.

Dog food bowl with medicine, human food, kibble, and dressing.

And that's how Willie manages to tolerate medicine. Hazel, on the other hand loves to eat and will easily accept pills in cheese or the like. She gets Special Breakfast to be fair, not because it's necessary.

Simple Book Binding

Stack of bound PDF print-outs

I like printed documentation. You can add sticky bookmarks, highlight material (I typically use colored pencils for that), annotate the text, and have multiple things open at once easily.

I'd really like to find an easy way to turn a Gutenberg Project book into a decently bound volume through some print on demand service. Getting things like page numbers, headers, footers, and proper margins (need more space at spine than at fore edge!), to say nothing of cover, illustrations, and table of contents makes it hard.

But for smaller works, say things that can print on a few dozen sheets of duplexed paper, that's achievable. First get the document ready for printing. Things that start as PDFs are usually good. Things that are HTML pages are sometimes good, and sometimes need the HTML paired down some.

I print my stuff on a "business" Brother laser printer, the HL L6200DW. In general the monochrome laser printers (single purpose, as opposed to "all in one" scanner/copier/printer ones which are more hit-and-miss) from Brother are a good deal. Thanks to the large amount of printing my wife does for her business, we've run through quite a few. After about 60,000 pages the replacement parts needed start to cost more than buying a new one. Most people won't have that problem. The Brother printers are cheap and Just Work(TM) with Mac, Windows, and Linux. And they print double sided (duplex) automatically.

So print the material duplexed and then neatly collate the output. If you've got less than 25 sheets (50 pages), an ordinary stapler will work to bind the edges. If you have more than that, you need a heavier duty stapler and extra long staples. Swingline makes a few options, but be sure to be careful about staple selection.

Staple close to the edge, six or seven times along the spine. This will make the printout function like a book.

Binding process

Then use a medium thick tape to cover the stapes and bound edge. You can use one peice wide enough to fold around, or multiple strips. This is important to prevent the staples from catching on things (eg fingers) and improves the look of the binding considerably.

You can quite easily print some parts on larger paper and fold them so only one edge staples in. For my Vectrex Service Manual here, I printed the schematics single sided on legal (8.5"x14" paper) in landscape orientation. This is probably close to how the original was done.

Extra wide foldout sheets

The Act of Sewing

laser printed manuscripts stacked

How It Started

cover of final printed book

How It's Going

My wife's book, The Act of Sewing launches this week. Work started a long time ago, with finished manuscript going to the publisher before this covid-19 thing appeared.

This book is for you if you are looking for beginning sewing patterns and want to learn how to adapt patterns to suit your own tastes. Both cosmetic variations and adjusting the fit are covered.

(NB: The patterns are aimed at women's body shapes, but could be adjusted.)

Manual restore of Firefox sessions

Recently I needed to downgrade my Firefox install from 87 to 84 due to a bug. With multiple windows open, I was intermitantly finding some events were being sent to the wrong window. An example is open a new (private) window and start to navigate to a new page, but discover mouse clicks and other events were still being sent to the original window. I started seeing this in FF86 and FF87 did not fix it. By that point the bug was testing my patience, and worse FF87 seemed to have new (unrelated) bugs specifically with one site I use.

So downgrade.

It's been a long time since some Firefox bug has been serious enough to force me to install a different version, particularly a downgrade. So I was surprised to find that Firefox now marks every profile with a browser version and does not let older browsers use profiles from newer ones. Originally when profiles introduced compatibility changes it was somewhat infrequent, and downgrades were usually easy to do.

There are three things I really wanted to preserve:

  1. My open tabs (actual state in the tab, not as critical).
  2. My (few) bookmarks. Of 40 or so bookmarks, about 30 I had created (the others shipped with Firefox), and about half of those I still want.
  3. My preferences.

These have varying degrees of difficulty uncovering from the files in a profile. Session tabs ended up being the most complicated. Working backwards in that list.

Changed preferences are stored one-per-line in prefs.js in the profile directory. The chief complication is the number of entries. Many of them are related to extensions or printing and can just be ignored. Many more are related to internal settings like toolkit.telemetry.* or most of the browser.* ones.

The bookmarks are available in compressed JSON files in the bookmarkbackups profile subdirectory. The compression format is a bit of an oddball. The actual compression type is not so rare, LZ4, but apparently the Mozilla implementation is slightly non-standard. There are a lot of tools out there which can apply the standard LZ4 algorithm to the .jsonlz4 files Firefox makes. I used lz4jsoncat by Andi Kleen. Here ls -rt finds the most recent backup file to operate on.

lz4jsoncat $(ls -rt bookmarkbackups/*.jsonlz4) | jq . | grep '"uri"'

If you are unaware, jq is a JSON Query tool. In the simple usage there, the query is for the whole structure and functions as a JSON pretty printer. Why not use jq to slice and dice the uri entries out? Because they exist in several groups (probably for bookmark folders) and grep was way faster than figuring out the correct jq query to use.

But that brings us to the remaining item of interest for me: the URLs of all my tabs in the session data. There are several files in the sessionstore-backups profile subdirectory. In my inspection they all appeared to be valid sessions from different times, and recovery.jsonlz4 seemed to be the most recent one. No need to resort to time sorted file lists here.

The JSON structure holds a lot of data, from cookies to apparently thumbnail images of the page (base64 encoded for safely storing in JSON). Getting just tab URLs was not easily done with grep, and I needed to work out a jq query. There is a windows[] array with an entry for each window, inside that there is a tabs[] array with a state for each tab, and inside that an entries[] array with the history for each tab. The history is a stack with latest entry first.

lz4jsoncat sessionstore-backups/recovery.jsonlz4 |
    jq -r '.windows[].tabs[].entries[0].url'

For each item ([]) in windows array,
  for each item ([]) in tabs array within it,
    for the first ([0]) item in entries array within it,
      print the url field.
The -r makes the output "raw", which is to say without quotes.

Not as neat and clean as actual session recovery, but a lot better than trying to recover my two dozen tabs from memory.