Skip to content

Instantly share code, notes, and snippets.

View simple-static-site-generation.md

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
kyhwana / blocksigners.sh
Last active Apr 7, 2021
Block RMS support letter signers
View blocksigners.sh
#replace "<PAT TOKEN>" with your github PAT token, tested with "Update ALL user data" PAT token.
curl -q https://rms-support-letter.github.io/ | grep "href" | grep "github.com" | grep -v "\/\[" | awk -F "https://github.com/" '{ 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" https://api.github.com/user/blocks/USER
@ggoodman
ggoodman / README.md
Created Feb 25, 2021
Using the concept of defer from golang to simplify resource cleanup in Javascript
View README.md

The withCleanup helper

Example

const result = await withCleanup(async (defer) => {
  const fileHandle = await getFileHandle();
  defer(() => fileHandle.close());
   
  // Carry on
@tannerlinsley
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,
deps,
value: fn(),
}
@developit
developit / worlds-worst-jsx-transform.js
Created May 18, 2020
worlds-worst-jsx-transform.js
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
malarkey / Contract Killer 3.md
Last active Aug 1, 2021
The latest version of my ‘killer contract’ for web designers and developers
View Contract Killer 3.md

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

…………………………