Stuff I made in Summer 2017

This post will be a bit different than my usual semester blog posts. Doing things has been the most interesting and memorable part of my summer, not thinking about things, so instead of telling you about what I thought about, I’ll show you the two most demonstrable things I made this summer: text formatting in Messenger and two tools to make window tiling easier.

Text formatting in Messenger

During an internal hackathon at Facebook, I added LaTeX math typesetting to Facebook Messenger’s web client. I also added *bold*, _italic_, ~strikethrough~, and `monospace` ranges…

Screen Shot 2017-09-02 at 11.27.27

…and both of these projects made it into production! You can read about them in the Facebook Help Center. Additionally, people on r/math have figured out all the features and easter eggs in math mode.

I actually wanted to make math in Messenger happen even before I signed my internship offer at Facebook. Being able to type math in Messenger would have been helpful throughout high school and the first few years in college when I was still taking math courses. I recall that at one point I even had someone join a nonce chat room on MathIM so that I could explain some calculus problem to them.

With math typesetting on Messenger, math students and researchers who talk about math every day won’t have to use ugly ASCII symbols to express themselves to other people online in the area of their expertise.

As for text formatting, practically every other chat client that’s newer than IRC has formatting, so there’s no reason we shouldn’t have at least some of the basics.

Window tiling solutions

I used two 1440p displays at work over the summer, and now that I’m back at school I upgraded to a 43 inch 2160p monitor. That’s equivalent to four 21.5″ full HD monitors, but with no borders in the middle. To optimize how well the screen estate is used on such a huge monitor, it’s much better to have many windows on the screen at once instead of one huge window. And since I’m bothered by inconsistency, I wanted to be able to switch between windows quickly and resize them quickly using only my keyboard.

The first little tool I made is a window switcher that lets you switch to any window visible on your screen by pressing alt-tab, followed by the first letter of the app’s name. (If there are multiple apps that start with the same letter or multiple windows of the same app visible, it’ll display the next available unused letter. For example, see the Chrome inspector, G for “Google Chrome”, alongside the actual browser, which is assigned H.) To me, this is more predictable and easy to use than the default cmd-tab switcher. I never remember which windows I focused most recently, so I have to wait until the switcher loads before I can select a window. With this, I know exactly what I need to press before the letters even pop up. Here’s a demo of the switcher in action:

(It’s faster when I’m not making a QuickTime screen recording.)

The second tool, shown right at the end of the video, is a keyboard-based tiling manager that lets you tile windows on any grid from 1×1 to 10×10. All you do is press alt-space, type the number of columns and rows, then the column and row number to move the window to, and then the number of columns and rows the window should take up. For example, the invocation for putting a window that takes up the right 3/5 of the screen but only the top half would be alt-tab 5 2 3 1 3 1. This can be a bit confusing for larger grids, but it’s doable, and for smaller grids, it’s pretty easy to gain muscle memory for the commands. There are a few special shortcuts for common grid sizes, including 1×1 (maximizing a window), 2×1, 2×2, 3×1, 3×2, 4×1, 4×2, and 4×4. In addition, if the number of rows in the grid is equal to 1, you can skip typing in the row numbers for position and size. So moving a window to the left half of the screen is simply alt-tab H 1 1 (H is the shortcut for halving the screen, i.e. 2×1 grid).

It’s not a feature right now, but a possible future expansion would be the ability to show an overlay of the grid on top of all the windows as you’re typing your invocation. That might make it a bit less arcane…

Both of these tools are written in Lua using Hammerspoon, a powerful automation tool for macOS. I highly recommend it over other window management apps for people who don’t mind a bit of coding. The app is stable, endlessly customizable, and well documented. If you’re interested in my scripts, they’re in one of my dotfiles repos. The switcher is navigator.lua, and the tiling manager is mosaic.lua.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s