newline

Alex Balgavy's blog. I write stuff here sometimes.

My homepage.

Here's my dotfiles repository.

My keys: PGP, SSH

My crypto wallets (BTC, XMR)

Latest posts (Tags)

Subscribe via RSS/Atom.

Creating a custom RSS feed for a web page with RSS-Bridge

September 29, 2024

RSS-Bridge is a way to create an RSS feed for a web page that doesn’t provide one. Unfortunately, this is increasingly more common, as publishers prefer you go to their website so they can serve you ads and track your activity, or they want your email so they can spam your inbox and/or sell your info. RSS-Bridge is essentially a framework to generate an RSS feed for any web page, to ‘bridge’ the web with RSS. Here’s how you can use it to create a new RSS feed.

Writing your own (derived) Emacs Org export backend

September 27, 2024

I frequently use Emacs to write things that eventually need to be entered in some other tool (Jira requirements, Confluence pages, etc.), mainly because of Org mode’s great support for text format conversions (and it’s more comfortable for writing). It means I can just write things in Org mode, then export them to a temporary buffer, and copy-paste them to whatever tool they need to end up in. For Confluence, there’s already a very nice Org export backend, as part of the org-contrib package. If you use that to export to a temporary buffer, yank it, then press control-shift-d in Confluence, and paste it in to get nicely formatted text – that already feels a bit like a superpower. However, I noticed the export is lacking some things that I wanted, and including some things I didn’t want. I could make changes to its code, open a pull request, and get it upstreamed; that’s more work though, requires a response from the owner, and I’m not sure if other users even want these changes. I could fork it, but then I have to maintain a fork. Emacs is extensible, so there’s a better way to do this, as part of my config – here’s how.

Creating a custom Emacs input method for box drawing characters

September 13, 2024

I wanted to manually create some file tree diagrams that look like those generated by tree, but without having to copy-paste or enter the Unicode for every box drawing character (, , etc.). In Emacs, I could do a C-x 8 RET and search for the name (e.g., “BOX DRAWINGS LIGHT HORIZONTAL”), but still, having to do that for every character is a hassle. I could assign some keys to each of those characters, and then press C-x 8 and the assigned keys to type the characters (like C-x 8 a > for ), but that’s still too many keypresses. There’s an even better way: a custom input method, which I can toggle with a single key combination.

Accessing your Linux computer from Windows on a local network

September 10, 2024

I have two computers I use simultaneously: Windows 11, and Linux (Ubuntu, on X11 with dwm). I wanted to use both on the same big monitor, without needing to change inputs…could I use some kind of remote desktop from the Windows machine? The answer is yes - VNC. Here’s how you can do that.

How to proxy your browser through an SSH connection

September 09, 2024

I had a need to access some things on the internet from a different IP address, because of temporary issues with my regular IP. So I thought, what if I could send that data through an SSH connection via my VPS, and access stuff from the IP of my VPS? Turns out that’s totally possible, here’s how you do it.

Upgrading LineageOS 20 to 21 on a Samsung Galaxy S10

July 20, 2024

Thanks to Linux4’s work and that of the LineageOS team, we have another major upgrade for Samsung Galaxy S10. Because it’s a major version change, this upgrade is a manual process. This time with the additional caveat that you have to wipe your data to upgrade. I was done in around half an hour, but then it took several hours to restore all my data.

Creating a function timeout decorator in Python

May 02, 2024

I had some Python code that did some processing and called external programs, which could run for a very long time and potentially not terminate. I wanted a simple solution to run some Python function with a timeout, and if it completes within the time limit, to get back its result. It would be ideal to only have to decorate a function with @timeout(number_of_seconds), and have the rest done automatically. Read on for my solution to this, and a discussion of the problems I ran into. Python 3 btw.

Managing systemd journal size

April 28, 2024

You may find that /var/log takes up a bit of space on your filesystem. Upon running du -sh /var/log | sort -h to get the size of each file/directory, you see that /var/log/journal takes up over a gigabyte in size (or at least I did). Here’s how to deal with that.

Getting out of a Magisk-induced bootloop

April 27, 2024

You install a module via Magisk on your phone, reboot…and reboot…and reboot…and reboot…you’re in what’s called a bootloop. Something you installed caused a problem somewhere in the boot process, and now you can’t start your phone. However, fear not – the Magisk devs have accounted for this.

Upgrading LineageOS 19 to 20 on a Samsung Galaxy S10

May 04, 2023

Time for another major LineageOS upgrade: 19 to 20. Because it’s a major version change, this upgrade is a manual process. I was done in maybe 15-20 minutes; there’s no need to wipe your data. It was mostly the same as from 18 to 19, but I had to fix enterprise WiFi connections and root access.

Monkey patching: why Ruby is the best for prototyping and one-off scripts

September 09, 2022

