Skip to content

Instantly share code, notes, and snippets.


Simple static site generation

I wanted to document the approach I used for a simple static site generator that I wrote. Alas, the code isn’t ready for public consumption and probably never will be, but maybe others find the ideas useful.

Key differences with other static site generators (that I know)

Its main goal is to keep things as simple as possible (with a minimum of configuration):

  • A single tree of input files that is translated almost verbatim to output files
  • File sets (such as “blog posts”) specified via globs
kyhwana /
Last active Apr 7, 2021
Block RMS support letter signers
#replace "<PAT TOKEN>" with your github PAT token, tested with "Update ALL user data" PAT token.
curl -q | grep "href" | grep "" | grep -v "\/\[" | awk -F "" '{ print $2 }' | awk -F "\"\>" '{ print $1 }' | sed 's/\///g' | sed '/^$/d' | xargs -I USER curl -i -X PUT -H "Authorization: token <pat token here>" -H "Accept: application/vnd.github.v3+json"
ggoodman /
Created Feb 25, 2021
Using the concept of defer from golang to simplify resource cleanup in Javascript

The withCleanup helper


const result = await withCleanup(async (defer) => {
  const fileHandle = await getFileHandle();
  defer(() => fileHandle.close());
  // Carry on
tannerlinsley / useGlobalMemo.js
Created Aug 28, 2020
useGlobalMemo is a React hook that lets you share memoizations across an entire app using a unique key.
View useGlobalMemo.js
const cache = {}
export default function useGlobalMemo (key, fn, deps) {
if (!cache[key]) {
cache[key] = {
subs: 0,
value: fn(),
developit / worlds-worst-jsx-transform.js
Created May 18, 2020
View worlds-worst-jsx-transform.js
* Write JSX, but make sure you have `import html from 'htm/preact'` in your files.
* Run them through this horrid attrocity and get JSX support with basically no overhead.
export function transformJsxToHtm(code) {
const tokenizer = /(^|)(?:<\/([a-z$_][a-z0-9_.-:]*)>|<([a-z$_][a-z0-9_.-:]*)(\s+[a-z0-9._-]+(?:=(?:".*?"|'.*?'|\{.+?\}))?)*(\s*\/\s*)?>|<(\/?)>)/gi;
let out='', index=0, token;
let depth = 0;
let stacks = [];
let shouldPop = false;
malarkey / Contract Killer
Last active Aug 1, 2021
The latest version of my ‘killer contract’ for web designers and developers
View Contract Killer

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008