memostack
article thumbnail
백준 2675번 / 문자열 반복 (nodejs 알고리즘 풀이)
Algorithm/Beakjoon 2022. 8. 29. 20:55

문제의 저작권은 백준 알고리즘(https://www.acmicpc.net/)에 있습니다 문제 풀이 전체 코드 const solution = (input) => { return input .slice(1, input.length) .reduce((acc, l) => { const [n, str] = l.split(' '); acc.push(str.split('').reduce((acc, c) => acc + c.repeat(+n), '')); return acc; }, []) .join('\n'); }; const input = []; require('readline') .createInterface({ input: process.stdin }) .on('line', (line) => input.push(..

article thumbnail
typegraphql + typeorm + postgres을 사용하여 monorepo apollo server 구축
Backend/GraphQL 2022. 8. 28. 13:50

monorepo 프로젝트 구성 프로젝트의 디렉토를 생성해준다. mkdir typeorm-apollo-server-example yarn berry를 사용할 예정이기 때문에, 아래 명령어로 berry 버전으로 변경해준다. yarn set version berry 아래에서 apollo server를 오류없이 원활하게 구축하기 위해, .yarnrc.yml의 nodeLinker를 node-modules로 수정해준다. nodeLinker: node-modules yarnPath: .yarn/releases/yarn-3.2.3.cjs yarn init 명령어로 monorepo 프로젝트를 초기 설정한다. yarn init -y package.json이 생성이 되면, workspace 경로를 정의하고, 편의를 위해 s..

article thumbnail
백준 10818번 / 최소, 최대 (nodejs 알고리즘 풀이)
Algorithm/Beakjoon 2022. 8. 27. 20:48

문제의 저작권은 백준 알고리즘(https://www.acmicpc.net/)에 있습니다 문제 풀이 최댓값과 최솟값을 구하는 bulit-in 모듈인 Math 모듈을 사용하면 쉽게 구할 수 있다. 모듈 도움없이 반복문을 사용해서 풀어도 되긴하지만, 굳이 제공해주는 모듈을 사용안할 이유는 없다고 생각한다. const solution = (input) => { const list = input[1].split(' ').map((s) => +s); return [Math.min(...list), Math.max(...list)].join(' '); }; const input = []; require('readline') .createInterface({ input: process.stdin }) .on('line..

article thumbnail
apollo server와 knex를 이용하여 postgresql 연동하기 (with monorepo, typescript)
Backend/GraphQL 2022. 8. 26. 21:24

환경 nodejs: v16.15.1 (lts) yarn version: berry 프로젝트 구조: monorepo Framework: apollo-server-express 기타 사용 모듈: typescript, Knex DB: postgresql monorepo 프로젝트 생성 graphql 서버 구축 전에 yarn workspace를 활용하여 monorepo 프로젝트 생성을 한다. mkdir knex-apollo-server-example yarn berry를 사용하기 위해 버전을 변경한다. 그리고 yarn init 명령어로 프로젝트 초기 설정을 한다. yarn set version berry yarn init -y .yarnrc.yml에서 nodeLinker에 node-modules를 추가한다. no..

article thumbnail
백준 2941번 / 크로아티아 알파벳 (nodejs 알고리즘 풀이)
Algorithm/Beakjoon 2022. 8. 25. 21:32

문제의 저작권은 백준 알고리즘(https://www.acmicpc.net/)에 있습니다 문제 풀이 전체 코드 const solution = (input) => { const s = input.split(''); let cnt = 0; for (let i = 0; i < s.length; i++) { const c = s[i]; const nc = s[i + 1]; const nnc = s[i + 2]; if (c === 'd') { if (i + 2 < s.length && nc === 'z' && nnc === '=') { i += 2; } else if (i + 1 < s.length && nc === '-') { i++; } } else if (c === 'c' && i + 1 < s.length ..

article thumbnail
백준 5622번 / 다이얼 (nodejs 알고리즘 풀이)
Algorithm/Beakjoon 2022. 8. 24. 21:25

문제의 저작권은 백준 알고리즘(https://www.acmicpc.net/)에 있습니다 문제 풀이 전체 코드 const solution = (input) => { const dial = [...Array(26).keys()].reduce((acc, i) => { const n = 65 + i; const c = String.fromCharCode(n); if (n < 68) acc[c] = 2; else if (n < 71) acc[c] = 3; else if (n < 74) acc[c] = 4; else if (n < 77) acc[c] = 5; else if (n < 80) acc[c] = 6; else if (n < 84) acc[c] = 7; else if (n < 87) acc[c] = 8; e..

article thumbnail
typescript react에서 styled-component 사용하기 (Theme Provider)
Frontend/React 2022. 8. 23. 21:16

styled-components 의존성 설치 styled-component를 사용하기 위해 styled-components와 @type/styled-components 를 의존서에 추가해야 한다. # with npm npm install --save styled-components # with yarn yarn add styled-components javacript에서 사용한다면 문제는 없지만, typescript에서 오류없이 사용하기 위해서는 styled-component의 type들을 가지고 와야한다. # with npm npm i --save-dev @types/styled-components # with yarn yatn add --dev @types/styled-components 첫 styl..

article thumbnail
Chrome 웹 브라우저 내부 아키텍처 및 동작 살펴보기 (3부)
Frontend 2022. 8. 22. 21:35

이전 브라우저 탐색에 대한 내용은 아래 글 참고바랍니다. 2022.08.20 - [Frontend] - Chrome 웹 브라우저 내부 아키텍처 및 동작 살펴보기 (2부) Chrome 웹 브라우저 내부 아키텍처 및 동작 살펴보기 (2부) 이전 브라우저 아키텍처에 대한 내용은 아래 글 참고바랍니다. 2022.08.18 - [Frontend] - Chrome 웹 브라우저 내부 아키텍처 및 동작 살펴보기 (1부) Browser Process 이전 글에서 살펴봤듯이 탭 외부의 모든 memostack.tistory.com Renderer Process는 웹 콘텐츠를 처리한다 Renderer Process는 탭 내부에서 발생하는 모든 일을 담당합니다. Renderer Process에서 Main Thread는 사용자에..

article thumbnail
백준 1157번 / 단어 공부 (nodejs 알고리즘 풀이)
Algorithm/Beakjoon 2022. 8. 21. 12:04

문제의 저작권은 백준 알고리즘(https://www.acmicpc.net/)에 있습니다 문제 풀이 전체 코드 const solution = (input) => { const en = new Array(26).fill(0); let max = Number.MIN_SAFE_INTEGER; input .toUpperCase() .split('') .forEach((c) => { const idx = c.charCodeAt() - 65; en[idx]++; max = max > en[idx] ? max : en[idx]; }); if (en.filter((n) => n === max).length > 1) return '?'; for (let i = 0; i < en.length; i++) { if (en[i]..

article thumbnail
Chrome 웹 브라우저 내부 아키텍처 및 동작 살펴보기 (2부)
Frontend 2022. 8. 20. 10:09

이전 브라우저 아키텍처에 대한 내용은 아래 글 참고바랍니다. 2022.08.18 - [Frontend] - Chrome 웹 브라우저 내부 아키텍처 및 동작 살펴보기 (1부) Chrome 웹 브라우저 내부 아키텍처 및 동작 살펴보기 (1부) 1부에서는 핵심 컴퓨팅 용어와 Chrome의 다중 프로세스 아키텍처에 대해 살펴봅니다. CPU & GPU 브라우저가 실행되는 환경을 이해하려면 컴퓨터 부품과 역할에 대해 이해하여야 합니다. CPU CPU(Central memostack.tistory.com Browser Process 이전 글에서 살펴봤듯이 탭 외부의 모든 것은 Browser Process에 의해 처리됩니다. Browser Process는 아래와 같은 스레드를 포함합니다. UI Thread: 브라우저의..