Cartoon portrait photo of Sidney Liebrand

Things I learned

This page lists some of the things I learned over time. They aren't necessarily front-end related though, but have been very useful to me to this very day!

Every time I upgrade Ubuntu something fails. One of these things is audio. For some reason, upgrading breaks my audio setup in weird ways, I have speakers connected as "Line Out" and a wireless headset. After an upgrade Ubuntu may refuse to play audio through my headset entirely, this can be fixed by removing pulse config:

rm -rf ~/.config/pulse

On restart, Ubuntu will create a fresh config file which will work.

Another thing that fails for me after upgrading Ubuntu is that my headset likes to "take control" over the audio even though it isn't switched on. The (likely) reason this happens is because the hub my headset connects to is in fact, always on, and gets detected after "Line Out". Pulseaudio has a setting located in /etc/pulse/default.pa to automatically switch to "newly connected" audio devices.

Since this is never what I want, I have to disable it by editing the file and commenting out load-module module-switch-on-connect like this:

# load-module module-switch-on-connect

When recording animations for my posts I use a gif recorder. However, while not the most efficient format, .mp4 browser support is a little bit better than .webm so aside from generating .webm files, I also like to create fallback .mp4 files. This ffmpeg command converts a .gif to a more efficient .mp4 file:

ffmpeg -i file.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" file.mp4

The -px_fmt yuv420p and -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" are required for mobile browsers (mainly for mobile Safari from my experience) to be able to display the files.

Just in case the stackoverflow link ever goes away, this backup link explains it as well.

When recording animations for my posts I use a gif recorder. However, using .webm files is more efficient and works in most browsers today. This ffmpeg command converts a .gif to a more efficient .webm file:

ffmpeg -i file.gif -c vp9 -b:v 0 -crf 40 file.webm

This is something I use so that I can deploy mkdx my markdown vim plugin, to vim.org.

vim.org doesn't allow zip files that are too large and the documentation I wrote contains a lot of example gif files. So to keep the zip size low I use the following command:

zip -r mkdx.zip mkdx -x "*git*" -x "*.gif" -x "*test*"

This recursively adds files while excluding any git, gif, or test files / directories.