This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int partitionLomuto(int[] A) { | |
int l = 0, r = A.length - 1; | |
int p = A[r]; | |
int ll = l - 1; | |
for (int bu = l; bu < r; bu++) { | |
if (A[bu] <= p) { | |
ll++; | |
swap(A, ll, bu); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Changing the file extensions of files from .js to .tsx | |
Get-ChildItem ./src -File -Recurse | Rename-Item -NewName { $_.Name -replace '\.js','.tsx' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARR1 = "value1 value2 value3" | |
ANOTHER = "test" | |
OPTIONAL_EXAMPLE = "optional test" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const msgMissing = (key: string): string => `Missing env var '${key}'` | |
export const loadOptionalEnvVar = (key: string): string | undefined => | |
process.env[key] | |
/** | |
* Load an environment variable. | |
* @param key The key used to access the environment variable. | |
* @returns The value of the environment variable. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish to the private GitHub NPM registry | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '**/*.md' | |
jobs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Make all keys of T optional except for K. */ | |
type PartialExcept<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A version of `Pick` that preserves unions composing `T` by applying `Pick` on each union of `T`. | |
*/ | |
export type DistributivePick<T, K extends keyof T> = T extends unknown | |
? Pick<T, K> | |
: never | |
/** | |
* A version of `Omit` that preserves unions composing `T` by applying `Omit` on each union of `T`. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A version of `Partial` that makes only the given keys of `T` optional. | |
*/ | |
export type PartialPick<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>> | |
/** | |
* A version of `Partial` that makes all the not specified keys of `T` optional. | |
*/ | |
export type PartialOmit<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type FormCompatible<T> = T extends unknown | |
? { | |
[P in keyof T]: T[P] extends infer K | |
? K extends object | |
? FormCompatible<T[P]> | |
: K extends number | |
? string | |
: K | |
: never | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import _ from 'lodash' | |
import { useRef } from 'react' | |
import { | |
FieldError, | |
FieldPath, | |
FieldValues, | |
useFormContext, | |
} from 'react-hook-form' | |
import { DistributivePick } from '../typescript/DistributivePick' |
OlderNewer