- Vite with Routerino Forge for SSG
- Modern JS using standard JS/Node APIs
- React 19 with JSX
- Write JSDoc for functions and components
- Follow "A Philosophy of Software Design", KISS, YAGNI principles
- Avoid: Observables, Proxies, RxJS, decorators, exotic patterns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| eslint prettier integration: formatting is now a linting error? ugh, too much noise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // useBackgroundAnimation.js | |
| import { useEffect, useRef } from 'react'; | |
| export function useBackgroundAnimation() { | |
| const canvasRef = useRef(null); | |
| const containerRef = useRef(null); | |
| useEffect(() => { | |
| const canvas = canvasRef.current; | |
| const container = containerRef.current; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const args = process.argv | |
| .filter((arg) => arg.includes("=")) | |
| .reduce((acc, cur) => { | |
| let split = cur.split("="); | |
| acc[split[0]] = split[1]; | |
| return acc; | |
| }, {}); | |
| console.log(args); | |
| // run command: node parse-node-args.js foo=bar baz=qux |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // update a head tag | |
| function updateHeadTag({ tag = "meta", ...attrs }) { | |
| // input check | |
| const attrKeys = Object.keys(attrs); | |
| if (attrKeys.length < 1) { | |
| return console.error( | |
| `updateHeadTag() received no attributes to set for ${tag} tag` | |
| ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // update head meta tags | |
| function addMetaTag({ name, property, value }) { | |
| // console.log({ name, property, value }); | |
| // input checks | |
| if (value === null || value === undefined) { | |
| return console.error( | |
| `addMetaTag received no value to set for tag: ${name ?? property}` | |
| ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // NoteField.swift | |
| // | |
| // Created by Floyd Noel on 7/11/21. | |
| // | |
| import SwiftUI | |
| struct NoteField: View { | |
| var label: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const getSearchParams = () => | |
| window.location.search | |
| .substring(1) | |
| .split('&') | |
| .reduce((acc, searchParam) => { | |
| const [name, value] = searchParam.split('='); | |
| return { ...acc, [name]: value }; | |
| }, {}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // takes a string URL, and returns a string URL which allows the request to proceed without CORS blocking | |
| const forgetAboutCors = u => `https://cors-anywhere.herokuapp.com/${u}` | |
| // example usage: forgetAboutCors(`https://clinicaltrials.gov/ct2/show/${'NCT03512561'}?displayxml=true`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const scriptAlreadyLoaded = urlString => Array.prototype.slice.call(document.scripts).filter(s => s.src).map(s => s.src).contains(urlString) |
NewerOlder