Skip to content

Instantly share code, notes, and snippets.

View epreston's full-sized avatar

Ed Preston epreston

View GitHub Profile
@epreston
epreston / basic.editorconfig
Created June 28, 2021 04:25
basic editorconfig - indent 2 spaces, single quote js, double quote html, protect package.json
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
# Space indentation
[*]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
@epreston
epreston / basic.eslintignore
Last active April 27, 2023 16:22
basic eslintignore - node modules, final build directory, and unmodified media directory
**/node_modules/**
dist
public
@epreston
epreston / aws-cli-osx-deployment-cmds.txt
Last active June 29, 2021 10:39
aws-cli osx deployment
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
# confirm deployment
which aws
# returns: /usr/local/bin/aws
aws --version
# returns: aws-cli/2.2.14 Python/3.8.8 Darwin/20.5.0 exe/x86_64 prompt/off
@epreston
epreston / display-ssh-keys-info.sh
Last active June 30, 2021 11:40
quick display of ssh keys - length, sha, note, type
# Display info on existing SSH keys
for key in ~/.ssh/*.pub; do ssh-keygen -l -f "${key}"; done | uniq
# DSA = Unsafe and even no longer supported since OpenSSH version 7.
# RSA = Concerning, see length. 3072 or 4096-bit length is ok.
# ECDSA = Trustworthiness concern on the NIST curves.
# Ed25519 = Recommended public-key algorithm.
@epreston
epreston / gen-Ed25519-ssh-key.sh
Created June 30, 2021 10:58
generate a new SSH key that uses Ed25519 algorithm
# Generate new Ed25519 SSH key
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "login@hostname.com"
# -o : Save the private-key using the new OpenSSH format rather than the PEM format
# -a: Increase resistance to brute-force password cracking if the private-key is stolen.
# -t: Type of key to create (Ed25519).
# -f: Filename of the generated key file.
# -C: Optional comment, often <login>@<hostname> or email.
@epreston
epreston / gen-rsa-ssh-key.sh
Last active June 30, 2021 12:26
generate a new 4096 bit SSH key that uses RSA algorithm
# Generate new 4096 bit RSA SSH key:
# --- Only use when ed25519 isnt possible ---
ssh-keygen -o -a 100 -t rsa -b 4096 -f ~/.ssh/id_rsa -C "login@hostname.com"
# -o : Save the private-key using the new OpenSSH format rather than the PEM format
# -a: Increase resistance to brute-force password cracking if the private-key is stolen.
# -t: Type of key to create (rsa).
# -f: Filename of the generated key file.
# -C: Optional comment, often <login>@<hostname> or email.
@epreston
epreston / queueBeforeEvent.js
Created April 27, 2023 16:05
queueBeforeEvent - perform asynchronous logic on event handlers, but never after a particular subsequent event.
// see: https://twitter.com/diegohaz/status/1526511865291067393
const showDialog = () => console.log('showDialog');
// Usage
function onMouseDown(event) {
// We want to showDialog asynchronously on mouse down, but before mouse up,
// for when the user is "tapping" instead of "clicking".
queueBeforeEvent(event.target, 'mouseup', showDialog);
}
@epreston
epreston / queueMicrotask.js
Created April 27, 2023 16:12
queueMicrotask - usage in synthetic events
// see: https://twitter.com/diegohaz/status/1530662445240426496
const anotherElement = document.querySelector('#anotherElement');
function onClick() {
// BAD - Focus will fire on another element before the
// click event finishes bubbling. You may get events
// in the wrong order on parent elements.
anotherElement.focus();
@epreston
epreston / basic.prettierignore
Last active April 27, 2023 16:18
basic .prettierignore - exclude the final build products from formatting
dist
@epreston
epreston / jsconfig.json
Created April 27, 2023 16:26
jsconfig.json - type checking modern js only projects in vscode typescript support
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */