Thursday, February 24, 2022

Review: Grandpa's Underwood No. 5 Typewriter

I am composing this blog post on a device that feels equal parts familiar and alien. On one hand I'm typing away on a QWERTY keyboard with tabs, backspace, shift lock, and a ruler eerily similar to the one found in Microsoft Word 98. The mechanical keyboard generates a familiar tapping sound that wouldn't be out of place coming from my Android device.

On the other hand, there's no software, or processor or any trace of electronics in sight. This is analog, mechanical hardware all the way! Each keystroke produces an indelible mark, recording mistakes in all their permanent glory. What's more, the entire writing process is intensely physical. The force of the each key stroke directly impacts how readable the output is.

This epic mashup of ideas and technology is courtesy of none other than an Underwood No. 5 Typewriter. In many respects it's almost reverential to compose on it. So much of the hardware and software I’ve used my entire life has been modeled on ideas made popular by this device. I can't help but be in awe.

This particular model comes to me courtesy of Shira's grandfather. Shira tells me he was a traveling salesman who typed his orders and she knew from experience that he used a typewriter to type all correspondence. So 9 year-old Shira would get letters at camp from her grandfather written on a typewriter (though on a later model than this one). Grandpa Bill owned multiple typewriters, yet he held on to one created in the 1920's. Perhaps it's for the same reason I have an NEC PC-8500 stashed away in a closet upstairs. That device was my first computer, and was profoundly life altering. For the world, the Underwood Typewriter would hold a similar status. In that context, it seems quite appropriate that Grandpa Bill would hold fast to his No 5.

By the time the Underwood made it to our house, it was in pretty rough shape. Decades of dust had accumulated and I had my doubts as to whether it could be properly restored.

We called the good folks at A to Z Typewriter Company for assistance. A nice fellow came by to pick up the typewriter. A few weeks later, he dropped it off in perfect working order, looking in amazingly good shape.

He left me with three pieces of advice. One, don’t drop it. This sucker weighs a ton, so I'm not sure that's a problem. Two, if I ever wanted to sell it, he should be my first call. Not likely, but good to know. And three: use it. This isn't just an heirloom to admire, operating it will help keep it functional.

For some time now, I've been pondering the best way to follow this last piece of advice. We've put the typewriter where folks can use it, and nobody can resist walking by the first time without tapping out at least a few characters.

When D visited us, he took the typewriter use to a new level: composing letters, journal entries, thank you notes and even addressing envelopes with it. In every case, the typewriter made all of these tasks more fun.

And now I’m using the device to compose blog entries. My plan is to snap pics of the typed text and run the photos through tesseract to OCR them.

I can't imagine this will be my new blog drafting setup of choice, but it sure is a mind bending way to write. Perhaps I can put the device to work for composing Morning Pages? If there's a practical use for the Underwood No 5, I'll find it.

What a profound gift Grandpa, and My Mother-in-Law gave us by holding on to this keepsake. To witness Grandpa Bill's great-grandson joyously typing away on the same keyboard he did was just too precious. And man, they do not make 'em like they use to. I may love the PC-8500 of my youth, but I can't imagine doing anything remotely practical with it. My Underwood No 5 feels to me as functional as it was the day it rolled off the assembly line in 1926. Now that's some impressive tech.


The following commands converted the images of the typewritten pages into text I could edit in emacs:

$ tesseract --psm 1  20220224_073448.jpg - > blog.txt
$ tesseract --psm 1  20220224_073453.jpg - >> blog.txt

Curiously, running tesseract with no command line arguments generated pure gibberish. Providing --psm 1 provided usable text.

Tuesday, February 22, 2022

Florida in a Hurry

We zipped down to Florida for a quick weekend of B'nai Mitvah prep. While it was mostly a weekend of Getting Things Done, we did enjoy spending time with the kids and even worked in a side-trip to visit my folks at their place. One notable highlight was finishing up the locket project for G.

Looking forward to our next visit where we get to enjoy the fruits of this past weekend's labor.

Thursday, February 17, 2022

The American Drawing Book: Learning to Draw Like an 1840's Amateur

Like an antiquities thief eyeing his next score, I often treat a museum visit as a sort of shopping trip. Instead of looking for my next heist, I'm on the lookout for ideas and inspiration. This last trip to the Smithsonian was no different. One gem I walked away with is featured in this pic:

According to the associated plaque, that's a copy of the The American Drawing Book: Manual for the Amateur, Basis of Study for the Professional Artist by John Gadsby Chapman. Published in 1847, as the title suggests, this text was intended to teach both amateurs and pros how to draw.

Thanks to Google Books we need not admire the text through glass alone. You can download a PDF or read the book online.

I've been making my way through the text,  and have spent enough time with it to form an opinion. Like any modern drawing book, the introduction dwells on the many benefits of learning to draw. The 'American' in the title is emphasized in the introduction, because at the time the text was published Europe was the center of the design universe. America had quite a bit of catching up to do, and Chapman intended to assist by providing this text for use by all, from the humble public student to the eager professional.

Among the groups of people he encourages to pick up the pen are women.

There are those, of another class of society, to whom education in Drawing may prove a real blessing whose painful and ill-repaid labors, to earn a scanty provision for themselves and families, have so often called forth our sympathies; and, while public feeling loudly declaims against the evil, no efficient remedy has been applied. Of the thousands of dependent females who are compelled to toil, night as well as day, to the destruction of health and life, and who are often tempted into paths of vice and misery by absolute necessity, how many there are who possess talent that needs but cultivation to secure them both respectability and support. The natural refinement and delicacy of the female mind renders it a fruitful soil, that should not be neglected or let run to waste, when its cultivation might realize such rich advantages, not only to themselves, but to their country. Give them the advantages of education in Drawing ; begin in your public schools let them carry it to their looms, to the manufacture of articles of taste and fancy, to their firesides, to the early education of their children;—-and more, if they possess the talent,—-let them take the pencil, the chisel or the burin. Give them strength, by proper education, to feel what they can accomplish, and we shall soon see the broken-hearted victims of incessant toil worth the wages of men, in departments of industry and usefulness for which they are by nature so well adapted.

Surprisingly woke, no?

I also appreciated his appeal to parents who may consider drawing to be a frivolous waist of time.

Fathers and Teachers--call not your boys idle fellows, when you find them drawing in the sand. Give them chalk and pencil — let them be instructed in design. “But,” you say, “I do not want my boy to become an artist.” Depend upon it, he will plough a straighter furrow, and build a neater and better fence, and the hammer or the axe will fit his hand the better for it: for from it, no matter what may be his calling in life, he will reap advantage. Last, not least, you give him a source of intellectual enjoyment, of which no change of fortune can deprive him, and that may secure his hours of leisure from the baneful influence of low and ignoble pursuits.

While the text may be written in awkward language, I can't think of strong arguments for why someone should learn to master the arts.

Chapman clearly had his advocacy game down. But how about the core of the text? Does the drawing instruction hold up? I'm only part way through the book, but so far, I'd say Chapman is nailing it.

Consider this advice he offers about favoring a pen over a pencil and an eraser:

Let us lay well the foundation, before we begin the structure. He who starts with the black lead pencil in one hand, and the Indian rubber in the other will find, however convenient the latter may be, that he will soon fall into loose and slovenly habit, of which it will be difficult to divest himself. They are both good and serviceable in their places; but too often, in the hands of beginners, most sadly abused.

This mirrors contemporary advice I've read on the topic.

So far, Chapman has focused on drawing progression. I've been faithfully following each of his exercises, which started as simply as tracing lines created with a straightedge. I'm finishing exercise #17 which has me drawing simple objects and using a grid to help navigate where the lines should be placed.

The grid vastly simplifies the drawing process, and I was impressed at Chapman's choice to rely on it. It then occurred to me: what if I wrote some code that let me take any pictures and draw a grid over it? That would be one useful tool, I mused. I could take Chapman's strategy from the 1850's and bring it to my 2022 smartphone! As a precursor to writing the app I had in mind, I searched Google Play for a similar topic. Turns out, there are quite a few apps that do exactly what I had in mind.

Apparently, overlaying a grid on a picture to help draw it is standard practice. Chapman knew this is 1840, and artists know this today. I'll take this as a hint that Chapman's drawing advice is standing the test of time, and more importantly, I have a lot to learn.

Here's a few samples of the work I've completed. I look forward to seeing if Chapman's approach continues to be effective.

Tuesday, February 15, 2022

Gotcha: When Windows and WSL2 Stop Talking To Each Other

When Linux and Windows Can Talk

Let's say I'm in an Ubuntu WSL2 session and I want to copy a file to Google Drive. The latest version of Google Drive allows access via a mounted drive, in my case, G:\. The simplest way I've found to copy a file into G:\ is to make use of PowerShell:

$ date > data.txt
$ powershell.exe -C copy "c:/Users/benji/Downloads/data.txt" "'G:\My Drive\'"
$ powershell.exe -C dir "'G:\My Drive\data.txt'"


    Directory: G:\My Drive


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
------         2/14/2022   6:13 AM             29 data.txt


$ powershell.exe -C type "'G:\My Drive\data.txt'"
Mon Feb 14 06:13:56 EST 2022
$ cat data.txt
Mon Feb 14 06:13:56 EST 2022
$

While the commands above are clunky, they're straightfoward. I'm kicking off an instance of PowerShell from Linux to run simple Windows commands. Because those commands are running under Windows, they can trivially access G:.

Or, consider another example. Let's say I want to open a web page from emacs running under Ubuntu. In emacs, I evaluate the following lisp code:

(browse-url "https://blogbyben.com")

The result is that the URL is opened in the Windows version of Chrome. I didn't have configure this behavior, it Just Works. Until it doesn't.

When Linux and Windows Aren't On Speaking Terms

Every once in a while, I'll use the code above and I'll be greeted with a long delay and finally an error message. For example:

$ powershell.exe -C type "'G:\My Drive\data.txt'"
<3>init: (26039) ERROR: UtilAcceptVsock:244: accept4 failed 110

In emacs, running browse-url will occasionally just not work. Digging into the code, I realized that emacs is running xdg-open. Running this command manually, when the integration is broken, results in a similar error message.

$ time xdg-open https://www.blogbyben.com
<3>init: (26536) ERROR: UtilAcceptVsock:244: accept4 failed 110
<3>init: (26546) ERROR: UtilAcceptVsock:244: accept4 failed 110
<3>init: (26548) ERROR: UtilAcceptVsock:244: accept4 failed 110
<3>init: (26550) ERROR: UtilAcceptVsock:244: accept4 failed 110
/bin/xdg-open: 869: firefox: not found
/bin/xdg-open: 869: iceweasel: not found
/bin/xdg-open: 869: seamonkey: not found
/bin/xdg-open: 869: mozilla: not found
/bin/xdg-open: 869: epiphany: not found
/bin/xdg-open: 869: konqueror: not found
/bin/xdg-open: 869: chromium: not found
/bin/xdg-open: 869: chromium-browser: not found
/bin/xdg-open: 869: google-chrome: not found
<3>init: (26599) ERROR: UtilAcceptVsock:244: accept4 failed 110
<3>init: (26609) ERROR: UtilAcceptVsock:244: accept4 failed 110
<3>init: (26611) ERROR: UtilAcceptVsock:244: accept4 failed 110
<3>init: (26613) ERROR: UtilAcceptVsock:244: accept4 failed 110
/bin/xdg-open: 869: links2: not found
/bin/xdg-open: 869: elinks: not found
/bin/xdg-open: 869: links: not found
/bin/xdg-open: 869: lynx: not found
/bin/xdg-open: 869: w3m: not found
xdg-open: no method available for opening 'https://www.blogbyben.com'

real    1m20.400s
user    0m0.159s
sys     0m0.067s

What the Heck?

From poking around the web, I learned that the integration between Windows and WSL2 happens via the environment variable $WSL_INTEROP. This variable is set to a file system socket which provides the communication channel.

When I look in /var/run/WSL I see a number of files:

$ ls -1 /var/run/WSL/
10088_interop
11670_interop
13888_interop
1663_interop
17081_interop
1_interop
2189_interop
6106_interop
6268_interop
8855_interop
8_interop

The trick: WSL_INTEROP needs to be set to the right one for proper communication to happen. I confirmed this by going through the list of files, setting each one to WSL_INTEROP and seeing if that fixed the problem. Eventually it did. But trial and error is hardly the way I want to get back on track once Linux and Windows stop talking.

This discussion thread suggests using pstree to automatically set WSL_INTEROP. However the recipe provided didn't work for me.

The goal of the command appears to be to set WSL_INTEROP to the value /var/run/WSL/<PID>_interop where PID is the process ID of the parent's init process.

Looking at my running system, I see that init is running multiple times, and that the PIDs correspond to files in /var/run/WSL.

$ ps auxwww|grep init
root         1  0.0  0.0   1772  1100 ?        Sl   Feb09   0:00 /init
root         8  0.0  0.0   1752    80 ?        S    Feb09   0:00 /init
root      8854  0.0  0.0   1772   100 ?        Ss   Feb10   0:00 /init
root      8855  0.0  0.0   1780   100 ?        S    Feb10   0:01 /init
ben      26051  0.0  0.0   8160  2488 pts/6    S+   06:18   0:00 grep init

After a few attempts, I realized one way to get the correct init PID is to use the last one in the process list. Using grep, tail and awk I can extract this value.

$ ps auxwww|grep init | grep -v grep | tail -1
root      8855  0.0  0.0   1780   100 ?        S    Feb10   0:02 /init
$ ps auxwww|grep init | grep -v grep | tail -1 | awk '{print $2}'
8855

I then added the following to my .bashrc:

$ export WSL_INTEROP=/var/run/WSL/$(ps auxwwww|grep init | \
   grep -v grep | tail -1 | awk '{print $2}')_interop

This code properly sets WSL_INTEROP and revives the Windows / Linux communication channel. With that in place, I'm back to opening up web pages and PowerShell'ing like a champ.

Friday, February 11, 2022

The Valentine's Gift a Year In The Making

Last Valentine's Day I gave my wife what every young lady dreams of: an over-engineered Love Note Display and Archival System. For the past year I've been feeding it messages for her to see, as well archive for later use. With Valentine's Day around the corner, it was time to put the stored content to use.

One thoughtful gift, I imagined, was to take messages I'd sent and format them into a poster. While I have no problem writing code that let's me post love notes from an Android device to an iPad, the thought of designing a poster left me overwhelmed. In fact, I considered outsourcing the job to someone on etsy. Still, in the name of love, I figured I should at least make an attempt.

A Little Gimp

I decided to start simple. I launched Gimp and made a new 4000x5000 pixel image. I chose this image size because it seemed both large, and has the same aspect ratio of an 8x10 photo.

One tricky aspect of this project is that some of the love notes contain emojis. While they looked good when rendered on the iPad and even stored properly in the Google Sheet, I had my doubts that they would format properly in Gimp. I selected all the notes from a Google sheet, copied them to my clipboard, and pasted them into a large text area in Gimp.

To my amazement, Gimp seamlessly rendered the text and emojis.

While the notes were all there, I didn't have anything resembling a pleasing poster.

A Little Shell Scripting

My next move was to reformat the text so that it was no longer one message per line. I made one massive stream of text using this quick shell script. I'm separating each note with \u2764 which is the heart emoji.

#!/bin/bash

##
## take in an input stream of love notes and output formatted love notes.
##

while read line ; do
  echo -n "I Love $line"
  echo -e -n " \u2764 "
done

The screenshots below show another discovery: Like Gimp, Windows Terminal running Ubuntu on WSL 2 seamlessly handles emojis. I'm so leveraging this in the future by having my shell scripts print out emojis status messages. While I was at it, I installed emojify, an emacs package that let's you seamlessly use emjojis. I can't wait to start including emoji's in my git commit messages.

I copied the massive line of love-note text into a Gimp text area and told Gimp to justify it. It looked better. We were definitely getting somewhere.

A Little More Gimp

To polish this up, I headed to Google photos and found a meaningful picture I could use as the poster's background. I downloaded it and positioned it at the bottom of my creation.

I then faded the top part of the background image using a layer mask. This allows the photo to seamlessly flow into the background of the poster.

