TEXT PREDICTION WITH MARKOV CHAINS IN HASKELL

Let’s work through a few prediction techniques that can give us text that resembles some source material. Using Haskell, we can reuse lots of code while we work up to a Markov chain. First, we will predict words at random by choosing, with replacement, from all unique words in the material. Next, we will predict using the previous technique on every word position in a sentence. Then we will implement a Markov chain which allows us to predict the next word given a chunk of words from the material. So, given a chunk of words from the source material, we keep track of the unique words that follow it. We then build a cumulative distribution function (CDF) for each list of found words. We can then build the next chunk using a word chosen at random from the cumulative distribution function.

C++ :: MAPPING USER INPUT TO ACTIONS

Writing programs to perform some tasks is useful but writing programs that respond to user input are infinitely more useful. We will run through some common ways to respond to user input with varying degrees of flexibility and maintainability.

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.