Skip to content

Instantly share code, notes, and snippets.

Avatar

Prana Adiwira intrnl

View GitHub Profile
@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 Jan 15, 2021
The latest version of my ‘killer contract’ for web designers and developers
View Contract Killer 3.md

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

You can’t perform that action at this time.