WSL Import/Export

Export

wsl.exe --export <DistributionName> <FileName>

WSL 관련 모든 프로그램 닫은 후,

wsl --export Ubuntu-20.04 Ubuntu20.04_dasomoli.wsl

Import

wsl.exe --import <DistributionName> <InstallLocation> <FileName>

Install할 경로 폴더 (C:\Users\dasomoli\AppData\Local\Packages\Ubuntu-20.04-dasomoli)를 만든 후,

wsl --import Ubuntu-20.04-dasomoli C:\Users\dasomoli\AppData\Local\Packages\Ubuntu-20.04-dasomoli Ubuntu20.04-dasomoli.wsl

[git] 추가된 파일이지만 변경은 무시하고 싶은 경우

git에서 repository에 파일은 추가해서 두고 싶지만 해당 파일이 빌드 중 변경되는 등의 이유로 변경은 무시하고 싶은 경우가 있다. 이런 경우 .gitignore에 추가해도 repository에 추가된 파일이므로 변경을 계속 추적하게 된다. 이 변경을 무시하고 싶다면 다음 명령을 주면 된다.

git update-index --assume-unchanged <file>

위 명령을 주면 해당 파일은 변경되어도 git status를 해도 나오지 않고 무시된다. 그러므로 주의해야 한다. 해당 파일을 다시 추적하고 싶다면 다음 명령을 입력한다.

git update-index --no-assume-unchanged <file>

[Javascript] Arrow function 정리

형식

다음은 모두 함수의 선언 혹은 표현식입니다. 마지막 형태가 arrow function입니다.

function dasomoli(arg1, arg2) {}
const dasomoli = function(arg1, arg2) {};
const dasomoli = (arg1, arg2) => {};

function 키워드를 제거하고 “=>” 를 중간에 넣는 형식입니다. 매개 변수 역시 사용 가능합니다.

바로 실행하고 싶은 경우(IIFE: Immediately Invoked Function Expression), 다음과 같이 괄호로 감싸서 실행합니다.

((arg1, arg2) => {
  console.log(arg1);
  console.log(arg2);
})(window, document);

생략 가능 형태

매개 변수가 하나인 경우, ( ) 생략 가능

매개 변수가 하나인 경우 괄호를 생략 가능합니다. 다음은 예제입니다.

const dasomoli = (arg1) => {};
const dasomoli = arg1 => {};

바로 return하는 경우, { }와 return 생략 가능

arrow function이 바로 return 하는 경우, 중괄호 { } 와 return은 생략 가능합니다. 다음은 예제입니다.

const dasomoli = (arg1, arg2) => {
  return arg1 + arg2;
}
const dasomoli = (arg1, arg2) => arg1 + arg2;

바로 { }로 감싼 object를 return 하는 경우, { }와 return은 생략 가능하지만 object를 ( )로 감쌈

예외로 { } 로 감싸는 object를 리턴하는 경우, object 전체를 괄호()로 감싸주어야 합니다. 다음은 예제입니다.

const dasomoli = () => { return { prop1: 1 }; }
// const dasomoli = () => { prop1: 1 } <- 이건 안됩니다.
const dasomoli = () => ({ prop1: 1 });

array는 상관 없습니다.

const dasomoli = () => { return [ v1, v2, v3 ]; }
const dasomoli = () => [ v1, v2, v3 ];

구글의 원온원 템플릿

https://docs.google.com/document/u/0/d/1NZaMq-tA0iksjkhrtqTcopdmoXavbETYWi4w99YI644/mobilebasic

구글의 원온원, 그러니까 1:1 면담을 위한 템플릿이다. 체크리스트처럼 생각하자.

관리자:

휴가 – 팀의 레스토랑 제안은 어떻게 되었나요? [관심 표시]

프로젝트 X의 영향력에 대한 디렉터의 직원 회의에서 칭찬 공유 [빅 픽처]

어떻게 지내셨나요? [체크인/업데이트]

무엇을 도와드릴까요? [장애물/장애물 제거]

예정된 오프사이트 날짜 [관리]

그 밖에 필요한 것이 있나요? [확장]

제가 해드리지 않고 있는 일이 있나요? [효과성 확인]

팀원:

지난주에 제가 한 일: 프로젝트 Y에 대한 업데이트

이번 주에 할 일 프로젝트 X의 v2.0에 대한 디자인 문서 제공

프로젝트 Y의 하위 프로젝트에 지연 가능성 플래그 지정

지난 주 1:1 ABC 토론에 대한 후속 조치 진행

C팀과 프로젝트 수행에 대한 관심 논의

피드백

수평적 관계 피드백: 목적이 동료의 성장을 지원하고 성과를 높이는 수단. 상시 진행 혹은 프로젝트가 종료될 때마다 하는 것이 효과적.

피드백의 틀로써 SBI:

Situation(상황): 피드백을 제공할 행동이 발생한 구체적인 상황을 서술.

Behavior(행동): 피드백의 대상이 되는 행동.

Impact(영향): 피드백의 대상이 되는 행동으로 발생한 영향의 내용을 서술.

지난 주 수요일에(S) Jane님께서 리뷰 전 기획서를 꼼꼼히 읽어주신 덕분에(B) 리뷰 회의 시간을 줄일 수 있었어요(I) Jane님께서 제 기획에 큰 관심을 가져주신 것 같아서 저도 더 열정적으로 임하게 돼요(I) 감사합니다.

비판적 피드백

I화법과 4A 기법

I화법: ‘저는’, ‘제가 느끼기에는’ 등, 내(I) 관점에서 이야기.

Aim to assist(도움에 집중): 도움을 주는 것에 집중. 비난하거나 나무라기 위함이 아님.

Actionable(행동기반): 당장 액션을 취할 수 있는 조언으로 구성.

피드백을 받는 사람이 준 사람에게..

Appreciate(감사하기): 동료에게 감사하기

Aacept or Discord(수용여부 표현하기): 비판적 피드백에 대한 수용 여부는 본인이 판단합니다. 수용하지 않기로 결정했다면 이유와 함께 본인의 대안을 설명합니다.

[Mac] 크롬 브라우저 사용의 몇가지 팁

