Skip to content

Instantly share code, notes, and snippets.

View Jtosbornex's full-sized avatar

Josh Osborne Jtosbornex

View GitHub Profile
@Jtosbornex
Jtosbornex / pick-function-args.type.ts
Created November 21, 2021 04:48
Typescript resolve function arguments utility type
export type PickFnArgs<Q> = Q extends (...args: infer P) => unknown ? P : never;
@Jtosbornex
Jtosbornex / DefaultKeyBinding.dict
Created August 30, 2021 18:27 — forked from lenalebt/DefaultKeyBinding.dict
How to use a typical Linux / Windows Keybindung on MacOS (tested with 10.15.2 Catalina)
/*
PUT THIS FILE IN ~/Library/KeyBindings/DefaultKeyBinding.dict
This file remaps the key bindings of a single user on Mac OS X 10.5 to more closely
match default behavior on Windows systems. This particular mapping assumes
that you have also switched the Control and Command keys already.
This key mapping is more appropriate after switching Ctrl for Command in this menu:
Apple->System Preferences->Keyboard & Mouse->Keyboard->Modifier Keys...->
Change Control Key to Command
Change Command key to Control
@Jtosbornex
Jtosbornex / unpromise.type.ts
Created January 12, 2021 21:24
Typescript resolve promise utility type
export type Unpromise<T extends Promise<any>> = T extends Promise<infer U> ? U : never;
@Jtosbornex
Jtosbornex / enhanced-state.hook.ts
Created December 29, 2020 18:22
React Enhanced State Management
import { useState, useCallback } from 'react';
import { PickOne } from 'pick-one.type';
export type UseStateEnhancedManagement<T> = [
T,
{
setState: React.Dispatch<React.SetStateAction<T>>;
setProperty: (property: PickOne<T>) => void;
setProperties: (properties: Partial<T>) => void;
}
@Jtosbornex
Jtosbornex / pick-one.type.ts
Created December 29, 2020 18:20
Typescirpt PickOne Property from Object
export type PickOne<T> = { [P in keyof T]: Record<P, T[P]> & Partial<Record<Exclude<keyof T, P>, undefined>> }[keyof T];
@Jtosbornex
Jtosbornex / typeorm-date-comparison.util.ts
Last active December 29, 2020 18:23
Typeorm Date Comparisons
import { FindOperator, LessThan, MoreThan } from "typeorm"
import moment, { Moment, MomentInput } from 'moment';
export const MoreThanDate = (date:MomentInput) => MoreThan(
new FindOperator(
'moreThan',
moment(date).format( 'YYYY-MM-DD HH:mm:ss' ),
)
);