I then dialed down the opacity of the background pic so it would be more reader-friendly and picked a color other than white to use for the poster's background.

And that was it, in relatively short order, I had my completed poster.

Success!

My final move was to send the image off to CVS to have it printed. $4.00 later, I had my Valentine's gift in hand. I have to say, I was pretty floored by how well the project turned out.

Mind you, the poster is far from perfect. At 8x10, the text is far too small to casually read, and the background I selected was probably too dark. Still, from an art perspective, it sort of works. You look at this 8x10 picture and see a mess of text. It's only upon closer inspection that you realize what you're truly looking at. So yeah, let's call this abstract art and leave it at that.

Sunday, February 06, 2022

DC, Chaperone Edition


For most of this past week Shira and I proudly donned a new, temporary, title: chaperone. D.'s class was visiting Washington, DC and through our good fortune we had the opportunity to help accompany them in the area.

For the most part, Shira and I tried to remain in the background. This was D's time to hang with his class and get direction from his teachers, not have an Uncle and Aunt Adventure. Still, we savored our time together and took advantage of of any free time we could find.

The class hit the usual DC museums and monuments and I enjoyed getting to see our city through fresh eyes. Here were a few of my favorites.

Favorite Monument: The Navy Memorial. D and I were meeting his class at Ford's Theater, and realized we had a bit of free time. We ducked over to the Navy Memorial and thoroughly enjoyed looking at the 26 bronze scenes that depict Navy history. My favorite was the first one, which honors the Navy's Bomb Disposal Unit. Their unofficial motto was just too clever: Initial Success or Total Failure. D liked the last scene which depicted Landing Ship, Tanks, which were affectionately known as Large Slow Targets.

I didn't realize it at the time, but the globe etched on the plaza itself is the largest map in the world.

Favorite Museum: National Gallery of Art. I was just blown away by the Smithsonian's National Gallery of Art. There were so many well known artists and paintings on display, even an art novice like myself had to be impressed. It seemed that around every corner was yet another breathtaking painting or sculpture. D loved that he got to see the only Leonardo da Vinci hanging in North America.

Favorite Exhibit: the Archive's Public Vault. I always think of the National Archives as a sort of one trick pony: you can see our founding documents and that's about it. But boy, was I proved wrong. The Public Vault's exhibit has all sorts of historic tchotchkes, from an original Emancipation Proclamation to navigation equipment used by Pole explorer Robert Peary. There's so much to see here, I can't wait to drag our next DC visitor back here.

Favorite Activity: Bird Watching. D is a fan of all things bird related, so we basically turned this trip into one massive bird watching expedition. Whenever walking or driving, we kept an eye out for birds; Whether it was a lone hawk soaring above or a few city pigeons looking for scraps, D was excited to spot them. For my part, I never appreciated how many buildings in DC feature birds as part of their architecture.

D's attentiveness paid off near the entrance of the Natural History Museum where we were rewarded with spotting a new (to us) species: a Yellow Rumped Warbler; aka Butter-Buttz.

The bird watching didn't stop when we went indoors, we just had to get more creative. D was thrilled by the Natural History's Bird's of DC exhibit, and loved visiting Martha, the last Passenger Pigeon. The National Gallery of Art provided no end to paintings that included birds, though often they were a bit grim from a bird watcher's perspective. D even spotted birds on dishes at the First Ladies exhibit in the Smithsonian American History Museum.

Heck, at times he even outsourced the bird watching, like when his classmates texted him a picture of a hawk they came across.

Other Highlights: Walking in on Shira and Dovid playing blackjack. She had the poker chips out and was covering betting strategy. Next lesson: card counting. Shira's already planning their first trip to a casino.

Dovid immediately noticed Shira's Gradfather's refurbished Underwood typewriter that we now have on display. After experimenting with typing some random gibberish, he quickly graduated to dashing off letters, including using the typewriter to address the envelope. By the end of the trip, he'd written three letters, one thank-you note, and multitple journal entries--including an evening edition for one day. My gosh that boy is industrious.

What a treat it was getting to both spend time with D, as well as see him shine in front of his classmates and teachers.