Skip to content

Instantly share code, notes, and snippets.

View didley's full-sized avatar

Dylan Lamont didley

View GitHub Profile
@didley
didley / CreatingGifsMac.md
Last active April 3, 2024 14:11
Creating quality looking code gifs on Mac
  1. Record as video first, QuickTime is build in and has a grea screen record option.
  2. Gifski to convert and compress the gif.
    • dimentions (~25%), speed 1.5x, fps 12, quality ~25%
  3. Compress through ImageOptim.

https://gif.ski/ (brew install gifski)

https://imageoptim.com/mac (brew install --cask imageoptim)

Downgrade homebrew cask to specific version

As of June 2022

Install specific version

brew extract --version=versionNumber caskName homebrew/cask brew install caskName@versionNumber

Link brew to specific version

brew unlink caskName brew link caskName@versionNumber

@didley
didley / angleBracketForceCast.ts
Last active July 15, 2023 14:10
TypeScript force type assertion/cast angle-bracket syntax
// this
const user = {name: 'Greg', age: 40} as unknown as User
// becomes
const user = <User><unknown>{name: 'Greg', age: 40} // eslint-disable-line @typescript-eslint/consistent-type-assertions
@didley
didley / EntityType.ts
Last active September 10, 2023 02:47
TypeScript relational entity type
// version 1.0.0 - https://gist.github.com/didley/54902a3428f854becc89b80587067524
type Id = string;
type Many = { many: string };
type One = { one: string };
type ManyAndOne = Many & One;
type None = object;
type RelationArg = ManyAndOne | Many | One | None;
@didley
didley / pickEnum.ts
Last active September 22, 2023 12:41
Util to pick TypeScript enum keys, values or entries
// version 1.0.0 - https://gist.github.com/didley/09ad3ddae164f5d7fb02f8ee96971e58
/**
* Examples
*
* enum NumberEnum { A, B, C }
*
* pickEnum('keys', NumberEnum) // ['A', 'B', 'C']
* pickEnum('values', NumberEnum) // [0, 1, 2]
* pickEnum('entries', NumberEnum) // [['A', 0], ['B', 1], ['C', 2]]
@didley
didley / CreateConst.ts
Last active May 18, 2024 07:33
Convert a union to a constant array or object
// version 1.0.0 - https://gist.github.com/didley/accb427bc53e9a0afba1a79134636da5
/** @example ConstRecord<'a' | 'b'> // {a:'a', b:'b'} */
type ContRecord<K extends string | number | symbol> = Readonly<{ [P in K]: P }>;
/**
* Used primarily to convert string union to a constant object or array.
*
* @example
* ```ts
@didley
didley / _interceptConsole.ts
Last active May 19, 2024 11:37
Intercept TypeScript console methods such as error, log, and time. Then throw or execute callback.
// version 1.0.0 - https://gist.github.com/didley/36423c48705878b223c0f84ac04544ce
type ExcludedConsoleMethod = "Console" | "clear" | "groupEnd" | "table" | "profile" | "profileEnd" | "timeStamp";
type InterceptingMethodName = Exclude<keyof Console, ExcludedConsoleMethod>;
type InterceptConsoleOptions<Cb extends (...args: unknown[]) => unknown> = {
method: InterceptingMethodName;
onIntercept: "throw" | ((...args: unknown[]) => void);
cb: Cb;
@didley
didley / gist:a3d82cfc6736fce669041d0670f9ea4d
Created October 11, 2025 16:01
Mac keybinding command for Fedora Silverblue / GNOME
gsettings set org.gnome.desktop.input-sources xkb-options "['ctrl:swap_lalt_lctl','ctrl:swap_ralt_rctl']"; \
gsettings set org.gnome.desktop.wm.keybindings close "['<Ctrl>q']"
@didley
didley / rhfFields.tsx
Last active October 31, 2025 12:32
React Hook Form <Controller /> integrated Shadcn UI form fields
/*
React Hook Form <Controller /> integrated Shadcn UI form fields 🙄
Adapted from: https://ui.shadcn.com/docs/forms/react-hook-form
version: 0.1.0
gist: https://gist.github.com/didley/28d5454eebb1ad284fef34bc60d58258
*/
import type { HTMLInputAutoCompleteAttribute } from "react";