Week ending 2018-03-10

A- got a new conformer last week. Progress: she didn’t cry in the waiting room, although she still burst into tears as soon as she saw the ocularist. We’re continuing with the conformer approach instead of switching to a painted shell because A- still rubs the conformer out of her eye from time to time, and it’s easier to replace a conformer. Maybe we’ll switch when she’s closer to school age.

I asked her where she wanted to go for Field Trip Friday. She said, “Riverdale Farm. I miss that. I have fun. Big sheep make big noises.” So we went, and we enjoyed looking at the baby goats. We passed by the Children’s Book Bank, and I was delighted to find that you can take double the number of books on Fridays. I picked up a few more Seuss books.

We’ve been making more of an effort to explore and catalogue places so that we can make the most of Toronto’s resources. We checked out Baird Park, which has a playset with a short tunnel that A- actually worked up the courage to go through. She liked going down the twisty slide on my lap, and then graduated to going down the twisty slide at Lithuania Park with a little push. I posted a few park reviews in Google just in case other people find those notes handy, and I should find some way of organizing my own copy of the notes too.

A- has been having fun with both fine and gross motor skills. She practised using a ladle to pour and a butter knife to spread. She goose-stepped and danced.

A- can talk about more abstract things. She scribbled and said she was drawing “nervous.” One time, W- was carrying her up the stairs to change her diaper, and she was getting a little wriggly and distracted. He said, “Focus.” She said with enthusiasm, “Diaper!”

She likes being involved. When she was at the sink, she said with delight: “Yes! I’m busy!”

One time, she insisted that I carry her up bridal-style in my arms (which she accomplished by flopping in a certain way and protesting if I tried changing things). I was mystified, but it all became clearer once we got upstairs and she wanted me to read Emma to her. The Cozy Classics version has just twelve words, and “carry” is one of them. “Frank Churchill carry. Emma,” she said. Aha!

She often sings nursery rhymes and other songs. She sang part of “Mamma Mia” while dancing, and then obligingly repeated while I suppressed my laughter long enough to record her on video.

Little improvements:

  • W- set up a Synology DS718 network-attached storage server. Wheee! I feel more grown-up with proper backups. I set up borg backups for my server and my laptop. Next: Docker containers for testing the backups…
  • I set up lots of voice shortcuts to help me with groceries and with tracking. For example, I can say, “Okay Google, baby awake” and it will log that in my system. I explored Tasker’s Memento support, too.
  • I figured out how to use Org Mode and LaTeX to typeset drawing templates for children’s books, and I used that to make a book about smoothies. Next: photos, more layouts
  • Lots of tidying up in the basement, too. Whee!
  • I switched to writing in Markor on Android. I briefly enabled Markdown support in WordPress, but it was messing up some of my other posts, so I turned it off again.
  • I set up god-mode in Emacs, which does make phone use a bit easier.

Using exiftool to put date, rating, and title in photo filenames

Now that we have a Synology backup server, I want to get better at keeping and organizing photos. I’ve got lots of pictures and videos of A- in Google Photos, but I don’t want to rely only on that. When Google eventually decommissions the service (no signs of this now, but you can never tell), I’d like to already have copies of my favourite photos and videos all prioritized and backed up instead of spending days wading through accumulated cruft.

I had previously added significant moments to a “Weekly highlights” album in the Google Photos app. I had also tried to select a number of those for “Level 2 highlights” and “Level 3 highlights” roughly approximating monthly and yearly filters. This was awkward, though, since Google Photos didn’t let me see which photos were already in an album or which timespans weren’t well represented. I wanted a five-star rating system so that I could gradually winnow images I liked, and I wanted tags for more flexibility.

The F-Stop Gallery app on Android seemed to be a quick way to sort through images, rate them, and tag them. I liked how it stored the metadata in the file instead of in a separate database. The bulk management tools were decent, although of course it would be even better to do things with fewer taps.

I downloaded ZIPs of my highlight albums and extracted them to a Samba share so that I could access them from my phone. I rated the level 3 highlights as 5 stars, level 2 as 3 stars, and weekly highlights as 2 stars, leaving the 4-star level for finer distinctions if I need to fiddle with things. Then I used cp -n (no clobber; don’t overwrite existing files) to copy the 5-star photos, then the 3-star photos, and lastly the 2-star photos. That way, even if a photo was in multiple albums, the file would have just the highest rating I assigned.

I can’t always rely on apps to index and search by the metadata in a file, so I like putting that information in the filename. A good filename might look like this:

2016-08-01-20-14-44 ### Relaxing on the deck #family.jpg

It starts with a date and time, since timelines make sense. I add one to the number of stars and convert that to # so that I can easily search for, say, ### to show me all entries that have at least two stars. This also creates a neat ASCII bar chart effect when looking at lists of filenames. I want to include the title if available, and any tags for easy searching as well.

Here’s the Bash script that takes an image file and renames it accordingly:

exiftool -m \
  -"Filename<\${DateTimeOriginal;s/[ :]/-/g} \${Rating;s/([1-5])/'#' x (\$1 + 1)/e} \${Title} \${Subject;s/^/#/;s/, / #/g}.%e" \
  "[email protected]"

This probably has bugs, but it seems to be a decent start.

It was great to find out that I can pass Perl expressions to exiftool to modify the field value. I figured out that I could combine that with the /e flag for executable replacements so that I could generate a string of N+1 characters. While tinkering with the code, I accidentally used \1 instead of \$1 in my Org Mode block. That made a number such as 5 turn up as a scalar with a six-digit value, so I ended up with a really long line of #####... in my Org file. Emacs was definitely not happy. I ended up opening my Org file in vi so that I could delete the offending line. Anyway, I managed to recover from that and figure out what I needed to put in. Yay!

It would be pretty neat to have some kind of inotify thing watching my NAS inbox and processing files accordingly. In the meantime, I don’t mind running another script. We’ll see how this goes!

2018-03-12 Emacs news

Links from reddit.com/r/emacs, /r/orgmode, /r/spacemacs, Hacker News, planet.emacsen.org, YouTube, the changes to the Emacs NEWS file, and emacs-devel.

February 2018

In addition to our usual field trips to the Science Centre and the ROM, we went to Riverdale Farm. A- named the animals and enjoyed talking about them, although she found the sheep a little loud. We also started visiting family more often, for both big things like Chinese New Year and A-‘s birthday as well as small things like an afternoon of hanging out.

A- wanted to build a Duplo tower so tall that she had to stand on a chair to add blocks to it. She got pretty good at inserting shapes into her sorter and screwing together the nuts and bolts in her toolkit.

She walked astride her balance bike all the way to the kitchen by herself. She carried empty containers on a tray. She danced a lot and imitated other aspects of music class. She enjoyed bouldering. She wanted to try out a life jacket while swimming, and she kicked her legs too. She picked up diving rings with her foot.

She sang Humpty Dumpty, Baa Baa Black Sheep, and Hey Diddle Diddle practically in full. I could prompt her to show me a sleepy face, a sad face, and so on. She talked about recent events and how she felt, often revisiting moments that were particularly significant to her. She echoed many of the things we often say, such as “Give it a try.” She asked for specific things using “I need…” and often thanked us.

She played more independently, often amusing herself for a number of minutes or toddling off to a different room while telling us to stop. She confidently touched different textures in books. She asked to be pushed faster while in the playground swing, and she wanted to go down the twisty slide.

Her eye exam went well. The pediatrician is working on referrals to Sick Kids for dentistry and endocrinology.

We replaced our printer with an HP M277dw, and I learned how to use it to make short books for A-. I figured out an Emacs News workflow that I can do entirely from my phone, and I set up Syncthing for my files too. We organized A-‘s toys and clothes into IKEA Trofast drawers. I uploaded old photos to Google Photos. Progress!

March: A new conformer, a consultation with the anesthesia dentist, more children’s books, and lots of time with A-. We’ll figure this out!

Using Org Mode, LaTeX, Beamer, and Medibang Paint to make a children’s book


  • It’s time to make a smoothie!
  • I pour blueberries into the blender.
  • Mama adds hemp seeds.
  • I add spinach.
  • Mama blends it all with some water.
  • I peel and add a banana.
  • I add some yogurt.
  • Mama blends it again.
  • Yum yum!


