Skip to content

Instantly share code, notes, and snippets.

View darcher-'s full-sized avatar
💭
Much foo... Such bar.

Dylan Archer darcher-

💭
Much foo... Such bar.
View GitHub Profile
@darcher-
darcher- / contrastCompliance.js
Last active June 6, 2024 19:35
Accessibility contrast rating utility.
/**
* Defines a color scheme with a text color and a backdrop color.
* @type {Object}
* @property {string} textColor - The hexadecimal color value for the text.
* @property {string} backDropColor - The hexadecimal color value for the backdrop.
*/
const COLOR_SCHEME = {
textColor: "#000",
backDropColor: "#fff",
@darcher-
darcher- / startsWithCharacters.js
Last active June 5, 2024 19:36
Compare the first character(s) of the provided context against one or more symbols
//? an easy to follow, abstracted approach
/**
* Compares first character of string against a character
* @param {string} reference
* @returns {(character: string) => boolean}
*/
function startsWithCharacter(reference) {
return character => reference.startsWith(
character
const EMPLOYEE_DATA = [
{
id: "001",
name: "Mario",
title: "Lead Plummer",
underlings: [
{
id: "002",
name: "Luigi",
title: "Plumbing Assistant",
@darcher-
darcher- / index.html
Last active April 27, 2024 16:27
`<noscript />` notice for browsers with disabled javascript <demo: https://jsfiddle.net/darcher/f9o2cmry/>
<!-- <noscript> -->
<input type="radio" id="nojs-dismiss" hidden aria-hidden="true" aria-controls="#nojs-memo" />
<details id="nojs-memo">
<summary>
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
<g stroke="currentColor" stroke-linecap="round" stroke-linejoin="round">
<path d="M7.89 1.0499a1 1 0 0 0-1.78 0l-5.5 11a1 1 0 0 0 .89 1.45h11a1 1 0 0 0 .4866-.1281.999.999 0 0 0 .5095-.83 1 1 0 0 0-.1061-.4919zM7 5v3.25" />
<path d="M7 11a.25.25 0 1 1 0-.5m0 .5a.25.25 0 1 0 0-.5" />
</g>
</svg>
@darcher-
darcher- / snippet.js
Last active April 11, 2024 19:00
Nullish coalescing and Map condition hash
/**
* Just an example to showcase some conditional logic
*
* Nullish coalescing operator (??)
* - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing
* Nullish coalescing assignment (??=)
* - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_assignment
* Map object (new Map())
* - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
* Map.getter (Map.get())
@darcher-
darcher- / merge-strings-sample.js
Last active October 10, 2023 17:26
a look back at the evolution of string "merging" in javascript
/** EXAMPLE */
//? start
//* legacy
var prefix = 'x'
var infix = 'y'
/** suffix argument */
var affix = 'id="';
affix += prefix + '-';
@darcher-
darcher- / utils.tsx
Created March 10, 2023 17:14
general utilities for reuse
export const { info, log, warn, error, table } = console;
export function keys(src = {}) {
return Object.keys(src);
}
export function isArr(src = []) {
return Array.isArray(src);
}
@darcher-
darcher- / code-splitting.tsx
Last active March 10, 2023 16:26
Structured lazy dynamic imports - serve only what is required.
import { lazy } from "react";
/**
* use dynamic "code-splitting" imports
* prevents all components from being bundled and loaded at runtime
* only serves what is being utilized at render
*/
class DynamicComponent {
private _node = {
@darcher-
darcher- / svg-ref.css
Created April 29, 2022 13:51
SVG Reference with symbol ID
/* reset */
*:where(:not(iframe, canvas, img, svg, video):not(svg *, symbol *)) {
all: unset;
display: revert;
}
:where([hidden]) {
display: none;
}
@darcher-
darcher- / GIT_SETUP.md
Last active November 2, 2022 15:46
A list of `git` default configurations and alias shortcut commands.

Global defaults

use alias[key] = "!f() { 〈 command 〉 }; f" to include complex commands

# .git/config

[alias]
	log = log --oneline --graph
	lgc = log -l HEAD --stats
	caa = commit -a --amend -C HEAD