Skip to content

Instantly share code, notes, and snippets.

View jherr's full-sized avatar
💭
Making a bunch of videos for the coming weeks

Jack Herrington jherr

💭
Making a bunch of videos for the coming weeks
View GitHub Profile
@jherr
jherr / .posh-theme.json
Created September 16, 2024 17:35
Oh-my-posh theme
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"palettes": {
"template": "bcc",
"list": {
"bcc": {
"base": "#0F9BF2",
"color-2": "#10b1d5",
"color-3": "#38939d",
"color-4": "#503FBF",
@jherr
jherr / simple-posh.theme.json
Created July 6, 2024 13:26
Very simple theme for oh-my-posh that shows the basics for a Node/React dev
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"palettes": {
"template": "bcc",
"list": {
"bcc": {
"base": "#0F9BF2",
"color-2": "#10b1d5",
"color-3": "#38939d",
"color-4": "#503FBF",
@jherr
jherr / .eslint.json
Last active December 30, 2023 23:52
Walkthrough of massive lint experiment
{
"root": true,
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [
"standard",
"plugin:no-unsanitized/DOM",
@jherr
jherr / runify.js
Created September 22, 2023 21:54
runify.js
export function runify(obj) {
if(Array.isArray(obj)) {
return obj.map(runify);
} else if(typeof obj === 'object') {
let rune = $state(obj);
let output = {};
for(let key in rune) {
if(typeof obj[key] === 'object') {
obj[key] = runify(obj[key]);
}
@jherr
jherr / middleware.ts
Created July 27, 2023 15:43
Astro HTMX Middleware
/*
There is currently no way to get a `.astro` route to just return the HTML
without the CSS and JS. This is a workaround to remove the CSS and JS from
the HTML response of HTMX fragment routes.
The premise here is that HTMX fragments won't required additional styles because
the Tailwind for the entire experience is alreay precomputed. And second that it will
not require additional JS because ... HTMX.
*/
const HTMX_FRAGMENT_ROUTES = ["/prompt"];

Frameworks like React require that when you change the contents of an array or object you change its reference. Or push another way that you don't change arrays but instead create new arrays with updated values (i.e. immutability).

There are older array methods that are incompatible with immutability because they alter the array in place and don't change the array reference. These are mutable (or destructive) methods.

Shown below are replacements for the array destructive methods (e.g. push, pop, splice, sort, etc.) that will create new array references with the updated data.

Solutions are provided using the spread operator and also the newer "change array by copy" methods (toSpliced, toSorted, toReversed and with).

Setting Value At Index

@jherr
jherr / spreadTest.js
Created April 24, 2023 14:41
Basic performance tests of the spread operator
const numberFormat = new Intl.NumberFormat("en-US", { style: "decimal" });
const TEST_ARRAY_SIZE = 1000;
const TEST_COUNT = 1000;
const pushUsingPush = (arr) => {
arr.push(5);
return arr;
};
@jherr
jherr / package.json
Created January 27, 2022 23:27
Simple monorepo starter
{
"name": "packages",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"private": true,
"scripts": {
"start": "concurrently \"wsrun --parallel start\""
},
"workspaces": [
@jherr
jherr / Setup.md
Last active October 31, 2024 04:22
Jack's Setup
@jherr
jherr / ang-pokemon-mfe.md
Last active July 20, 2021 16:14
ang-pokemon-mfe process

Original article

First create the NX workspace and the initial application named search:

npx create-nx-workspace@latest ang-pokemon-mfe

Set it up as angular, with the name search and SCSS for the styling: