Skip to content

Instantly share code, notes, and snippets.

View develax's full-sized avatar
💭
∑☯

Joe develax

💭
∑☯
View GitHub Profile
@develax
develax / TypeScript_Infer.md
Created September 22, 2024 19:17
TypeScript inferring types

TypeScript infer

/**
 * Extract String
 */
type ExtractStringType<T> = T extends `${infer U}` ? U : never;
type StrType1 = ExtractStringType<'ABC'>; // 'ABC'
type StrType2 = ExtractStringType<string>; // never

Infer Function Argument Type

A function that accepts an argument of an anonymous type where hobbies is a tuple:

function stringifyPerson(person: {
    name: string;
    age: number;
    hobbies: [string, string]; // tuple
}) {
    return `${person.name} is ${person.age} years old and loves ${person.hobbies.join(" and  ")}.`;
@develax
develax / TypeScript_Unions.md
Last active September 21, 2024 19:26
Unions as type property keys

Unions

Unions as type property keys

type StringKeys = 'firstName' | 'lastName';
type NumberKeys = 'age';

type Person = {
    [Key in StringKeys]: string;

Таксист зарабатывает 3 тысячи рублей в будни и 5 тысяч в выходные. При этом он тратит на еду 1 тысячу в будни, и 1.5 тысячи в выходные. Каждую третью неделю он тратит 2 тысячи на мойку автомобиля. Сколько понадобится времени, чтобы таксист заработал 1 миллион рулей?

Angular (VSCode)

Create new Angular project: ng new AppName

Run the project: ng serve --open (or F5 in VSCode)

Install styles npm install -D tailwindcss

@develax
develax / VSCode_TypeScript_setup.md
Last active May 5, 2024 12:47
VSCode + TypeScript setup

VSCode + TypeScript setup

Set TS version for VSCode intellisence

VS Code command palette: &gt; TypeScript: Select TypeScript version

@develax
develax / 3D-Engine-from-scratch.MD
Last active June 27, 2020 22:02
3D Engine from scratch
@develax
develax / BlenderHotkeys.MD
Last active March 5, 2020 21:41
Blender Hotkeys Cheat Sheet

Blender Hotkyes

UI

COMMAND DESCRIPTION
T Tools Panel (Transform)

Focus / View

@develax
develax / GIT
Last active August 14, 2020 10:45
Lazy man's guide: multiple GitHub HTTPS accounts on Windows
https://dev.to/configcat/lazy-man-s-guide-multiple-github-https-accounts-on-windows-2mad