In Ruby, ‘monkey patching’ lets you extend a class definition (with e.g. new methods) at runtime, for any class, even built-ins like Integer and Object. This gives you an incredible amount of flexibility, especially when you’re writing a one-off script, just working in a REPL, or prototyping something. Here’s two such ‘monkey patches’ I used today that prompted me to write this post.

TIL: How to track down a shell configuration option (alias, variable, etc.)

September 07, 2022

Sometimes you find that you have an alias defined in your shell, or an environment variable that you set. However, you’re not entirely sure where it’s defined. Here’s how you can figure that out.

A practical example of why Ruby is a great language: comparing works cited in two sections of a paper

August 07, 2022

I’m writing a research paper, and I wanted to determine if all the papers I’ve cited in my main text were also mentioned in the discussion. Because Ruby is so easy to write and ‘tape together’, it only took a few lines to get the list of papers I still need to mention. In general terms, the goal was to find uses of a group of LaTeX commands with a varying argument in two sections of text (different types of \cite{key} with a varying key), and determine which arguments (key) occur in one section but not in the other. Continue reading to see the power of Ruby in action when solving this.

Writing a CLI lookup tool for Forvo.com

June 22, 2022

In this post, I show how I analyse the behavior of the website Forvo, which I use to find audio clips with pronunciations of words in various languages. Then I show how I can quickly script a CLI interface for the website; this technique is applicable to a variety of websites.

Solving MASTER BOOT RECORD's newest challenge: Personal Computer

May 14, 2022

The musician MASTER BOOT RECORD, which I’d describe as ‘chiptune synth metal’, does something unique: with every album release, he crafts a challenge, and when you solve that challenge, you gain access to bonus music. The challenges usually involve analysis, cryptography, and other CTF elements. With his new album, Personal Computer, he also created such a challenge. This post explains the steps I took to solve it; read on for spoilers.

Upgrading LineageOS 18.1 to 19.1 on a Samsung Galaxy S10

May 13, 2022

After waiting for some time (as one should before any large upgrade, to give issues time to surface and be fixed), I decided it’s time to upgrade to LineageOS 19. The updater built into LineageOS doesn’t let you upgrade to a new major version, so this upgrade is a manual process. It took me around half an hour to complete without any issues, and you do not need to wipe your data; read on to see what I did.

An introduction to Python decorators

May 11, 2022

I’d never taken the time to wrap my head around decorators in Python, but I watched a video from PyCon 2021 today which explained them well. I decided to write this post to share the knowledge; read on for my explanation of decorators. In this post, I assume the reader is comfortable with functions in Python. If you’re not, you might want to do some preliminary reading.

Determining MP3 audio quality with spectral analysis

April 10, 2022

You might have an MP3 file that says it’s high quality, but you want to know for sure. Spectral analysis is a great method to determine the real bitrate, and thus the real quality, of an MP3 file. In this post, I explain a bit of theory regarding MP3 audio, and then I demonstrate how to analyze the spectrum of an audio file in practice and consequently deduce its bitrate.

OT: build habits by tying them to your existing routine, or how I tricked myself into doing more pushups

March 30, 2022

This is my first post with the ‘OT’ prefix, meaning ‘off-topic’. Usually, I write more technical posts - related to programming, the command line, Linux, and technology overall. So, off-topic posts will be ones that discuss things unrelated (mostly) to technology. They might be about random thoughts, philosophy, tips…basically anything I think is worth sharing with the public.

In this post, I discuss habit-forming and a specific ‘trick’ that’s helped me remember habits: binding the desired action to an action that I already do regularly. Read on for more details, and a discussion of how this has helped me.

Setting up Emacs as a daemon on macOS

March 26, 2022

I use Emacs as my daily planner and for a few other things (I might write a separate blog post about this – don’t worry, I still use Vim, I actually use both). However, one of the problems with Emacs is that it’s a bit slow to start up, especially since I have it refresh packages on startup, which is synchronous. It gets annoying to have to wait through that startup sequence whenever you want to use Emacs. A common way to solve this is to have Emacs run automatically when you log in, keep it running in the background as a server, and then connect to the running session with emacsclient. But this is not a solution for me, because I don’t want it always running in the background, since there are times when I don’t use Emacs. Read on to see what I did.

Using Microsoft Office365 with Neomutt (+ isync + msmtp)

February 04, 2022

My university switched its Microsoft Office365 email system to just “modern authentication”, and I suspect a lot of other companies using Microsoft’s stack did the same around this time. What that means is, unless I use what’s deemed a “modern application”, I won’t be able to access my email. However, I like my email the way I have it: on the command line, scriptable, and synced offline. It took some time, but I figured out how to make my setup work with Office365 (fortunately, what Microsoft calls “modern authentication” is just marketing speak for OAUTH2); this post explains the steps. I’m using macOS, but the same can be achieved with similar steps on GNU/Linux (though not all steps might be necessary). I use the newest versions of all tools, installed via Homebrew unless I explicitly say otherwise.

A Practical Guide to GCC Inline Assembly

December 26, 2021

When you want to write part of your C code in assembly, you have two options. Either you can write and compile your assembly code separately, and then link it with the compiled C code, or you can write it inline. For the second option, GCC provides an extension that allows you to embed snippets of assembly code directly into your C code. However, its syntax is (perhaps infamously) complicated and unintuitive. This blog post will give you a more intuitive explanation for practical use, so that you can understand and use inline assembly if needed.

Passing SafetyNet on LineageOS using Magisk

November 02, 2021

Some time ago, I installed LineageOS on my Samsung Galaxy S10. It’s been working great, but some apps detect that I have a custom ROM, because of SafetyNet (for example, Brave doesn’t let me claim rewards). In this post, I explain how I used Magisk to pass SafetyNet.

Fixing Wi-Fi on macOS when you can't turn it on

September 06, 2021

I was unable to turn on my Wi-Fi on macOS, the buttons in the menu bar and system preferences did nothing. In this post, I go over how I fixed it.

TIL: uBlock Origin supports XPath syntax!

August 17, 2021

If you’re using an adblocker, chances are you’re using uBlock Origin. And if you’re not, you should be using it. Anyway, I just found out that uBlock supports XPath syntax, and here’s how to use it to hide elements on a page.

Why you should use Anki, and how to get started

August 10, 2021

In simple terms, Anki is a flashcard program. But more than that, it’s a system that will never let you forget anything. As long as you do a regular review (daily is best, but every other day works too), you will always remember what you add to Anki. Read on for my opinion on why Anki is useful for everyone, and a simple ‘getting started’ guide.

My experience installing LineageOS on my Galaxy S10

August 03, 2021

I own a Samsung Galaxy S10, and of course that’s a phone that offers zero privacy out of the box. Plus it contains a bunch of software that I don’t want and don’t need, from both Samsung and Google. LineageOS started officially supporting the S10 a few months ago, so I decided to make the jump; read on to find out about my experience.

Archiving channels with youtube-dl

July 28, 2021

Things that are online may spontaneously disappear, or may be not-so-spontaneously removed by different companies. What if you want to archive your favorite Youtube channel so that, in case it gets deleted, you still have the videos? You can do this easily with youtube-dl.

Fix YouTube on iOS 9.3.5

May 04, 2021

I have an iPad Mini (1st gen) on iOS 9.3.5. Google is hard-at-work to kill off legacy devices/software, but for now, you can still get YouTube working.

TeX Live on macOS: Manually installing packages

March 11, 2021

I’m running BasicTeX on my Mac, and I wanted to install the tr2latex package to translate Groff/Troff files into LaTeX. This package is listed on CTAN, but isn’t part of TeX Live, so tlmgr didn’t give me any results. Here’s how you can install such packages manually.

Announcement: zeroalpha.codes domain expiration

January 26, 2021

My previous domain, zeroalpha.codes, expires soon (and hence so do all subdomains, like lectures.zeroalpha.codes). I’ve had it redirecting to alex.balgavy.eu for some time now, but in a month, this website will only be reachable via alex.balgavy.eu and subdomains. I’m not sure if anyone except me uses this website, but just in case anyone does, this is your PSA.

Why I use the Command Line

December 28, 2020

The ‘terminal’, ‘shell’, or ‘command line’. It’s an interface that you can easily reach by opening the “Terminal” application on macOS or Linux, but that most people avoid because they view it as “too complicated”, or they aren’t even aware of it. Well, I almost exclusively work on the command line, because it’s actually simpler and much more powerful. I’ll try to explain why, using a navigational analogy.

TIL: searching Git logs

November 29, 2020

I recently read a post about a way to search Git commit history for code, and I thought I’d summarise the post here. It’s mainly for my own reference, but others may find it useful.

Forwarding application sound on macOS

November 01, 2020

I ran into a problem recently regarding audio routing on macOS. I own a virtual drumset (an “air drum” setup where you drum in the air and a piece of software converts it to actual drums), and I wanted to forward that sound to a video call, while also being able to hear it myself. Perhaps you’ve had a similar problem, where you wanted to e.g. record system audio. This is easily doable, using BlackHole.

TIL: use multiple config files with Git

October 14, 2020

If you want to version control your files but don’t want to publish your name/email on Github, there’s an easy way to do this with multiple Git config files. You can include any other files in your config with the [include] section.

TIL: push to multiple Git remotes at once

October 07, 2020

Sometimes, you may want to sync your local Git repository to multiple remotes at once (e.g. Github and Gitlab). You could do this by pushing twice, but it’s much easier to set up multiple push remotes in Git, and handle everything with one git push.

