Skip to content

Instantly share code, notes, and snippets.

@danwdart
Last active June 6, 2018 00:14
Show Gist options
  • Save danwdart/73e81e06667a70ad298f2cd7ee5ea24e to your computer and use it in GitHub Desktop.
Save danwdart/73e81e06667a70ad298f2cd7ee5ea24e to your computer and use it in GitHub Desktop.
Easy product keys
// Small
> Math.round(Math.random() * Number.MAX_SAFE_INTEGER).toString(36).toUpperCase().match(/.{1,4}/g).join(`-`);
'2DSH-DWGM-7X5'
// Long, like Windows 98
> Array(5).fill().map(x => Array(5).fill().map(x => Math.floor(Math.random() * 36).toString(36)).join(``)).join(`-`).toUpperCase()
'1WH4O-WLUT5-DA1DJ-KNNCK-7A32I'
// No repeats for "fill"
> (a => a.map(x => a.map(x => Math.floor(Math.random() * 36).toString(36)).join(``)).join(`-`).toUpperCase())(Array(5).fill())
'07GK4-YNLZH-TK38I-PH7YL-FPQ1Q'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment