Using GoogleTest with CMake

If you’ve worked in a large C++ codebase within the last couple of years, you’ve probably come across the GoogleTest unit testing framework. Chances are you’ve also encountered everyone’s favorite build generator: CMake. In this article, you will see two options for integrating GoogleTest into your next CMake project. The content that follows is largely a condensed version of the tips found in “An Introduction to Modern CMake”. This post summarizes the bits relevant to using CMake with GoogleTest to act as a quick reference when setting up future projects. ...

January 23, 2024 · 3 min

Signing Git Commits With GPG

If you’ve been around the open source community long enough, you’ve probably heard of people signing their VCS commits/tags. This post covers the why and how of signing your Git commits. The focus will be on commits but keep in mind that these tips equally apply to tags. Why Sign Your Commits The short answer is, signing your commits makes it harder for an attacker to impersonate you. Sure, if you work solo on rinky-dink toy projects, having your commits signed isn’t a big deal. Now consider the case where you make commits to an open source project with sensitive code or at your day job where you make commits and PRs on a product. It might be worth safeguarding those commits just a bit. ...

January 21, 2024 · 6 min

Dotfile Mgmt With GNU Stow

Do you have a bunch of dotfiles? Do you maintain a GitHub repo with all your dotfiles? Whenever you upgrade your machine, do you find yourself manually placing the dotfiles in the right spots in your home directory? If you answered yes to these questions, read on. Enter GNU Stow GNU Stow is a dotfile management utility. Stow has all the makings of a varsity athlete: Stow is small (a 32KB Perl script). Stow is simple to use with a solid manpage. Stow doesn’t get in the way of version controlling dotfiles. Real world Stow usage is pretty simple and best explained with an example. Imagine you had your i3wm and Bash configurations stored in your home directory. The layout might look something like this: ...

January 20, 2024 · 2 min

The Game of Life

If you grind old Advent of Code problems, you might notice a particular style of problem crop up more than once. The people of Reddit refer to their solutions as a variation of Conway’s Game of Life (GoL). Wikipedia has a great article on GoL. The animations are eye catching. The Wiki serves as motivation for a terminal app that visualizes GoL simulations. Rules of the Game What are the GoL rules? The setup is simple. You have an MxN grid of “cells.” Each cell is always in one of two states: live or dead. The grid transitions through states on a frame tick. You apply the following rule at each tick. ...

December 1, 2023 · 6 min

ncube: A Cube in Your Terminal

You ever come across one of those ASMR programming videos? This video where the developer programs a terminal display with a couple of spinning cubes is neat. This video is the motivation for the development of a ncurses application that renders a user controlled 3D cube. Perspective Projection and Rotation Matrices So how do you take an object in 3D space and visualize it in 2D space? The answer is perspective projection. Many videos explain the technique in detail. One of the better videos is “Carl the Person”’s (cool name by the way) video tutorial: ...

November 16, 2023 · 7 min

keylogger: A Cross-Platform Keylogger

If you’re familiar with the kbhell application, you might realize that kbhell is about 90% of the way to being a keylogger. Why not finish the job and write a proper, cross platform keylogger that captures a victim’s every keystroke (for science reasons, of course)? The Requirements So there’s the obvious requirement of capturing user keystrokes. When you think about the fact that keyboards have different layouts, there are different language sets, etc., the task becomes challenging. ...

November 13, 2023 · 7 min

Linux Driver Development for Embedded Processors

If you’ve already read through “Linux Device Drivers”, it may be worth your time to read a more focused Linux driver development textbook. ARM driver development has been popular for some time now and remains relevant today. “Linux Driver Development for Embedded Processors” (ELDD for short) gives a modern look into the development of ARM drivers on Linux. ELDD has a number of selling points: Labs targeting multiple ARM processors: NXP iMX7D, Microchip SAMA5D2 and Broadcom BCM2837. Excellent Device Tree introduction with many examples. Plenty of labs using real hardware. This article dives into the details starting with processor support. ...

October 7, 2023 · 5 min

A Beginner's Memory Allocator

While reading through the awesome “Operating Systems: Three Easy Pieces” book, I came across the topic of memory allocators. While always having an inkling of how functions like malloc() and free() work under the hood, I never considered writing a custom allocator. To help demystify the topic, I decided to write a basic allocator on Linux. The Interface What does the API look like? The API is identical to that of malloc()/free() with only two major deviations: ...

September 12, 2023 · 14 min

Keyboard Hell

Do you enjoy the sound of a mechanical keyboard? What if it was possible to achieve the sound of the keys clacking without having an actual mechanical keyboard? That was the idea that spawned this keyboard hell (kbhell) project. That and trolling friends by playing a soundbite every time they press a key! Getting Started When a user performs any keystroke, a audio file gets played. One of the main kbhell requirements is that it runs on both Windows and Linux. That leaves you with two problems to solve: ...

September 2, 2023 · 7 min

Morse Translator

While on a LeetCode grind, I came across a fun problem involving Morse code: Unique Morse Code Words. You might wonder what the encodings sound like. With a little programming magic you can find out by creating a command line utility for converting text to Morse code audio. The Basics The journey starts at the Morse code wiki page. The wiki had a chart that sums up the protocol: ...

August 1, 2023 · 7 min