Unexpected Places You Can And Can't Use Null Bytes
The traditional way of representing strings in C is using null-terminated character arrays. Common C library methods like strcpy, printf, etc. detect how long strings are by sequentially scanning...
View ArticleIn Defense of C++
I really like C++. It’s not the right tool for every job, but it’s what I reach for when I need to do any kind of systems programming. Unfortunately, C++ has often been cited as a “bad” language, and I...
View ArticleAll About Linkers
In this post I want to explain what linkers and loaders do, and why languages like C and C++ have a linking phase. We’ll also see how the linking process works in Go, Java, and Rust. Motivation...
View ArticleAn Introduction to Valgrind Memcheck
Valgrind is an extremely powerful tool for debugging and profiling programs written in C or C++. Valgrind has many builtin tools for various operations, such as checking memory errors, memory...
View ArticleNeoliberalism
Recently the word “neoliberalism” has been catching my eye. Two weeks ago I attended a panel discussion about contemporary labor movements, and one of the panelists used the term pejoratively to...
View ArticleHow To Play Pool At A Bar
Pool is by far the most popular game played in bars in the United States. You can find a pool table and a jukebox in most “dive bars” across America, whether you’re in a big city or a rural honky-tonk....
View ArticleUnix System Call Timeouts
Recently I was writing some code where I wanted to wait for a child process, and I wanted the wait call to have a timeout. The use case is something like this: you spawn a subprocess, and you expect...
View ArticleThe Cult of DD
You’ll often see instructions for creating and using disk images on Unix systems making use of the dd command. This is a strange program of obscure provenance that somehow, still manages to survive in...
View ArticleEfficient File Copying On Linux
In response to my last post about dd, a friend of mine noticed that GNU cp always uses a 128 KB buffer size when copying a regular file; this is also the buffer size used by GNU cat. If you use strace...
View ArticleBlog Rewrite In Go
Today I rewrote all of the code I use to generate the static HTML for my blog. The code for my blog started out as a simple Python script, and over time evolved into incredibly slow and unmaintainable...
View ArticleBash $* and $@
In Bash, there are two closely related “special parameters” for accessing how the current script was invoked: $* and $@. For both variables, the behavior is affected by whether or not the variable is...
View ArticleHow To Host Your Own Private Git Repositories
Hosting your own private git repositories is really easy. If you already have a dedicated web server (e.g. to host your blog), you have everything you need to host your own repos. Doing this is cheaper...
View ArticlePinning GPU Memory in Tensorflow
One of the really great things about Tensorflow is how easy it makes it to offload computations to the GPU. Tensorflow can do this more or less automatically if you have an Nvidia GPU and the CUDA...
View Article`PATH_MAX` Is Tricky
One of the defining features of Unix is its hierarchical filesystem: directories on Unix systems can contain other directories, without a limit to the depth of the nesting. This isn’t a big deal...
View ArticleC String Literals Are Lvalues
C values come in two types: lvalues and rvalues. The intuitive way to think of this is that lvalues are the things allowed on the left side of expressions, and rvalues are the things allowed on the...
View ArticleDeclaring C String Constants The Right Way
C string constants can be declared using either pointer syntax or array syntax: // Option 1: using pointer syntax. const char *ptr = "Lorem ipsum"; // Option 2: using array syntax. const char arr[] =...
View ArticleThe Traveling Salesman Problem Is Not NP-complete
As an interview question, for many years I’d ask candidates to write a brute-force solution for the traveling salesman problem (TSP). This isn’t nearly as hard as it sounds: you just need to try every...
View ArticleDown the SSH\_AUTH\_SOCK Rabbit Hole: A GNOME Adventure
For a couple of years now, a confluence of GNOME bugs related to SSH handling have been driving me crazy. I finally sat down and spent time diving around the internals of various GNOME components, in...
View ArticleSmarter clang-format In Emacs
I’m a big believer in using clang-format to automatically format C and C++ code. Typically this is done by adding a file called .clang-format to the root directory of a project. This file tells...
View ArticleSetting Up A Headless Raspberry Pi On Linux
Most of the Raspberry Pi guides online are targeted for newbies want to set up their device using a keyboard and monitor. This is going to be a no-nonsense guide for people who already basically know...
View Article
More Pages to Explore .....