Skip to content

Instantly share code, notes, and snippets.

View jjhiggz's full-sized avatar
🎯
Focusing

Jonathan Higger jjhiggz

🎯
Focusing
View GitHub Profile
@jjhiggz
jjhiggz / index.ts
Created December 17, 2023 15:28
AOC Day 11 2023
import { sumBy } from "remeda";
import { Matrix, MatrixCell, MatrixPosition } from "./data-structures/matrix";
const exampleText = await Bun.file("example.txt").text();
const buildMatrix = (input: string) =>
new Matrix(input.split("\n").map((n) => n.split("")));
const tagValues = (input: Matrix<string>) => {
let count = 0;
@jjhiggz
jjhiggz / example.ts
Created August 11, 2023 13:24
Why Record Types can be annoying in JS / TS
// let's say I want to find the most occurring year here
const years = [1999,1993, 1992, 1991, 1991, 1999, 1993, 1993]
// I can use a Record<number, number> to create a map like so
// {1999: 2, 1993: 3, 1992: 1, 1991: 2, }
const yearMap: Record<number, number> = {}
for(let year of years){
if(year in yearMap){
@jjhiggz
jjhiggz / index.html
Created July 13, 2023 15:30
HTML Starter Boilerplate
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
@jjhiggz
jjhiggz / SUPER_MEGA_PIPE_REMEDA.ts
Created January 28, 2023 04:25
If you're using remedaJS, here is an absurdly massive pipe function 700+ long
This file has been truncated, but you can view the full file.
import { LazyResult, _reduceLazy } from "remeda/dist/commonjs/_reduceLazy.js";
/**
* Perform left-to-right function composition.
* @param value The initial value.
* @param operations the list of operations to apply.
* @signature R.pipe(data, op1, op2, op3)
@jjhiggz
jjhiggz / ActionsMenu.tsx
Created August 15, 2022 23:26
Sidebar Stuff
import type { Entity } from "~/types/EntityType";
import { getChildEntityType } from "~/types/EntityType";
import useClickOutside from "~/hooks/useClickOutside";
import { useEffect, useRef } from "react";
import ActionsMenuItem from "./ActionsMenuItem";
import useCustomNavigation from "~/hooks/useCustomNavigation";
import { RemenuIcons } from "~/icons";
import { useFetcher, useNavigate } from "@remix-run/react";
import { objectToFormData } from "~/utils/form-data/object-to-form-data";
@jjhiggz
jjhiggz / $itemId.tsx
Created July 18, 2022 14:08
Action Helpers
import { useActionData } from "@remix-run/react";
import useFormReset from "~/hooks/useFormReset";
import type { ActionFunction, LoaderArgs } from "@remix-run/server-runtime";
import invariant from "tiny-invariant";
import { prisma } from "~/db.server";
import { requireUserId } from "~/session.server";
import FormHeader from "~/components/UI/Forms/FormHeader";
import { Form } from "@remix-run/react";
import TextInput from "~/components/UI/Forms/Inputs/TextInput";
import { updateItemSchema } from "~/models/item.server";

Johnny Coder

1 MyAddress email@example.com