Skip to content

Instantly share code, notes, and snippets.

Write a Static Site Generator

If you're doing front end development in the year of our lord 2020, chances are good that you'll be working with a static site generator (SSG) extensively. I can of course give you the formal definition of a static site generator and you can find lots of good documentation and pointers just by Googling what is a static site generator, but nothing will help you understand the concept better than writing a simple SSG yourself.

Some background

In the beginning, we had a HTML blog post page that looked like this:

<!doctype html>
<html>
bool pressed[4] = { false };
int cdown[4] = { 0 };
const int thold = 9;
const int maxcdown = 5000;
void setup() {
pinMode(A0, INPUT_PULLUP);
pinMode(A1, INPUT_PULLUP);
pinMode(A2, INPUT_PULLUP);
pinMode(A3, INPUT_PULLUP);
@waybeforenow
waybeforenow / index.html
Created January 7, 2019 01:20
scss-scaffold
<!doctype html>
<!--
scss-scaffold: prototype SCSS in your browser without having to install Node.
Takes an SCSS file, turns it into CSS, then applies that to an externally-
supplied HTML file. Notably, it also works in the `file:///` namespace.
IMPORTANT: Your HTML file needs to contain this boilerplate:
#ifndef __RBYTEORDER_H
#define __RBYTEORDER_H
/* In-place reverse the byte-order of any variable. */
template <typename T, size_t size = sizeof(T)>
void rbyteorder(void* bytes) {
size_t n = size, j = 0;
while (j < (size / 2)) {
char tmp = ((char*)bytes)[--n];
((char*)bytes)[n] = ((char*)bytes)[j];
#include <cstring>
#include <iostream>
#include <string>
#ifdef __GNUG__
#include <cxxabi.h>
#include <algorithm>
#include <typeinfo>
#include <vector>
#endif
/* Teensy sketch to provide an adjustable 24-hour little-endian
* binary clock with 17 LEDs and 3 momentary pushbuttons.
*
* You wire it up like so:
*
* +-------------------+
* | 2 3 4 5 6 |
* | 7 8 9 10 11 12 |
* | 14 15 16 17 18 19 |
* +-------------------+