단축키

  1. Cmd + `: 다른 창 이동
  2. Cmd + W: 탭 닫기
  3. Shift + Cmd + T: 이전에 닫았던 탭을 역순으로 열기
  4. Cmd + Option + 화살표: 탭 간 이동

트랙패드

  1. 두 손가락으로 왼쪽 또는 오른쪽: 이전 혹은 다음
  2. BTT(BetterTouchTool)에서 4 fingers tab을 Cmd + W로 맵핑하면 창 닫기도 터치로 가능

[MySQL] DB auto repair 및 optimize

제공하는 mysqlcheck로 check 및 복구, optimize를 하려면 다음과 같이 한다.

mysqlcheck -u <USER_ID> -p<PASSWORD> --auto-repair <DB_NAME>
mysqlcheck -u <USER_ID> -p<PASSWORD> --optimize <DB_NAME>

예제로 wordpress의 경우, user를 wordpress로 했다면, 다음과 같이 하면 된다.

mysqlcheck -u wordpress -pPASSWORD_HERE --auto-repair wordpress
mysqlcheck -u wordpress -pPASSWORD_HERE --optimize wordpress

근데 wordpress의 경우 테이블을 optimize를 지원하도록 만들지는 않는다…

[C] nm, readelf, objdump, size

링킹 관련 object file을 다루는 binutils 몇가지를 설명하고 command 예제를 보인다.

nm: object 파일 내의 symbol 을 나열한다.

nm dasomoli.o

readelf: symbol table을 보인다.

readelf -s dasomoli.o
readelf -hSl dasomoli.o

몇가지 옵션은 다음과 같다.

  -h --file-header       Display the ELF file header
  -l --program-headers   Display the program headers
     --segments          An alias for --program-headers
  -S --section-headers   Display the sections' header
     --sections          An alias for --section-headers
  -s --syms              Display the symbol table
     --symbols           An alias for --syms
     --dyn-syms          Display the dynamic symbol table
     --lto-syms          Display LTO symbol tables
     --sym-base=[0|8|10|16]
                         Force base for symbol sizes.  The options are
                         mixed (the default), octal, decimal, hexadecimal.

objdump: object file 내의 machine level 명령 및 그 disassembly를 보인다. macOS에서는 gobjdump를 사용한다.

objdump -d dasomoli.o

다음과 같이 -s -j 옵션으로 section 내용 확인이 가능하다. -s 는 선택된 section의 모든 내용을 보여 준다. -j <section> 은 section의 내용을 모두 표시한다.

objdump -s -j .data dasomoli.out

-S 옵션으로는 source disassembly 내용을 표시한다.

objdump -S dasomoli.out

size: static memory layout에 해당하는 세그먼트를 살펴볼 수 있다. POSIX utility program이다. macOS에도 있다.

size dasomoli.out
size -m dasomoli.out

[Web] “이 사이트의 보안 연결(HTTPS)은 완벽하지 않습니다.” 발생 시

https 적용 후 인증서 적용은 잘 되었지만, “이 사이트의 보안 연결(HTTPS)은 완벽하지 않습니다.”가 발생하는 경우가 있다. 이 경우는 사용하는 리소스 중 일부가 여전히 http를 사용하는 경우 나타난다.

브라우저의 개발자 도구를 이용해서 http를 사용하는 리소스를 찾아 모두 https를 사용하도록 하여 제거해주도록 한다.

Transmission SSL 설정하기

토렌트 머신으로 사용할 때 Transmission을 설치해서 사용한다. 우분투에서도 https://blog.dasomoli.org/raspberrypi-torrent-%eb%a8%b8%ec%8b%a0-%eb%a7%8c%eb%93%a4%ea%b8%b0/ 의 내용을 그대로 설정하면 된다. 이대로 설정하면 http 프로토콜을 이용하게 되는데, 여기서 한 단계 더 나아가서 SSL 설정을 통해 https를 쓰도록 설정하자. letsencrypt 인증서를 사용하는 certbot을 사용하면, 설정은 매우 간단하다.

# certbot --apache

실행 예제 화면은 다음과 같다.

root@bamtol:/etc/letsencrypt# certbot --apache
Saving debug log to /var/log/letsencrypt/letsencrypt.log

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: blog.dasomoli.org
2: torrent.dasomoli.org
3: www.dasomoli.org
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 2

Requesting a certificate for torrent.dasomoli.org

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/torrent.dasomoli.org/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/torrent.dasomoli.org/privkey.pem
This certificate expires on 2023-06-07.
These files will be updated when the certificate renews.

Deploying certificate
Successfully deployed certificate for torrent.dasomoli.org to /etc/apache2/sites-available/torrent.dasomoli.org-le-ssl.conf
Congratulations! You have successfully enabled HTTPS on https://torrent.dasomoli.org

NEXT STEPS:
- The certificate will need to be renewed before it expires. Certbot can automatically renew the certificate in the background, but you may need to take steps to enable that functionality. See https://certbot.org/renewal-setup for instructions.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

그럼 /etc/apache2/sites-enabled/torrent.dasomoli.org-le-ssl.conf 파일이 생성되는데 여기에 SSLProxyEngine on 옵션을 추가해준다. 그럼 이렇게 된다.

<IfModule mod_ssl.c>
<VirtualHost *:443>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        ServerName torrent.dasomoli.org
        ServerAdmin dasomoli@gmail.com

        ProxyPass / http://localhost:9000/
        ProxyPassReverse / http://localhost:9000/

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/torrent.log
        CustomLog ${APACHE_LOG_DIR}/torrent.access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf


SSLCertificateFile /etc/letsencrypt/live/torrent.dasomoli.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/torrent.dasomoli.org/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLProxyEngine on
</VirtualHost>
</IfModule>

이게 끝. apache2 서비스를 재시작한 후 https로 접근한다.