Skip to content

Instantly share code, notes, and snippets.

View jonathanconway's full-sized avatar
⌨️
Typing

Jon jonathanconway

⌨️
Typing
View GitHub Profile
@jonathanconway
jonathanconway / conventional-commit.code-snippets
Last active April 24, 2026 00:53
VSCode Snippet - Conventional Commit Message
{
"Conventional Commit Message": {
"body": "${1|build,chore,ci,docs,feature,fix,performance,refactor,revert,style,test|}: ${2:ticket} ${3:message}",
"description": "Conventional commit message in the format: <type>: TICKET-123 descriptive message"
}
}
/**
* $1: type
* Source: https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional
const resolvedEls = document.querySelectorAll('[data-action="click:review-thread-collapsible#toggle"]');
resolvedEls.forEach(el => el.click())
@jonathanconway
jonathanconway / pascal-case.ts
Created March 17, 2026 03:26
Converts provided string to PascalCase
import { kebabCase, startCase } from "lodash";
/**
* Converts provided string to PascalCase
* @example my-string => MyString
* @example myString => MyString
* @example my_string => MyString
* @example MY_STRING => MyString
*/
export function pascalCase(input: string) {
@jonathanconway
jonathanconway / scripts.md
Last active April 18, 2026 06:53
Some handy shell commands for MacOS

Terminal

Increase the terminal buffer to 100kb so you can scroll up and see more output.

  • {command} is the command you want to run and see more output from
DEBUG_PRINT_LIMIT=100000; {command}
@jonathanconway
jonathanconway / nil.ts
Created January 21, 2026 02:16
Type and related utilities for dealing with nil or "falsy" values in Typescript
// Type and related utilities for dealing with nil or "falsy" values in Typescript
// Credits:
// • You Don't Know Javascript by Kyle Simpson [Book]
// • Javascript – The Good Parts by Douglas Crockford [Book]
/**
* Value which behaves the same as `false` when evaluated.
*/
export type Nil = undefined | null | false | 0 | -0 | typeof NaN | "";
@jonathanconway
jonathanconway / type-of-const.ts
Created January 11, 2026 02:12
Type utility to transform an object const map into a literal union
/**
* Transform an object const map into a literal union.
*
* @example
* const Colors = {
* Red = "red",
* Green = "green",
* Blue = "blue",
* } as const;
*
@jonathanconway
jonathanconway / deep-merge-maps-of-arrays.ts
Last active January 9, 2026 03:18
Merges multiple maps of T to Array of U into one map
type MapOfArrays<
TKey extends string | number | symbol,
TArrayItem,
TArray extends RelativeIndexable<TArrayItem>,
> = Partial<Record<TKey, TArray>>;
type ReadonlyMapOfArrays<
TKey extends string | number | symbol,
TArrayItem,
> = MapOfArrays<TKey, TArrayItem, ReadonlyArray<TArrayItem>>;
@jonathanconway
jonathanconway / create-with-hoc.ts
Created December 15, 2024 13:27
Creates a function that applies a HOC to a React component
import { get, omit } from "lodash";
import { ComponentType } from "react";
export function createWithHOC<THOCProps, THOCName extends string>(
HOC: ComponentType<THOCProps>,
hocName: THOCName,
) {
return function withHOC<TLOCProps extends JSX.IntrinsicAttributes>(
LOC: ComponentType<TLOCProps>,
) {
@jonathanconway
jonathanconway / list_authors.sh
Created December 14, 2024 02:10
Lists all the unique authors who have edited a given file in the current Git repository
#!/bin/bash
# Generated by ChatGPT.
# Prompt:
# Please write a bash script which finds and lists all the unique authors who
# have edited the given file in the current Git repository. The given file
# will be specified as the first parameter to the bash script.
# Check if a file parameter is provided
@jonathanconway
jonathanconway / .prettierrc
Created March 18, 2024 10:12
Handy sensible defaults for prettier including import ordering and grouping
{
"tabWidth": 2,
"useTabs": false,
"singleQuote": false,
"importOrder": ["^[@]?[a-zA-Z]", "^[@/a-zA-Z]", "^../", "^./"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"plugins": ["@trivago/prettier-plugin-sort-imports"]
}