notes

2020. 8. 2.
symlinks

path 의 alias 라고 생각하면 쉽다.

ln -s /PATH/TO/ORIGINAL /PATH/TO/LINK
ln -s /PATH/TO/ORIGINAL /PATH/TO/LINK

2020. 7. 31.
Declaring Global Variables in TypeScript

daum 주소검색등 window에 뭔가 끼워넣는 외부 기능 사용시, window.someApi등으로 호출하게 될 때가 있는데, TS에서 당연히 Property 'someApi' does not exist on type 'Window & typeof globalThis'. 라고 뭐라고 한다. 요걸 해결하기 위해 보통은:

(window as any).someApi
(window as any).someApi

혹은

(<any>window).someApi
(<any>window).someApi

를 쓰라고 하는데 아래가 더 나은 것 같다.

declare global {
  interface Window {
    someApi: any; // 혹시 타입 정의를 제공해준다면 somApiType
  }
}
declare global {
  interface Window {
    someApi: any; // 혹시 타입 정의를 제공해준다면 somApiType
  }
}

요게 되는 것은 interface는 merging이 되기 때문.

Ref.

https://mariusschulz.com/blog/declaring-global-variables-in-typescript

2020. 7. 30.
asdf nodejs

  1. asdf를 설치한다.
    brew install asdf
    brew install asdf
  2. gpg를 설치한다.
    brew install gpg
    brew install gpg
  3. asdf nodejs plugin을 설치한다.
    asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git
    asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git
  4. nodejs release team의 gpg key를 추가한다.
    bash -c '${ASDF_DATA_DIR:=$HOME/.asdf}/plugins/nodejs/bin/import-release-team-keyring'
    bash -c '${ASDF_DATA_DIR:=$HOME/.asdf}/plugins/nodejs/bin/import-release-team-keyring'
  5. nvm등 사용중이던 vm이 있다면 호환성을 위해 ~/.asdfrc에 아래를 추가한다.
    legacy_version_file = yes
    legacy_version_file = yes
  6. 됫다.

how to uninstall node

https://reactgo.com/uninstall-node-npm-from-macos/

2020. 7. 27.
fix firefox color render

?

firefox의 컬러가 뭔가 좀 더 채도가 높게 렌더링 되는 경향이 있다.

  1. chrome
Screen Shot 2020-07-27 at 4 00 39 PM
  1. safari
Screen Shot 2020-07-27 at 4 01 59 PM
  1. firefox
Screen Shot 2020-07-27 at 4 03 52 PM

요걸 없애려면?

!

  1. 일단 firefox의 주소창에 about:config를 입력해 신비의 세계로 들어가서,
  2. 신비의 세계 검색창에 color_management를 쳐보면 아래와 같은 설정값들을 볼 수 있다. 이중에서, Screen Shot 2020-07-27 at 4 16 53 PM
  3. gfx.color_management.mode1로 바꾼다.
  4. gfx.color_management.enablev4true로 바꾼다.
  5. Screen Shot 2020-07-27 at 4 19 46 PM

이것들이 뭐냐?

  1. gfx.color_management.mode:
    • 0: Color management disabled.
    • 1: Full color management.
    • 2: Color management applied only to tagged images.
  2. gfx.color_management.enablev4:
    • 찾는 중

Refs

2020. 7. 22.
type argument default value

예를 들어, 첫번째 arg는 보통 string이고 두번째 arg는 보통 number인데 아닐 수도 있고 두번째 arg가 있을 수도 없을 수도 있는 함수의 타입을 정의한다면 아래와 같이 선언할 수 있을 것이다.

type ExampleFn<T, U> = (arg0: T, arg1?: U) => SomeReturnType;
type ExampleFn<T, U> = (arg0: T, arg1?: U) => SomeReturnType;

근데 쓸 때 마다 아래와 같이 하기는 매우 귀찮은 일이다.

const implmentedFn1: ExampleFn<string, number> = (val: string) => /* ... */
const implmentedFn1: ExampleFn<string, number> = (val: string) => /* ... */

그래서 ts는 type argument에도 default value를 정해놓을 수 있는데, 함수 default value랑 동일한 형태로, 아래와 같이 하면 된다.

type ExampleFn<T = string, U = number> = (arg0: T, arg1?: U) => SomeReturnType;
type ExampleFn<T = string, U = number> = (arg0: T, arg1?: U) => SomeReturnType;

이제부턴 굳이 명시할 필요가 생기지 않으면 그냥 편하게 쓸 수 있다.

const implmentedFn2: ExampleFn = (val: string) => /* ... */
const implmentedFn2: ExampleFn = (val: string) => /* ... */

그러고보니 아예 arg에 타입 어노테이션을 안해도 된다.

const implmentedFn3: ExampleFn = (val) => /* ... */
const implmentedFn3: ExampleFn = (val) => /* ... */