TIL: insert unicode characters in Vim

September 24, 2020

You may already be aware of digraphs, which let you insert special characters using combinations of two keys (:h digraphs-use). However, Vim also lets you insert arbitrary Unicode characters, as long as your font/terminal emulator supports them. That includes emoji.

TIL: merge a Github PR entirely from your terminal

September 07, 2020

Let’s say someone makes a pull request (PR) to your repository, but you want to handle it from the commandline, without using the browser. Perhaps it’s the middle of the night and you don’t want to blind yourself with a white screen. Whatever your reasons may be — all you need is a git fetch.

Cheat sheets accessible from anywhere, with cheat.sh

June 24, 2020

Cheat sheets are great. They let you find the most important information about a command at one glance, without having to go scuba-diving in the man page. There are lots of projects that aim to be a package of such cheat sheets: tldr, bro, eg, and cheat, just to name a few. But the downside of all of these is that you have to install something. Most of them have dependencies. You can’t just get a cheat sheet from anywhere, any time. That’s why I use cheat.sh exclusively, which provides cheat sheets in plaintext, accessible with a single HTTP GET request. You can send that request with curl (most common), but you can also use a browser, or any other HTTP tool. Doesn’t matter whether you’re on Ubuntu, Arch, macOS, Windows, Android, Raspberry Pi, or a potato (as long as it has internet access and supports HTTP).

TIL: reader mode in Google Docs/Slides/Sheets

April 28, 2020

Sometimes, you just want to read a Google document, and in those cases the UI might be overwhelming. It definitely is for me. The good news is you can easily get rid of that UI by replacing the /edit in the URL with /preview. And you can automate it with a simple bookmarklet.

TIL: Git shortlog

April 27, 2020

Let’s say you’re working with a Git repository, and you want to see a summary of the commits. One way is to do git log, but that lists all of the commits. What if you wanted to summarise the commit history in some way, e.g. to determine the amount of commits per author, or see who has committed during a certain timespan? Enter git shortlog, a way to summarise git log output.

TIL: actually free up space on macOS APFS with tmutil

April 16, 2020

I deleted around 150 GB of files from my APFS volumes, but I ran into a strange issue. The storage section in “about this mac” showed the free space; however, df and Disk Utility both showed the old free space (which was around 8 GB). I figured out that this is because starting with High Sierra, drives with APFS create local snapshots that can be used by Time Machine to restore files. The snapshots are invisible to the filesystem, so you can’t find them with a simple du -skh *.

Git push to your filesystem (or Dropbox)

March 11, 2020

If you use Git, chances are you have repositories on GitHub or GitLab, and whenever you run git push, you send the contents of your local repo to one of these sites. But did you know that you don’t actually have to rely on services like GitHub/GitLab to be able to git push? You can push to Dropbox, Google Drive, NextCloud, or any other service that can sync a local folder on your computer. What I mean is, you can make pretty much any folder on your filesystem into a Git remote repository.

GPT: Recovering Partitions From a Disk With a Broken Partition Table

September 08, 2019

I recently did a Linux installation onto my secondary hard drive, which also contains a FileVault-encrypted HFS+ volume. Well, when I booted back into macOS, I found out that the volume was suddenly unreadable, and all of my books, movies, music, etc. were therefore gone. What now?

Test a Live USB With VirtualBox

August 07, 2019

Often, I’ve wanted to test a live USB without having to reboot my computer. This is made quite easy with VirtualBox, and here’s how you do it.

Toggle Dark Mode With a Single Shortcut on macOS

August 02, 2019

Switching from light mode to dark mode is quite easy by itself. But what if you want to also change your Terminal theme and your Vim theme, all with a single keyboard shortcut? Then it gets a little more complicated, but it’s still possible. Here’s how you do it.

TIL: the fc builtin

August 01, 2019

This my first post with the “TIL” prefix, meaning “today, I learned”. I’ll use it to designate posts that aren’t full-blown guides, but rather small things I found out (and hence these posts might be less self-contained).

The fc command is a shell builtin that lets you work with commands that you previously typed in, and its name stands for “fix command”. It has two forms: in the first, you can interactively edit a range of commands, while in the second, you can re-run a previous command after doing a replacement.

Editing Efficiency in the Terminal: Learning Readline Bindings

July 31, 2019

Everyone has their favorite editor, and some would fight to the death to defend their editor. Editors are also a common topic of blog posts — how to use a specific editor, how to configure it, what plugins to use, etc. People mention Vim, Emacs, Atom, Sublime Text, VS Code…but nobody ever talks about the editor that you use the most on the command line — the shell prompt. In my opinion, the shell prompt is actually quite a powerful editor, and I hope this post will serve to convince you.

Hello World

July 25, 2019

This is my first post, just checking if everything’s working correctly.