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....

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: The chart though labeled “International Morse Code” seems basic....

August 1, 2023 · 7 min

Binary Rain

Most programmers young and old have seen the cyberpunk sci-fi film The Matrix. One of the most outstanding parts of the movie is the closing scene where Neo sees the Matrix when battling the Agents: The visual effect with the code running along all the surfaces is iconic. Seems other people thought so too to the point that the effect has a name: Matrix Digital Rain. Wouldn’t it be neat to create a terminal screensaver that mimicked the effect seen in the movie?...

July 23, 2023 · 6 min

A CLI Base Converter

When debugging an embedded system, it’s common to work with raw data requiring conversion between decimal, hexadecimal, binary, and sometimes octal number systems. The Python REPL and printf shell utility do the job but are tedious to use for the simple task of base conversion. It would be nice to drop the overhead of format specifiers and fear of numerical limits. To ease the pain, I decided to write a command line utility that made conversion between positive binary, decimal, octal, and hexadecimal numbers of arbitrary size....

July 8, 2023 · 6 min

Huffman Coding

Implementing a Huffman Tree is a fun afternoon project for anyone interested in learning about data compression. A Huffman Tree is a type of binary tree that sees use in the compression of an arbitrary data file. Developing a command line utility to compress/decompress a file using Huffman coding is a good CS101 challenge. Breaking It Down Into Steps This project starts where many do: Wikipedia. The Huffman Coding wiki article gives a nice breakdown with examples of the data structure and associated algorithms....

July 4, 2023 · 12 min

Digital Image Steganography

There’s a neat Computerphile video discussing the topic of steganography. In the video, Mike Pound talks about a technique for steganography on digital images: least significant bit substitution (LSBS). The effectiveness of LSBS in concealing a secret image is surprising. This article puts least significant bit substitution to use in a command line tool for embedding one image within another. A Little Background on Digital Images You don’t need fancy image manipulation techniques to make this steganography tool work....

June 25, 2023 · 7 min

Snake in the Terminal

Are you a text user interface enjoyer? Have you always wondered how difficult is it to write an ncurses UI? What better way to find out than to write a program of your own that explores ncurses’ API. Of course, you have to keep it interesting. Why not implement a scaled down version of a retro arcade game: snake. The Rules of Snake Step one of this project is to look up what the rules for a game of snake are....

June 17, 2023 · 14 min

GPIO Driven Synchronization

Have you ever heard of the Kuramoto Model? The Kuramoto Model Wikipedia page has an impressive video showing out of phase metronomes synchronizing: Could two or more computers synchronize in a similar fashion? What would be the common “fabric” between the machines? In the clip with the metronomes, the base board is crucial in bringing the metronomes into phase. Perhaps you could use GPIO signals to achieve a similar link between two computers....

May 29, 2023 · 12 min

Real-time Linux App Development

If you’re an embedded systems programmer, you have likely touched on the topic of real-time operating systems (RTOS). There are plenty of commercial RTOSes available on the market: VxWorks, Integrity, DeOS, Helix, the list goes on. As a hobbyist, you may not have thousands of dollars to spend paying for commercial licenses. Real-time Linux can fill the void by providing a path to a soft real-time system. This post takes a tour through the advice given in John Ogness’s 2020 presentation: “A Checklist for Writing Linux Real-Time Applications”....

April 27, 2023 · 15 min