spread0.png spread1.png spread2.png spread3.png spread4.png spread5.png


  • Prerequisites

    • ImageMagick
    • Texlive (probably)
    • latex-beamer
    • Org Mode and Emacs
  • Set up Org Mode export to Beamer

    (eval-after-load "ox-latex"
      ;; update the list of LaTeX classes and associated header (encoding, etc.)
      ;; and structure
      '(add-to-list 'org-latex-classes
                      ,(concat "\\documentclass[presentation]{beamer}\n"
                      ("\\section{%s}" . "\\section*{%s}")
                      ("\\subsection{%s}" . "\\subsection*{%s}")
                      ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))))

  • Set up image directories

    mkdir text-pages blank-spreads drawn drawn-pages

    text-pages Will contain one image per page of just the plain text.
    blank-spreads Will contain text spreads ready for drawing
    drawn Export one image per spread (without the text layers) from your drawing program
    drawn-pages Will contain one image per page combining text and drawing
  • Tweak the header.tex

    This file gets included in the LaTeX file for the children’s book. Tweak it to change the appearance. In this example, I use black serif text at the bottom of the page.

    \setbeamercolor{normal text}{fg=black,bg=white}

  • Write the story

    I used Org Mode to make it easy to write the story.

    Some considerations:

    • Because we’re printing this as a saddle-stitched booklet, the number of lines should be a multiple of four. Sixteen is probably a good maximum.
    • The first heading is actually for the last page.
    • The second heading is for the cover page.
    • The third heading is for the first inner page, the fourth heading is for the second inner page, and so on.
    #+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc author:nil date:nil
    #+OPTIONS: H:1
    #+startup: beamer
    #+LaTeX_CLASS: beamer
    #+LaTeX_CLASS_OPTIONS: [20pt]
    #+LATEX_HEADER: \input{header.tex}
    #+PROPERTY: header-args :var pages=12
    * Story
    ** It's time to make a smoothie!
    ** I pour blueberries into the blender.
    ** Mama adds hemp seeds.
    ** I add spinach.
    ** Mama blends it all with some water.
    ** I peel and add a banana.
    ** I add some yogurt. 
    ** Mama blends it again.
    ** Yum yum!

  • Make the tex, PDF, page PNGs, and spread PNGs

    1. Go to the subtree for the story and use M-x org-export-dispatch (C-c C-e) with the subtree option (C-s) to export it as a Beamer file (option l b).
    2. Use pdflatex to convert the .tex to PDF.

      pdflatex index.tex

    3. Create one PNG per text page with:

      convert -density 300 index.pdf -quality 100 text-pages/page%02d.png

    4. Create spreads to draw on with:

      montage text-pages/page*.png -tile 2x1 -mode Concatenate blank-spreads/spread%d.png

    5. Optionally, create a layered PSD with:

      convert blank-spreads/spread*.png \( -clone 1,0 -background white -flatten -alpha off \) -reverse spreads-for-drawing.psd

  • Draw

    I imported the PNG layers into MediBang Paint on a Samsung Note 8 Android phone, and then:

    • imported photos
    • traced them
    • painted and shaded them
    • hid the text layers
    • exported one PNG per spread to QuickPic, renamed them, and uploaded them to Dropbox, because I couldn’t figure out how to export to Dropbox directly

    Layer folders were handy for organizing spread-related images. I couldn’t seem to move all of the layers in a layer folder together on Android, but the iPad was able to do so. If I didn’t have the iPad handy, I combined the layers by exporting a PNG and then importeing it back into MediBang Paint.

    This was a decent setup that allowed me to draw and paint even when I was in bed nursing A- and waiting for her to fall asleep. I held the phone with one hand and rotated the canvas as needed so that it was easier for me to draw lines with my right. Because of the awkward position and the small screen size, the lines are not as smooth as I might like, but the important thing is that they’re there. Whee! =)

    It turns out to be possible to use the free MediBang Pro drawing program under Wine on Linux to import the PSD and save it to the cloud. I was also sometimes able to switch to drawing with iPad Pro with Pencil, but it was harder to find time to do that because that usually made A- want to draw too.

    Anyway, after I drew and exported the PNGs, the next step was to…

  • Convert the drawn spreads back to pages and combine them with the text

    Here’s some code that combines the drawing and the text. Keeping the drawing and the text separate until this stage (instead of exporting the PNGs with the text) makes it easier to change the text later by recreating the text PNGs and running this step.

    (defun my/combine-spread-drawing-and-text (page num-pages)
      (let ((gravity (if (= (% page 2) 1) "West" "East"))
            (spread (/ (% page num-pages) 2)))
           (concat "convert \\( "
                   "drawn/spread%d.png -gravity %s "
                   "-chop 50%%x0 +repage \\) "
                   "text-pages/page%02d.png -compose darken "
                   "-composite drawn-pages/page%02d.png")
           spread gravity page page))))
    (cl-loop for i from 0 to (1- pages) do
             (my/combine-spread-drawing-and-text i pages))

  • Create print spreads for saddle-stitching

    This code pairs up the drawn pages into a PDF that can be printed duplex. Make sure to choose the option to flip along the short edge. I hard-coded the page orders for 4-, 8-, 12-, and 16-page booklets.

    (let* ((page-order
            '((0 1 2 3)   ; hard-coded page sequences
              (0 1 2 7 6 3 4 5)
              (0 1 2 11 10 3 4 9 8 5 6 7)
              (0 1 2 15 14 3 4 13 12 5 6 11 10 7 8 9)))
            (mapconcat (lambda (d) (format "drawn-pages/page%02d.png" d))
                       (elt page-order (1- (/ pages 4))) " ")))
        "montage %s -tile 2x1 -mode Concatenate print-duplex-short-edge-flip.pdf"

  • Print and bind

    After printing and folding the book, I used tape to make the book hold together. Tada!

  • Create on-screen PDF for reading

    A little bit of manipulation so that the last page is in the right place:

      (format "convert %s onscreen.pdf" 
        (mapconcat 'identity (cl-loop for i from 1 to pages 
          collect (format "drawn-pages/page%02d.png" (% i pages))) " ")))

  • Create thumbnails of spreads

     for i from 0 to (1- (/ pages 2)) do 
       (concat "convert "
               "\\( blank-spreads/spread%d.png "
               "drawn/spread%d.png "
               "-compose darken "
               "-resize %dx -flatten \\) "
               "\\( +clone -background black -shadow 50x1+%d+%d \\) "
               "+swap -compose src-over -composite "
       i i width shadow shadow i)))

  • Ideas for next steps

    • Better thumbnails for easy previews
    • PDF for online reading
    • More layout possibilities (photos, verses, etc.)
    • Smaller books:

      • crop marks on a full-page print, or
      • the right imposition rules to print more pages on a sheet

Week ending 2018-03-02

We went to Riverdale Farm this week. A- was a little wary of the sheep, but she eventually got more used to the noise. We visited her grandmother. A- ate lots of strawberries and practised fetching things.

A- had lots of fun spinning around and around, whether it was on the platform at the Ontario Science Centre or in the kitchen at home. With a tray, too, for extra challenge points! She enjoyed rock-climbing, and so did I. She walked most of the way to the subway, too, and she walked astride her balance bike from the living room all the way to the kitchen.

She sang all of Humpty Dumpty and Hey Diddle Diddle, and has been dancing and playing instruments “just like music class.”
We played with catching and blowing feathers, too.

A- had a tantrum because she didn’t want me to go to sleep. I think adjusting her sleep schedule will have to be more about waking her up rather than trying to nudge her to sleep earlier. On the plus side, she echoed some of the sentences from the books we’ve been reading: “One step, another, fall down, and then pick myself up and try it again.” “I know it’s hard.”

I figured out how to make books! I drew a 12-page book about night weaning and an 8-page book about A-‘s conformer. I’m looking forward to making more, especially as I collect ideas and fine-tune my workflow. I managed to do Emacs News entirely on my phone, too, which bodes well for traveling without my laptop. I also worked on documenting files to back up.

Next week: new conformer, more books, and setting up some storage!