For anyone else working on understanding some of the JS helpers for the Colossal Order UI package, I spent some time deobfuscating a couple functions/classes. Please note there certainly be mistakes and there is some omitted code; however, overall the gist is present.
While react-hook-form
supports strong typing everywhere, including support for types inferred from a Yup schema (Yup.InferType<Schema>
), passing field names to controls is still untyped. However, this can be resolved with RHF's FieldPath
type and a helper function.
// Option 1: Declared per form, less boilerplate per control
export const getOrganizationFormField = (name: FieldPath<OrganizationForm>) => name;
getOrganizationFormField("billingAddress.address1");
type CacheKey = string | number; | |
interface Cache<T> { | |
/** Number of cache entries */ | |
readonly count: number; | |
/** Get an item from the cache */ | |
get: (key: CacheKey) => T | null; | |
/** Check whether cache contains a given item */ | |
has: (key: CacheKey) => boolean; | |
/** Cached items */ |
Jupyter Notebooks have a tendency to cause Git conflicts when working collaboratively on a notebook. This is primarily due to cell metadata that really doesn't matter, and can be removed with a pre-save configuration hook. This hook will be run across all Jupyter Notebooks; however, it utilizes a custom opt-in metadata configuration option (reduce_git_conflicts
). If the opt-ine is not specified, or set to false
, the Notebook will save as normal.
- Add pre-save hook to Jupyter Notebook config
- Enable reducing Git conflicts in Notebook metadata
NOTE: This approach does modify the notebook save file itself, which could lead to issues if there are fields that must remain in the file but lead to conflicts (and would otherwise be removed).
NOTE: This approach was developed with Jupyter Notebook in mind. While Jupyter Lab is quite similar, there are several differences (generating config, editing metadata).
Some projects may have files that should be skipped in Git diff
but still show in Git status
(and be tracked). This can be made possible with a custom diff driver that uses a no-op command.
Adapted from StackOverflow - @KurzedMetal.
Create a global no-op diff
command driver with the following command. Note that driver can be limited to local respository by removing the --global
flag.
git config diff.nodiff.command /bin/true
/** | |
* Dynamically sets a deeply nested value in an object (returns new object) | |
* | |
* NOTE: By default it will create any missing nested keys! | |
* | |
* @param obj - Object which contains the value to set | |
* @param path - Path to nested key being set | |
* @param value - Target value to set | |
* @param recursive - Whether to create non-existing paths | |
* @returns Updated nested object |
""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" 01. General | |
"""""""""""""""""""""""""""""""""""""""""""""""""" | |
set nocompatible | |
filetype off | |
"""""""""""""""""""""""""""""""""""""""""""""""""" | |
" 02. Vundle plugins | |
"""""""""""""""""""""""""""""""""""""""""""""""""" | |
set rtp+=~/.vim/bundle/Vundle.vim |
# Forward WSL2 ports to host machine/platform (handles Windows Firewall) | |
# | |
# NOTE: 'iex' is a shortform for 'Invoke-Expression' | |
# Ports that should be forwarded to WSL2 and allowed through firewall (comma-separated) | |
$ports = @(8081); | |
# WSL IP address changes whenever WSL restarts | |
$wsl_ip = $(wsl hostname -I).Trim(); |
It can sometimes be useful to have multiple SSH keys for the same Git hosts, which requires some additional SSH configuration.
A typical example involves using the same host (GitHub) with multiple accounts on the same computer. Since each account should use its own SSH key, we need to use a combination of the SSH configuration and Git remotes to determine which SSH key to use.