Skip to content

Instantly share code, notes, and snippets.

View chris-mcdonald-dev's full-sized avatar

Chris McDonald chris-mcdonald-dev

View GitHub Profile
@chris-mcdonald-dev
chris-mcdonald-dev / Optional-with-examples.md
Last active December 29, 2023 11:20
TypeScript: Make Specific Properties Optional/Required - (A Custom Utility)

A custom utility to make specific keys optional

type OptionalKeys<TType, TKey extends keyof TType> = Omit<TType, TKey> & Partial<Pick<TType, TKey>>

A similar utility to make specific keys required

type RequiredKeys<TType, TKey extends keyof TType> = Omit<TType, TKey> & Required<Pick<TType, TKey>>
@chris-mcdonald-dev
chris-mcdonald-dev / Find Potential Sparse Columns.sql
Last active March 3, 2022 21:29
Finds columns that qualify for storage optimizations of at least 40% across entire database
-- WHAT THIS DOES:
-- By default, NULL values take up storage as well.
-- Microsoft recommends considering a feature called "sparse columns" that reduces the size of NULL values in that column.
-- This only works well for columns with a large amount of NULL values. This script does this process for you.
-- DIRECTIONS ON HOW TO USE:
-- 1. Simply run the script initially to view all columns in your database that Microsoft recommends could benefit from being a "sparse column"
-- 2. Lastly, uncomment "Step #3", and run just that portion to actually make the changes to all columns that qualify.
--- NOTES: