Skip to content

Instantly share code, notes, and snippets.

View mrmartineau's full-sized avatar
👋
Aho Young Warrior

Zander Martineau mrmartineau

👋
Aho Young Warrior
View GitHub Profile
@mrmartineau
mrmartineau / stimulus.md
Last active April 19, 2024 09:41
Stimulus cheatsheet

ZandersComponent

Usage

export { ZandersComponent } from './ZandersComponent'

<ZandersComponent>Some content</ZandersComponent>
@mrmartineau
mrmartineau / settings.json
Last active February 26, 2024 19:33
vscode settings.json
{
"[handlebars]": {
"editor.formatOnSave": false
},
"[markdown]": {
"editor.quickSuggestions": {
"comments": "off",
"other": "off",
"strings": "off"
}
@mrmartineau
mrmartineau / UserProvider.tsx
Created October 11, 2023 12:01
Supabase / Next 13 user prefs question
'use client';
import { createClientComponentClient } from '@supabase/auth-helpers-nextjs';
import { ReactNode, createContext, useCallback, useContext } from 'react';
import { useRealtimeProfile } from '../hooks/useRealtime';
import { UserProfile } from '../types/db';
export type UseUpdateReturn = (action: UIStateAction) => void;
type UIState = UserProfile['settings'];
export type UIStateAction =
@mrmartineau
mrmartineau / dev-resources.md
Last active March 23, 2023 00:20
My go-to resources for working on the web.
:root {
--padding-1: 0.25rem;
--padding-2: 0.5rem;
--padding-3: 0.75rem;
--padding-4: 0.75rem;
}
.button {
padding: var(--padding-1);
border: none;
[data-hotkey]:not(.selected)::after {
content: attr(data-hotkey);
color: var(--color-fg-muted);
background-color: var(--color-neutral-subtle);
margin-left: var(--primer-control-medium-gap, 4px);
border-radius: 2em;
font-family: monospace;
display: inline-block;
font-size: var(--primer-text-body-size-small, 12px);
font-weight: var(--base-text-weight-medium, 500);
@mrmartineau
mrmartineau / array_iteration_thoughts.md
Last active November 22, 2022 15:10 — forked from ggauravr/array_iteration_thoughts.md
Array iteration methods summarized

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it much simpler to think about both the old list and the new one, what they contain, and