Skip to content

Instantly share code, notes, and snippets.

View iansan5653's full-sized avatar

Ian Sanders iansan5653

View GitHub Profile
interface ExampleQuery {
name?: string;
age?: number;
child?: {
id?: number;
name?: string;
};
}
const GET = Symbol();
@iansan5653
iansan5653 / shortcut_target.txt
Created August 23, 2019 16:06
Windows Snipping Tool Fast Shortcut
C:\Windows\System32\SnippingTool.exe /clip
function getSumOfSquaresOfDigits(n) {
let _n = n;
let result = 0;
while (_n > 0) {
result += (_n % 10) ** 2;
_n = Math.floor(_n / 10);
}
return result;
}
@iansan5653
iansan5653 / JSONTypes.ts
Created February 11, 2020 21:10
Typescript types for parsed JSON data
/** Any allowed JSON member value. */
export type JSONValue =
| string
| number
| boolean
| null
| JSONValue[]
| {[key: string]: JSONValue};
/** The generic result of parsing any valid JSON data. */
export type ParsedJSON = Record<string, JSONValue>;
/**
* Stricter version of `Omit`:
* Construct a type with the properties of T except for those in type K.
*/
export type OmitStrict<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
type JSONValue =
| string
| number
| boolean
| null
| JSONValue[]
| {[key: string]: JSONValue};
type ParsedJSON = {[key: string]: JSONValue};
function assertMatchesSchema<Schema extends yup.ObjectSchema>(
@iansan5653
iansan5653 / Apple.scala
Created October 29, 2020 01:21
Create a Case Class
case class Apple(color: String) extends Fruit {
val isSour: Boolean = color == "green"
}