RESTFUL API ROUTER USING C++, FUNCTIONAL PROGRAMMING, AND CRTP
Introduction Originally, this blog post was going to be specifically about Curiously Recurring Template Patterns (CRTP) in C++ and give a concrete example of when to use it. I decided that implementing an HTTP request router would be a good place to start but the amount of design decisions grew quite large.
FUNCTIONS AS FIRST CLASS CITIZENS IN C++: PASSING LAMBDAS OR FUNCTIONS TO FUNCTION TEMPLATES
A Simple Case Let’s look at a case where we can change the way a Function Template behaves by passing it various Lambdas as arguments.
GIT TIME KEEPER
Keeping track of time is important when programming. Git records the date and time of each commit you perform, but extracting the amount of time you spent on a commit or task is impossible. There are currently a few time trackers that integrate with git but are arduous to install and overly complex.
POOR MAN'S COMPILER EXPLORER
If you do any sort of C++ programming, you may know about Compiler Explorer. Written by Matthew Godbolt, it has become an indespensible tool in determining what your compiler is doing. If you aren’t comfortable with using the running version he has setup or can’t be bothered with installing the dependancies to run your own, then you have come to the right place! Using some command-line tools that are likely already installed on your system, you can setup an environment that is highly useable and configurable.
EPHEMERAL LXC SWARM FOR LOCAL TESTING
So, you need to create a swarm of Linux Containers to test multiple clients but don’t want the containers to stick around when you’re finished. We can use ephemeral LXC’s that utilize OverlayFS on harddisk or temporary storage in RAM. We do need a little Bash scripting knowledge. But, when we include the use of Tmux, we gain a large increase in power, flexibility, and productivity. What we need:
SSH CHROOT USING FIREJAIL AS LOGIN SHELL
Do you have a Linux server? Do users need SSH access to the server? Don’t you wish you didn’t have to hunt down object files for every piece of software you’d like to make available to every single chroot for every single user? Firejail. Yes, Firejail.
C++ STL CONTAINERS OF UNIQUE POINTERS TO POLYMORPHIC CLASS TEMPLATE
To those who have never seen polymorphism, this will look like black magic. To those who don’t utilize the power of generic programming this will look like something from another world completely.
FILESYSTEM RESILIENCE WITH DM-CRYPT, BTRFS, AND OVERLAYFS - LINUX
This is a guide to gaining multiple levels of resilience for a filesystem through the combination of dm-crypt, BTRFS, and OverlayFS.
WHOLE DISK ENCRYPTION WITH ONE COMMAND - LINUX
Plain Mode cryptsetup --type=plain open /dev/sdX myCrypt It’s that simple! What we’ve done is create a device at /dev/mapper/myCrypt that we can now add a partition. In plain mode there is no key on the device so in order to open the device, we use the same command. Let’s have a look at a more advanced plain mode example.
PARTICLE EMITTER WITH C++, SDL2, AND OPENGL
This is a naive approach to creating a particle emitter with C++, SDL2, and OpenGL. To create an efficient particle emitter all the vertices would be held in a single buffer and you would only call glDrawArrays() once every frame. In order to elaborate on drawing separate objects, I’ve opted to draw each particle separately. So let us begin.