분석과탐구
-
도커를 이용하여 PHP 개발 환경 설정하기분석과탐구 2023. 5. 3. 19:59
도커를 이용한 PHP 개발 환경 구축의 이점 도커를 이용한 개발, 배포 환경 구성의 이점은 무엇일까. 재사용하기 좋다는 것이 가장 크지 않나 싶다. 재사용하기 좋다는 것은 다음과 같다. 한 명의 프로그래머가 도커 기반으로 개발환경을 꾸미면 나머지 사람들은 그대로 사용하면 된다. 나머지 사람들은 같은 팀원일 수도 있고 미래의 내가 될 수도 있다. 그리고 이렇게 올려놓은 개발환경에 설정파일을 바꿔 서비스에도 올릴 수 있고. 개발환경을 꾸민다는 것은 단순히 IDE만을 설치하는 것이 아니라 프로그램을 실행하기 위한 라이브러리나 시스템 도구, 런타임 등 필요한 것들을 구성하는 것을 의미한다. 따로 세팅을 한다면, 똑같은 일을 여러 번 반복하게 되어 시간이 낭비된다. 그리고, 시스템에 기본적으로 적용된 버전 차이에..
-
CDN은 어떻게 저비용으로 콘텐츠를 전달하나분석과탐구 2023. 5. 3. 05:38
CDN은 어떻게 저비용으로 콘텐츠를 전달하나-ChatGPT 어떻게 이것이 가능한가. chatgpt에게 물어보았다. CDNs also employ techniques such as compression and minification of content, as well as image optimization, to reduce the size of the content being delivered, further reducing the load on the network and improving the speed of delivery. Additionally, CDNs typically have agreements with internet service providers (ISPs) that allow th..
-
divide and conquer vs dynamic programming분석과탐구 2023. 4. 8. 01:06
divide and conquer(분할 정복) divide and conquer는 문제를 작은 문제로 나누어 해결한다. 문제 자체가 답이 될 정도로 작게 분할한다. 그리고 그 결과들을 취합하여 조금 더 큰 문제를 해결한다. 이것을 반복하여 원래의 문제까지 돌아오고 문제를 해결한다. divide and conquer를 구성하는 원리 divide: 큰 문제를 작은 문제로 나눈다. 작은 문제는 큰 문제와 유사하지만 좀 더 사이즈가 작은 문제이다. 작은 문제는 다른 문제와 독립적이라, 문제를 풀어도 다른 문제의 정답엔 영향을 주지 않는다. 예를 들어, 원소 10개 배열을 정렬하는 문제를 5개 배열 2개로 나누어서 해결한다. 원소 5개 배열 하나를 정렬하더라도, 다른 배열을 정렬하는 문제와 독립적이다. conqu..
-
CRA의 npm run start는 서버를 띄우는 걸까?분석과탐구 2023. 3. 28. 13:43
CRA의 npm run start는 어떤 일을 하는 걸까? CRA(Create React App)의 npm run start 커맨드를 실행하면, 브라우저에서 로컬호스트의 3,000번 포트로 접속하여 개발한 내용을 확인할 수 있다. 그렇다면, 이 커맨드는 서버를 띄우는 것인가. 아니면 로컬의 파일들을 취합해서 단순히 보여주는 것인가. 확인해 보자. package.json의 scripts npm run start는 package.json에 scripts안에 정의한 것을 실행하는 커맨드이다. scripts안에 있는 커맨드를 보니 모두 react-scripts라는 것을 이용하여 커맨드를 실행하는 것으로 보인다. react-scripts는 어디에 있는 것일까. node_modules/.bin npm run으로 실..
-
express의 Request 타입 확장하기분석과탐구 2023. 3. 13. 11:57
express의 Request 타입 확장이 필요한 상황 // 익스프레스의 미들웨어 function auth(req, res, next) { // 인증을 다 한후에 id를 얻어낸다. // 이 id를 컨트롤러에서도 쓰고싶다. req.id = id; } app.get('/', auth, (req, res) => { // 미들웨어에서 req.id에 id를 등록하여 가져올 수 있다. const userId = req.id; }); 익스프레스에 미들웨어를 적용해서 사용하다 보면, 미들웨어에서 얻은 데이터를 컨트롤러로 그대로 넘기고 싶은 경우가 있다. 해당 데이터를 컨트롤러 쪽에서 다시 얻으려고 하면 미들웨어에서 했던 일을 반복해야 하는 경우가 있기 때문이다. 자바스크립트에서라면 `req.id = id;`처럼 그대로..
-
2. express 타입 이해...2분석과탐구 2023. 1. 7. 20:43
express 예제의 타입 확인. 이번 글의 목표는 npm에 올라온 express 예제의 타입을 확인하는 것이다. 다음은 express 예제에 번호를 추가한 것이다. const express = require('express') // (1) const app = express() // (2) app.get('/', function (req, res) { // (3) res.send('Hello World') // (4) }) app.listen(3000) // (5) 이 예제에 타입이 추가된 코드는 다음과 같다. (1)부터 (5)까지 코드를 보며 타입을 알아볼 것이다. (1) ~ (5)번으로 넘버링된 줄을 하나씩 살펴보자. (1) : "export = "로 모듈을 내보내는 파일을 받을 때 쓰는 방식이다...
-
1. express 타입 이해...1분석과탐구 2023. 1. 7. 07:32
express의 타입 npm express에 있는 모듈에서 가리키는 express 사용법은 다음과 같다. const express = require('express') // (1) const app = express() // (2) app.get('/', function (req, res) { // (3) res.send('Hello World') // (4) }) app.listen(3000) // (5) 위 코드 (1) ~ (5)에서 타입은 어떻게 되는가? express 자체는 자바스크립트로 먼저 작성되었다. 그리고, 타입이 따로 추가된 형태이다. NPM을 가보면 다음과 같이 되어 있다. express 라이브러리를 타입스크립트에서 사용하려면 타입 정보가 필요한 것이다. 이를 위하여 @types/exp..
-
std::move에 대하여분석과탐구 2022. 10. 3. 15:20
std::move 선언 std::move의 선언은 다음과 같다. 템플릿 함수 std::move는 함수다. 그 선언 모습은 위와 같다. 첫 번째 줄을 보면 템플릿으로 된 것을 볼 수 있다. 반환형 함수의 반환형을 보자. constexpr 키워드가 붙어있다. 함수에 붙은 constexpr은 이 함수가 컴파일 타임에 계산될 수도 있으니, 컴파일 타임에 계산할 수 있다면 우선하라는 의미이다. constexpr을 제외한 반환형은 std::remove_reference_t&&이다. 즉, T라는 타입에서 reference를 제거한 것에 &&을 추가한다. &&은 rvalue reference이다. 즉, T라는 타입에서 reference을 제거하고 다시 rvalue reference를 추가하는 것이다. 함수 이름 std..