# Computable Multiverse

Hi, I'm Rakhim. I teach, program, make podcasts, comics and videos on computer science at Codexpanse.com. You can learn more about my work and even support me via Patreon.

## Fast automatic remote file sync

Our dev machines at Hexlet are remote, since the project is too big and resource-heavy for laptops. This good decision made by our CTO also means that the dev environment is freed from additional layers of complexity like managing Vagrant and Vbox.

Most of the devs work directly on the remote machines using vim. I used Sublime before Emacs, and seamlessly synced all changes using an excellent SFTP package. There’s a similar (and free) package for VS Code.

The canonical solution for Emacs is TRAMP. It’s pretty cool, but not suitable for my workflow. I want instant feedback when navigating the project with Projectile and searching all files using ag. TRAMP is slow as hell for these.

A possible solution is to sync files from local to remote using rsync and do it automatically when files change. Doing full folder sync is slow. Luckily, rsync has --files-from option. You can specify a list of files to sync. So, use fswatch to watch changes, and run rsync for each changed file.

Thanks to Alistair Phillips, I didn’t have to write the whole script myself. Here is what I got in sync.sh:

#!/usr/bin/env bash
rm --force /tmp/remote-server-rsync.txt
rm --force /tmp/remote-server-rsync-relative.txt

echo "Starting initial sync..."
rsync --verbose -azP --delete --exclude='.git/' --exclude='.DS_Store' --exclude='tmp/' . remote_user@XXX.XXX.XXX.XXX:/home/remote_user/hexlet
echo ""

echo "Watching..."

fswatch --exclude=".git" --batch-marker=EOF -xn . | while read file event; do
if [ $file = "EOF" ]; then printf "%s\n" "${list[@]}" > /tmp/remote-server-rsync.txt
sed -e "s,/Users/rakhim/code/hexlet/,," /tmp/remote-server-rsync.txt > /tmp/remote-server-rsync-relative.txt
echo "Beginning sync..."
rsync --verbose --files-from=/tmp/remote-server-rsync-relative.txt . remote_user@XXX.XXX.XXX.XXX:/home/remote_user/hexlet
echo "sync completed"
echo "Watching..."
list=()
else
list+=(\$file)
fi
done

The workflow looks like this:

1. Run ./sync.sh
2. That’s it :-) Just edit files and save them as usual. It takes about a second to sync.

## Make Firefox faster and nicer on macOS

I’m trying Firefox as my primary browser on all devices. It has some great features like Multi-Account containers in addition to being a non-Google product, which is an increasingly rare feature on the web nowadays.

Firefox on macOS is somewhat sluggish at the moment. If you try the current stable version 62 or current beta version 63, you’ll notice some lags and general slow response time for even the simplest tasks like changing tabs.

Mozilla will probably fix these issues in the upcoming releases. Meanwhile, I found the following steps improve the performance significantly.

As of today (October 1, 2018), stable release version is 62. Version 63 is currently in beta, and I recommend using it today. It’s very robust, I haven’t had any problems with it. There are some important performance improvements in it.

You can also try Firefox Nightly, it is currently version 64 on the dark side. Nightly is an unstable testing and development platform. By default, Nightly sends data to Mozilla — and sometimes their partners. There are some rough edges, I wouldn’t recommend it for daily browsing.

## Disable animations

By default Firefox has lots of animations. I find them unnecessary and distracting, but more importantly, they contribute to the general sluggishness.

Go to about:config in the address bar. Search for animate and set at least cosmeticAnimations to false.

Fullscreen transition takes 0.2 seconds both ways. Make them instant by setting the following to 0 0:

• full-screen-api.transition-duration.enter
• full-screen-api.transition-duration.leave

## Disable Pocket

Firefox embedded Pocket into the browser. A questionable move, but it’s easy to disable (unless you use it, of course). Set extensions.pocket.enabled to false.

## Other stuff

These are not related to performance, but can make your Firefox experience a bit nicer.

Set to true:

• modalHighlight highlight all the search results.
• browser.tabs.closeTabByDblclick close tab by double-clicking on it.
• abs.multiselect shift-click on tabs to select a group of tabs and do something with them (for example, detach from window).
• insecure_connection_text.enabled write “Not Secure” in the address bar of non-https pages (like Chrome does). Additionally, enable a broken padlock icon with security.insecure_connection_icon.enabled.

Minor things:

• general.smoothScroll.mouseWheel.durationMaxMS set 200 to make scrolling speed similar to Chrome.
• geo.enabled set to false to disable geolocation.
• extensions.screenshots.disabled set to true to disable the screenshot extension. It’s actually pretty handy, check it out before disabling.