Tutorial

Foundry VTT on DigitalOcean with SSL and PM2

8 minute read

Foundry Virtual Tabletop Screenshot

I absolutely LOVE Foundry Virtual Tabletop (FoundryVTT). It is by far the best $50 I’ve spent on my tabletop role-playing hobby in years. I can gush about the software on and on, and perhaps I will in a future post. This post, however, focuses on something a bit more practical.

For years, I’ve hosted my instance on AWS, but with the change to their public IP address pricing, it doesn’t make sense to stay with them since DigitalOcean offers a beefier solution at a lower monthly cost.

Read 1,956 more words...

Creating and Publishing a Bluesky Feed

9 minute read

Bluesky terminal feed output

I was recently invited to join Bluesky, a new social media platform. This was mostly motivated by the nightmare that Twitter has become over the past year or so. One of Bluesky’s nice features is the encouragement from the official team to build supplementary software. One way to do it is to build a custom feed. So, I set out to do just that: I built a feed that serves all posts related to TTRPGs on Bluesky. Here’s how I went about publishing mine on a DigitalOcean droplet using PM2, Nginx, and Let’s Encrypt.

Read 1,984 more words...

C++ PImpl Template

less than 1 minute read

If you’re not familiar with the PImpl (private implementation) idiom, read this Wikipedia article first. While this is more or less “syntactic sugar” since the templates are expanded during compilation, but I think it makes for cleaner looking code.

Read 261 more words...

C Bitwise Operations Cheat Sheet

1 minute read

Operations Table

Operation Sample C Operator
AND 1001 AND 0101 = 0001 & (ampersand)
OR 1001 OR 0101 = 1101 | (pipe)
NOT NOT 1001 = 0110 ~ (tilde)
XOR 1001 XOR 1011 = 0010 ^ (caret)
LEFT-SHIFT LEFT-SHIFT 0001 BY 1 = 0010 <<
RIGHT-SHIFT RIGHT-SHIFT 1000 BY 1 = 0100 >>

C Assignment Operators

Operation Syntax Short For
AND X &= Y; X = X & Y;
OR X |= Y; X = X | Y;
XOR X ^= Y; X = X ^ Y;
LEFT-SHIFT X <<= Y; X = X << Y;
RIGHT-SHIFT X >>= Y; X = X >> Y;

Read 287 more words...

C Tutorial 01: Hello, World!

7 minute read

If you ask a programmer which programming language you should learn as your first, they’ll often prescribe you their personal favorite, often not considering if the language is supported on multiple platforms, easy to learn, exposing underlying system mechanics, and fully featured.

This post is the first of a series of tutorials intended to teach you the C programming language, an excellent first language because of the following reasons:

Read 1,667 more words...

Creating a Window Wrapper Class: Redux

4 minute read

Okay, so I know you’re probably here because you searched for “window wrapper class” or something similar and expected the article that I use to host on Scriptionary that threw a bunch of C++ code at you for you to copy and paste. I regret to inform you that the article you were looking for has ceased to exist.

Sorry about that.

However, in its place I have for you this very post which will teach you how to accomplish creating such a wrapper all by yourself. I hope that is okay since all you really need to know is the how to create a window procedure that you can use with your custom class.

Read 1,043 more words...

A High-Resolution Timer for Win32

2 minute read

This post lists the code for creating a high resolution timer for the Microsoft Windows platform. High resolution timers are often used in multimedia and entertainment applications for timing events up to the microsecond.

This is a heavily modified re-post of the article that used to be on the Scriptionary.com website before the change to the blog, read the source code for details.

Read 705 more words...

Amount of Digits in an Integer

1 minute read

Here’s another little snippet that might come in handy in your programmatic travels. I’ll show you an example of usage below, which might also be of interest to you. The code presented is in C, not C++. First, the code to count the amount of digits in an integer:

Read 498 more words...

Flattening Multidimensional Arrays

1 minute read

Edit: Thank you, fixitman for the insightful comment; the code has been fixed to work with non-square arrays as well.

In an effort to produce a better performing multidimensional array, I would like to share the following with you. Say we have a Matrix (or multidimensional array) of 5 x 5 integer elements, M. In order to allocate such an array in C++, we use the following code:

Read 489 more words...

CriticalSection wrapper class

2 minute read

2023 Update: You probably don’t want to use this code since there are likely some serious issues with it. But, fun fact: a major tech company reached out to me to clarify what the license for this is. So, if you want to screw yourself over and use it, let’s say it’s MIT licensed and call it a day.

What: A C++ wrapper around both WINAPI (Microsoft Windows) and PThreads (POSIX threads) functionality.

Why: To abstract cross platform functionality.

Remarks: On windows, CRITICAL_SECTION objects cannot be shared cross-process. This means that the class is tied to your application or DLL process. Comments are in Doxygen/Javadoc style.

Read 568 more words...

Bitwise Programming in C

6 minute read

This article explains Bitwise Programming in C, a common practice in most programming languages. While bitwise operations might seem like a dark art at first, it really isn’t that scary. You simply need to know when to apply these operations and for what reasons to use them.

The article discusses bits (calculation, workings) in section one previous to the actual operators so that an understanding is made on how bits operate.

Read 1,589 more words...