본문 바로가기

전체 글343

[Windows] Microsoft PowerToys PowerToys는 Windows10의 사용자 편의를 위한 유틸리티 모음 입니다. 공식 페이지는 다음 링크를 참고하세요 https://docs.microsoft.com/en-us/windows/powertoys/ 설치 설치는 공식 페이지의 가이드를 따르시면 됩니다. https://docs.microsoft.com/en-us/windows/powertoys/install 전 chocolatey를 사용중이라 choco로 설치 했어요. $ choco install powertoys winget 같은 다른 패키지 매니저 툴도 있긴 한데... 그건 차후에 다뤄보도록 할께요. (관심 있으시면 Windows Package Manager WinGet으로 찾아보세요.) 일단 전 choco로 사용하고 있어요. ^^ 설정 .. 2021. 7. 15.
[TypeScript] Indexed Access Types, Mapped Types, Conditional Types Indexed Access Type We can use Indexed Access Type to look up a specific property on another type. type Person = { age: number; name: string; alive: boolean }; let age: Person["age"] = 18; console.log(typeof age); // number The indexing type is itself a type, so we can use union, keyof, or other types entirely. type Person = { age: number; name: string; alive: boolean }; let person1: Person["age.. 2021. 7. 9.
[TypeScript] Mixins Mixin is a way that building up classes by combining simpler partial classes. It is a kind of component reuse. Basics It relies on using Generic with class Inheritance to extend a base class. type Constructor = new (...args: any[]) => {}; class ExClass { constructor(public name: string) { } } function MixinGenerator(Base: T) { return class Example extends Base { _age = 1; setAge(age: number) { t.. 2021. 7. 9.
[TypeScript] Generic Generic can create a component that can work over a variety of types rather than a single one. function identity(arg: T): T { return arg; } This generic function is the same as below. function identity(arg: number): number { return arg; } function identity(arg: string): string { return arg; } ... The T in the generic allows us to capture the type the user provides so that we can use that informa.. 2021. 7. 5.
[TypeScript] Singleton Pattern Singleton is the most popular design pattern. It is a kind of creational design pattern and it ensures that only one instance. Code class Singleton { private static instance: Singleton; private constructor() { } public static getInstance(): Singleton { if (!Singleton.instance) { Singleton.instance = new Singleton(); } return Singleton.instance; } } We can get the same single instance using getIn.. 2021. 7. 5.
[TypeScript] Class The class of TypeScript is similar to other languages. class Person { name: string; constructor(name: string) { this.name = name; } introduce() { console.log(`My name is ${this.name}`); } } let person = new Person('hoya'); person.introduce(); // My name is hoya Structural Type System TypeScript uses structural type system. That is, if the class has the same structure, they are compatible with ea.. 2021. 7. 4.
[TypeScript] Basic Types TypeScript gives us some data types and it helps us a lot. Boolean It has a true/false value. let isSuccess: boolean = true; Number let binary: number = 0b0111; let octal: number = 0o765; let decimal: number = 7; let hex: number = 0xcafe; let big: bigint = 1234n; If you want to use bigint, you need to use ES2020 or later. String let familyName: string = 'kim' let givenName: string = "hoya" let m.. 2021. 7. 4.
[Python3] typing module We can use a type in Python3. It is not enforced like other strong typed languages, but it can help us. It can be a communication tool with other developers and can prevent mistakes. Syntax The default syntax is like this. # def func_name(param: param_type) -> return_type # func_body def say_hello(name: str) -> str: return f"Hello {name}" Python3 supports bool, int, str, tuple, set, list, and di.. 2021. 7. 3.
[Python] Decorator Decorator allows you to dynamically add actions to a function or object without changing the behavior of the function or object. In Python, Decorator can be applied to a function and executed before and after the surrounding function. Simple Example This example changes the input string to the upper case. def to_upper_case(func): text = func() if not isinstance(text, str): raise TypeError("Not a.. 2021. 6. 29.