Skip to content

Instantly share code, notes, and snippets.

View dlaub3's full-sized avatar
:shipit:

Daniel Laubacher dlaub3

:shipit:
View GitHub Profile
@dlaub3
dlaub3 / ts
Last active February 11, 2023 16:58
TS Utilities
// Extract the desired values from a union of objects
type ExtractUnionValues<T extends {}, ExcludProps extends string = never> = T extends Extract<T, { [K in infer P]: any }> ? T[Exclude<P, ExcludProps>] : never
type PickUnionValues<T extends {}, Props extends string = never> = T extends Extract<T, { [K in infer P]: any }> ? T[Extract<P, Props>] : never
// alternative implementation
type ExtractUnionValues<T extends {}, ExcludedProps extends string = never> = T extends {} ? Omit<T, ExcludedProps>[keyof Omit<T, ExcludedProps>]: never
type PickUnionValues<T extends {}, Props extends string = never> = T extends {} ? Pick<T, Extract<keyof T, Props>>[keyof Pick<T, Extract<keyof T, Props>>]: never
@dlaub3
dlaub3 / tsconfig.json
Created November 26, 2021 11:11
tsconfig-codesandbox-react
{
"compilerOptions": {
"target": "es6",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
@dlaub3
dlaub3 / typescript.vim
Last active September 18, 2021 01:09
Vim + TypeScript ❤️
# after/syntax/typescript.vim
# after/syntax/typescriptreact.vim
set conceallevel=1
syntax keyword typescriptPredefinedType any conceal cchar=💩
@dlaub3
dlaub3 / husky.ignore.sh
Created August 24, 2021 22:55
Better Husky Pre-Commit
#!/usr/bin/env sh
#
# This script lints files for a Husky pre-commit hook
#
# run with `git commit -m "foo" 2>&1 | tee husky-errors.ignore.txt`
# to save the errors to a file.
#
# {
# "hooks": {
@dlaub3
dlaub3 / instructions.md
Last active August 21, 2021 13:31
Kinesis Advantage2 Map Meta Key in PC mode

Given I am in PC mode When I press program => keypad => F1 => keypad => Home Then I will have mapped the Home key as the Meta key for a Linux PC

@dlaub3
dlaub3 / related-series.html
Created August 21, 2021 02:57
Hugo related content in series
@dlaub3
dlaub3 / handy-scripts.md
Created August 21, 2021 02:55
Handy Scripts

Copy Import Path

function copyImport --description "copy the import path to the clipboard"
   rg --no-filename "$argv[1]" | rg "^import" |  sort | uniq | fzf | pbcopy
   echo (pbpaste)
end
@dlaub3
dlaub3 / save-restore.vim
Last active August 23, 2021 14:21
Automatically manage saving Vim sessions and resoring the layout
function SaveSession()
let session_dir = $HOME . "/.vimsessions/"
let session_file = "dir" . substitute(getcwd(), '/', '_', 'g')
if v:this_session
execute "mks! " . v:this_session
echo "saved " . v:this_session
return 0
endif
@dlaub3
dlaub3 / Sites.md
Last active December 30, 2019 17:27
List of sites I like
@dlaub3
dlaub3 / VSCodeSettings.json
Created June 6, 2019 16:11
VSCode Settings
{
/* Editor */
"editor.fontLigatures": true,
"editor.fontFamily": "'FiraCode-Retina'",
"editor.formatOnSave": true,
"editor.fontSize": 14,
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [