Category Archives: geek

2018-04-09 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.

2018-04-02 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.

2018-03-26 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.

Labeling toy storage bins with photos and text using ImageMagick and org-babel

I wanted to make labels for A-‘s new toy storage: three low Trofast drawer frames all along the wall.

I liked how early childhood drop-in centres labeled their shelves with both pictures and text. That way, kids can find things before she can read, while still being exposed to print. I took pictures of the bin contents and renamed the files to the labels I wanted to put on them, such as 2x2 blocks.jpg. (We have a lot of Duplo.)

This time, I experimented with creating the labels entirely in Imagemagick instead of using LaTeX. First, I used a table in Org Mode to let me easily play with the dimensions and recalculate pixel sizes.

DPI   300
Columns 3  
Rows 5  
Paper width 14 4200
Paper height 8.5 2550
Minimum margins 0.5 150
Label width 4.3333333 1300
Label length 1.5 450

I passed the width and the height to the following code block by using header arguments. I liked using 400 pixels as the height instead of 450, so that’s what I used. My source image size was 4032×3024 pixels. If I resize them to a height of 400, that gives me a width of 533. Allowing 20 pixels for the text left and right borders gives me (- 1300 533 20 20) = 727 as the text width.

#+begin_src sh :dir ~/code/labels :var width=1300 :var textwidth=727 :var height=400 :var pointsize=72 :results silent
for x in source/*; do
  file=$(basename "$x")
  /usr/local/bin/convert \( \( "source/$file" -resize x${height} \) \
     \( -background white -fill black -font Alegreya-Regular -bordercolor White \
         -gravity West -border 20 -pointsize $pointsize -size ${textwidth}x caption:"${file%.*}" \) \
     +append \) \
     -extent ${width}x${height} \
     \( -fill none -stroke gray -draw "rectangle 0 0 $(echo $width - 1 | bc) $(echo $height - 1 | bc)" \) \
     "out/$file.png"
done
#+end_src

Sample resized label:

I moved the ones I wanted from the out directory to a ready directory and combined the ones I wanted to print into a PDF:

#+begin_src sh :dir ~/code/labels :results silent
montage ready/*.png -tile 3x5 -background none -geometry +0+0 print.png
convert print*.png -density 300 -quality 100 print.pdf
#+end_src

Then I printed the labels in colour on an 8.5×14″ sheet of paper (single-sided, landscape), cut them out, and taped them onto the bins with packing tape.

W- suggested taking macro shots that more clearly show the characteristics of things in the bins instead of just aiming down and taking pictures of the contents. Might be a good excuse to show A- basic product photography when we get back.

W- also recommended making the label text bigger. The first time I did it, I just picked a pointsize based on whatever fit the ones I wanted to print. I decided against letting Imagemagick maximize the font size because I didn’t want labels to have very different text sizes. After a little poking around, I figured out how to use caption: instead of label: to give me text that can neatly wrap within a given space, and that will probably let me use 90-point font instead of 72-point font. That will make the next iteration of labels even easier to read.

It’s nice having all these bins. A- is getting pretty good at heading straight for the bin she wants something from, and she even talks about them: “Horse is in animals bin.” I’m glad we labeled the most frequently used bins. I’ll tweak the labels when we get back from our trip. We’ll probably change some of the bin contents anyway.

Hooray for ImageMagick, and hooray for variables in org-babel blocks!

Oops report: Moving from i386 to amd64 on my server

I was trying to install Docker on my Linode virtual private server so that I could experiment with containers. I had a problem with the error “no supported platform found in manifest list.” Eventually, I realized that dpkg --print-architecture showed that my Ubuntu package architecture was i386 even though my server was 64-bit. That was probably due to upgrading in-place through the years, starting with a 32-bit version of Ubuntu 10.

I tried dpkg --add-architecture amd64, which let me install the docker-ce package from the Docker repository. Unfortunately, I didn’t review it carefully enough (the perils of SSHing from my cellphone), and installing that removed a bunch of other i386 packages like sudo, ssh, and screen. Ooops!

Even though we’ve been working on weaning lately, I decided that letting A- nurse a long time in her sleep might give me a little time to try to fix things. I used Linode’s web-based console to try to log in. I forgot the root password, so I used their tool for resetting the root password. After I got that sorted out, though, I found that I couldn’t resolve network resources. I’d broken the system badly enough that I needed to use another rescue tool to mount my drives, chroot to them, and install stuff from there. I was still getting stuck. I needed more focused time.

Fortunately, I’d broken my server during the weekend, so W- was around to take care of A- while I tried to figure things out. I had enough free space to create another root partition and install Ubuntu 16, which was a straightforward process with Linode’s Deploy Image tool.

I spent a few hours trying to figure out if I could set everything up in Docker containers from the start. I got the databases working, but I kept getting stymied by annoying WordPress redirection issues even after setting home and siteurl in the database and defining them in my config file. I tried adding Nginx reverse proxying to the mix, and it got even more tangled.

Eventually, I gave up and went back to running the services directly on my server. Because I did the new install in a separate volume, it was easy to mount the old volume and copy or symlink my configuration files.

Just in case I need to do this again, here are the packages that apt says I installed:

  • General:
    • screen
    • apt-transport-https
    • ca-certificates
    • curl
    • dirmngr
    • gnupg
    • software-properties-common
    • borgbackup
  • For the blog:
    • mysql-server
    • php-fpm
    • php-mysql
    • php-xml
  • For Quantified Awesome:
    • ruby-bundler
    • ruby-dev
  • For experimenting:
    • docker-compose
  • For compiling Emacs:
    • make
    • gcc
    • g++
    • zlib1g-dev
    • libmysqlclient-dev
    • autoconf
    • texinfo
    • gnutls-dev
    • ncurses-dev
  • From external repositories:

I got the list by running:

zgrep 'Commandline: apt' /var/log/apt/history.log /var/log/apt/history.log.*.gz

I saved my selections with dpkg --get-selections so that I can load them with dpkg --set-selections << ...; apt-get dselect-upgrade if I need to do this again.

Symbolic links to old volume:

  • /var/www
  • /usr/local
  • /home/sacha
  • /var/lib/mysql (after installing)

Copied after installing – I’ll probably want to tidy this up:

  • /etc/nginx/sites-available
  • /etc/nginx/sites-enabled

Lessons learned:

  • Actually check the list of packages to remove.
  • Consider fresh installs for major upgrades.

When things settle down, I should probably look into organizing one of the volumes as a proper data volume so that I can cleanly reinstall the root partition whenever I want to.

I also want to explore Docker again – maybe once I’ve wrapped my mind around how Docker, Nginx, WordPress, Passenger, virtual hosts, and subdirectories all fit together. Still, I’m glad I got my site up and running again!

Decision review: Samsung Note 8

It was quite a big jump going from a Moto G (2nd gen, bought in 2015) to a Samsung Note 8 this year, mostly on my dad’s insistence. Here’s how I’ve been working on making the most of my new phone’s capabilities.

  • Camera: Way more pictures of A-, since the camera works decently even in low light. I like how it reminds me to clean the camera lens.
  • Better battery life, quick charge: This is great. I used to keep W-‘s old Moto G handy so that I could swap to it if my phone battery ran low while I wrote in bed. Now I don’t even worry about charging overnight, since I can charge my phone while having breakfast with A-.
  • More storage: It’s nice not having to decide which apps I have space for on my phone. I even used the SD card to copy thousands of archived photos into Google Photos.
  • Pen: Screen-off notes are really quick to scribble down, since all I need to do is take out the pen and start writing. I trust writing more than typing for taking fast notes. I also really like the ability to select part of the screen and extract text, because sometimes apps don’t make it easy to select and copy text. I’ve used the pen to draw and colour illustrations for a book for A-. It’s more awkward than using my tablet PC or the iPad, but it lets me use phone time to get more things done, so it’s worth it.
  • Fingerprint scanner: Surprisingly handy way of reducing the friction of using my phone. I keep my phone locked when the screen is off so that A- doesn’t play with it, and tapping the fingerprint sensor to unlock the phone saves me a bit of fumbling around.
  • Voice and gesture control for pictures: Great for taking pictures, since it’s not easy to hold and shoot with one hand.
  • Speech recognition in general: I’ve been getting the hang of this now that battery life means I’m a little less worried about leaving my phone listening all the time. I have a few shortcuts for tracking activities, and I often set timers and add grocery items by voice too. It’s still not quite reliable, but it’s worth a shot. A- occasionally parrots “Okay Google” and “Command sent,” so I try to model saying “please” when I ask my phone to do things. I haven’t used Bixby as much, since voice wake-up for Bixby interferes with voice control of pictures.
  • Larger screen: This was a little hard to get used to, since the bigger screen makes it hard to put my phone in my pocket or hold in bed. But it does make it a little more manageable to ssh into my server and do things, although working with a virtual keyboard is still annoying. I’ve also used the split screen feature a few times.
  • Edge apps: I’ve used the clipboard and the ruler a few times.
  • Live focus: I’ve used this a few times, but I usually don’t have much time to compose a picture of A-. Maybe when she’s a bit older, or if I think about it more.

I want to explore more of the camera’s features, figure out a good workflow for photos, learn more about what I can do with speech recognition, and get better at workflows for notes (thoughts, images, and e-books).

I wonder if it makes sense to draw more on my phone than on paper even when A- is around. I haven’t been keen on doing so because she usually wants to imitate me, and she gets more out of drawing on paper than on my phone. Maybe I’ll draw on paper and take quick pictures on my phone instead.

I probably won’t upgrade for a while, since it’s likely to be a bit of a hassle selling this phone and upgrading to a new one. I might be tempted by an even better camera in the next phone. After all A- is only this age once. I really like the stylus. That means keeping an eye on the Samsung Note line and figuring out when it makes sense to upgrade. I hope this phone is sturdier than the Samsung Galaxy S3 I experimented with years ago. This one has survived life with a toddler so far, so that’s good. I spend more time on my phone than on my laptop these days, so it’ll be interesting to see how I can make the most of it.