글

Update WireGaurd Package to 14 and set hashed password

Update WireGaurd Package to 14 and Set Hashed password VPN 서버로 wireGaurd를 세팅하였고, 해당 패키지가 오래 되어서 업그레이드를 하게 되었습니다.  i used wireGaurd as my VPN server, and the server is not updated long time so i try to update the package. 기존에는 password를 plain 방식으로 제공해서 추가하면 되었는데, 업데이트 된 버전부터는 password 값을 hashed 데이터로 넣어달라고 에러를 리턴하더라구요. previous the wireGaurd need to plain text password, but after the upgrade version, they need to put the hashed password in the environment. and if you sent not hashed password then they got a return from server 그래서 어떤식으로 제공하는지 에러 메세지에 나온 주소로 가봤는데, 해당 주소가 찾을수 없다는 에러가 리턴되었습니다. https://github.com/wg-easy/wg-easy/blob/master/How_to_generate_an_bcrypt_hash.md so i access the page they mention in the error details, but the page is not exists. this is the page link they mention in the error details https://github.com/wg-easy/wg-easy/blob/master/How_to_generate_an_bcrypt_hash.md    그래서 Chatgpt를 통해 물어보니, 제가 bcrypt 를 통해 hashed 한 데이터를 PASSWORD_HASH environment에 세팅해주면 된다...

Vuetify3 와 vue3를 활용해서 dynamic confirm 컨퍼런트 생성하기.

Vuetify3 와 vue3를 활용해서 dynamic confirm 컨퍼런트 생성하기. Vuetify3 와 vue3를 활용해서 dynamic confirm 컨퍼런트 생성하기. 이번에 vuetify3와 vue3를 사용하는 프로젝트에서 confirm component를 개발해야해서 찾아서 개발해보던 중에 관련된 리소스가 많이 존재하지 않는것 같아, 이 내용을 공유할려고 합니다. 저는 이런 방식으로 dynamic Confirm 컨퍼런트를 개발했습니다. 개발해야하는 Component 설명 https://vuetifyjs.com/en/components/dialogs/#usage 해당 Component를 통해 유저가 액션이 발생할 경우, 한번 더 확인하는 형태의 수단으로 사용 문제점: 기본적으로 component를 사용하는 page에 import후에 이벤트를 받아서 사용해야했음. 이 경우 불필요하게 모든 페이지 내에 해당 component를 import해야하는 번거러움이 생김. 또 코드가 수정되거나 이름이 변경되었을 경우 사용하는 모든 페이지에 내용을 수정해야함 해결방법: Dynamic Component를 사용해서 dialog를 로딩하고, 결과값을 promise를 통해 전달 받도록 작업 샘플 코드 confirm/index.js import Confirm from './Confirm.vue' ; export function confirm ( options = { } ) { const wrapper = document . createElement ( 'div' ) ; document . body . appendChild ( wrapper ) ; return new Promise ( ( resolve ) => { let app ; const comp = h ( Confirm , { messag...

Mac에서 docker 실행시에 행이 발생할때

 Mac에서 docker 실행시에 행이 발생할때 Mac을 메인 PC로 작업을 진행중에 갑자기 docker 실행시에 hang이 걸리는 이슈가 발생해서 해당 관련 내용에 대해 오류를 수정하다가 해당 내용이 공유가 되면 좋을것 같아서 이렇게 적습니다.   저는 방법을 찾던중에 docker 버전이 자동 업그레이드 되면서 발생한 이슈로 판단해서 기존에 PC에 깔려있는 docker를 지우고 새로 설치하는 형태로 이슈를 해결하였습니다.   이때 주의할 점은 기존에 docker를 Mac에서 지웠다고 하더라도 관련된 리소스들은 제거 되지 않아 문제가 원활하게 해결 되지 않습니다. 그래서 아래 내용을 통해 관련된 docker 리소스를 다 제거 후에 재 설치를 해줄 경우 docker가 정상 동작합니다. rm -rf ~/Library/Group\ Containers/group.com.docker rm -rf ~/Library/Containers/com.docker.docker rm -rf ~/.docker cd /usr/local/bin sudo rm -rf docker docker-compose docker-compose-v1 kubectl.docker com.docker.cli  https://github.com/docker/for-mac/issues/6576#issuecomment-1315409976

Application Load Balance에서 ecs websocket 서버 연결시 연결 안되는 문제

이미지
 Application Load Balancer 에서 ECS websocket 서버 연결시 연결 안되는 문제 기존에 ECS에서 서비스를 생성해서 alb (Application Load Balancer)와 target_group을 통해서 연결을 했습니다.  이번 경우에는 websocket 서버를 ecs에 service로 띄우고 나서 그걸 alb를 통해 클라이언트에서 접근할때 발생할수 있는 이슈에 대해서 적을려고 합니다. 다행히 2016년 부터 ALB에서 websocket 및 http2 프로토콜을 지원해서 따로 기존에 사용하는 load balancer 바꿀 일은 없었습니다. 관련 자료. * https://aws.amazon.com/blogs/aws/new-aws-application-load-balancer   기존의 방식 대로 alb의 rule을 적용 시에 ws://DOMAIN_NAME으로 접근 할 경우 접근이 불가능하다는 이슈 발생 * 이 경우 alb 에서 세팅된 rule의 stickiness가 enable 상태인지 확인 안되어있을경우 enable 상태로 하고 ws에 접근할 경우 접근 이 잘 되는걸 확인할수 있습니다.      저희 경우는 해당 이슈 빼고는 다른 이슈는 발생하지 않아서 여기서 마무리하도록 하겠습니다. 또 다른 웹 소켓을 사용하는 중에 다른 이슈 발생시 해결 방법에 대해 공유하도록 하겠습니다.

구글 인앱 백엔드 API 연결시에 purchase.subscriptions API 사용시 401 에러 발생 해결방법

이미지
  구글 인앱 백엔드 API 연결시에 purchase.subscriptions API 사용시 401 에러 발생 해결방법 구글 인앱 결제에 대한 내용을 가져오기 위해 purchase.subscriptions API를 사용해야하는데 그 경우 올바른 서비스 계정을 사용했음에도 불구하고 401 에러 발생 이유는 Google Play Developer Reporting API가 off 되어있어서 발생한 이슈 해결 기능 On 한후에는 purchase.subscriptions API를 백엔드에서 정상 동작함.

Leetcode 25h August

Leetcode 25h August Sum of Square Numbers 이 문제는 a 2 + b 2 = c 가 존재하는지 체크 하는 로직입니다. This problem is checking whether has a condition values like a formula that a 2 + b 2 = c 이경우 저는 c - a 2 값을 저장한 DP 리스트를 만들고, for 문을 돌면서 math.sqrt가 정수인 값을 찾도록 있을 경우 True 없을 경우 False를 리턴하는 방식을 사용했습니다. in this case, i create one list named DP, in theirs they saved c - a 2 value until a * a <= c after that loop the dp and checking whether the square root of element is integer value or not Python class Solution : def judgeSquareSum ( self , c : int ) - > bool : dp = [ ] i = 0 j = 0 while i * i <= c : dp . append ( c - i * i ) i += 1 for x in dp : if math . sqrt ( x ) % 1 == 0 : return True return False

Leetcode 24h August

Leetcode 24h August Complex Number Multiplication 이 문제는 두개의 String 값이 주워졌을 경우, 파싱을 통해 실수와 허수 나누고 그것에 대한 곱을 계산해서 리턴하는 문제입니다. This is the problem when they given two string value then return value that product of two imaginary numbers after parsed 이경우는 단순히 String parsing 이기 때문에 딱히 방법없이 split 메소드를 사용해서 값 가져오고, 그 후에 계산해서 리턴하였습니다. in this case, i don’t need to a specific way, i just used split method given default by language, and then return calculated value from parsed data. Java class Solution { public String complexNumberMultiply ( String num1 , String num2 ) { String [ ] arrOfNum1 = num1 . split ( "\\+" ) ; String [ ] arrOfNum2 = num2 . split ( "\\+" ) ; int x = Integer . parseInt ( arrOfNum1 [ 0 ] ) ; int y = Integer . parseInt ( arrOfNum2 [ 0 ] ) ; System . out . printf ( "%d %d \n" , x , y ) ; int xi = Integer . parseInt ( arrOfNum1 [ 1 ] . split (...

Leetcode 23th August

Leetcode 23th August Two Sum IV - Input is a BST 이 문제는 Tree에서 두개를 선택해서 합이 K가 되는 경우의수가 존재하는지 확인하는 문제입니다. This problem is checking condition that when you choose the two element in tree the sum of the elements value are same as K 이경우 저는 일단 Tree을 순회하면서 값을 List에 추가한 후에 이중 for loop를 통해 두개의 합이 k가 되는 값이 있는지 체크 하는 방법을 사용했습니다. for this case, first of all i gathering a every elements value in tree use dfs algorithm, then try to found a has a case that the sum of two elements is same as k Java /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(int val) { this.val = val; } * TreeNode(int val, TreeNode left, TreeNode right) { * this.val = val; * this.left = left; * this.right = right; * } * } */ class Solution { public boolean findTarget ( TreeNode root , int k ) { List < Integer > list ...

Leetcode 21th August

Leetcode 21th August Sudoku Solver 이 문제는 9x9 배열의 sudoku 문제 주워지고 그 빈값에 알맞은 답을 적용하는 방식입니다. This is the problem that return matrix that set correct value 이 경우에도 저는 grid 한 방식으로 9X9 배열을 돌면서 값이 없을 경우 1~9까지의 숫자를 돌면서 해당 답이 valid 할 경우 다음 row, col에 값을 대입하는 형태로 문제를 풀었습니다. i use previous way for solving this problem, so looping matrix then if the value is empty, i found a correct value from 1 ~9 Python class Solution : N = 9 def is_valid ( self , board , row , col , num ) : """ This function is for checking this board is valid or not :return: boolean """ # TODO: checking row is valid for x in range ( 9 ) : if board [ row ] [ x ] == num : return False # TODO: chcking colum in valid for x in range ( 9 ) : if board [ x ] [ col ] == num : return False # TODO: checking box is valid ...

Leetcode 20th August

Leetcode 20th August Valid Sudoku 이 문제는 제공된 9x9 matrix sudoku 문제가 valid 한지 안한지 리턴하는 문제 입니다. This is the problem to check whether given matrix is valid or not 이 경우는 간단히 O(N^2) 을 써서 사용했습니다. valid 한 조건의 경우 row, col, box에 같은 변수값이 있는지 없는지로 추가하였습니다. for solving problem i use that way that is looping given matrix and if the value is exists checking that value is valid or not. if the result is invalid then return False. and if don’t found a any invalid value in loop matrix then return True. Python class Solution : def is_valid ( self , board , row , col , num ) : """ This is the function to checking given num is valid or not. return: boolean """ # TODO: checking row is valid for x in range ( 9 ) : if x != col and board [ row ] [ x ] == num : return False # TODO: chcking colum in valid for x in range ( 9 ) : if x ...

Leetcode 17th August

Leetcode 17th August Leetcode 17th August Count Good Nodes in Binary Tree 이 문제는 Tree 를 순회하면서 Node의 상태가 good인 node의 갯수를 리턴하는 문제입니다. This is the Question return count of good node in tree 상태가 good 인 node란? tree의 parent의 값 들이 모두 자기 자신보다 작거나 같은 경우 What is the meaning of good node? the node’s value are greater than or equal to all of the values of parent node in tree 그래서 저는 dfs를 통해 Tree를 순회하면서 node의 parent의 값을 비교하는 방식으로 구현하였습니다. So i use dfs algorithm for access node by tree, and then calculate this node is good or not. if the node is good node then i adding 1 in answer Python # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution : def goodNodes ( self , root : TreeNode ) - > int : queue = deque ( ) root . parent = None queue . append ( root ) ...

Leetcode 15th August

Leetcode 15th August Leetcode 15th August Set Matrix Zeroes 이 문제는 matrix 가 주워졌을때 cell 중에 0 이포함되어있으면 그 해당 rows, cols의 값을 0으로 변경하는 문제 입니다. This question is Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0’s, and return the matrix. 그래서 저의 경우 rows, cols sets를 만든 다음에 matrix[i][j] 값이 0 일 경우 rows 에 i, cols에 j를 추가하고, 그담에 loop를 통해서 i가 rows 에 포함되어있거나 cols 가 j에 포함되어있을 경우 값을 0으로 변경하는 방식으로 해결했습니다. For solving this problem i create two sets named rows , cols and add i in rows and j in cols if the cell value is 0, after set up rows, cols values, set matrix value 0 if i value in rows or j value in cols Python Time complexity: O(M * N) class Solution : def setZeroes ( self , matrix : List [ List [ int ] ] ) - > None : """ Do not return anything, modify matrix in-place instead. """ n = len ( matrix ) m = len ( matrix [ 0 ] ) res = ...

Leetcode 14th August

Leetcode 14th August Group Anagrams 이 문제는 anagrams 가 같은 문자들 끼리 그룹화 해서 보여주는 문제 This question is return string list group by same anagrams 그래서 단순하게 저의 경우는 정렬 된 문자를 키로 가지는 map 만들고, 후에 값만 리턴 하는방식으로 문제를 해결하였습니다. For solving this problem, i used make a Map, that is key, value store, then the key is sorted string, and value is string list, after generate map i return values. Python class Solution : def groupAnagrams ( self , strs : List [ str ] ) - > List [ List [ str ] ] : res = defaultdict ( list ) for s in strs : ss = "" . join ( sorted ( s ) ) res [ ss ] . append ( s ) return [ v for i , v in res . items ( ) ] 요새 자바도 연습하고 있어서 똑같은 방식으로 자바 코드로도 한번 짜봤습니다. i also try to write a code in java, because for now i learning Java Java class Solution { public List < List < String >> groupAnagrams ( String [ ] strs ) { Map < String , List < String >> map = n...

Leetcode Weekly Context #250 회고

이미지
 Leetcode Weekly Context #250 회고 Leetcode Weekly Context #250 관련된 코드 리뷰 및 회고 내용입니다. 오늘은 요새 자꾸 회사에서도 개발보다는  기술 검토 및 아키텍쳐 설계를 담당하고 있고,  내 자신도 코로나 때문인지 밖에 잘 못나가서 그런지 답답한 감이 생겨서 오랜만에 leetcode Weekly Context를 간단하게 해볼까 합니다.  아마 다 풀지는 못할텐데,  일단 풀수 있는 만큼 만 풀고 나서 그것에 대한 회고 및 코드를 적을 까 합니다.   그리고 이걸 하는 이유는 점점 그날이 다가 오고 있기 때문이기도 하구요. leetcode Weekly Context 이건 leetcode 에서 매 주마다 4개의 알고리즘 문제를 출제하고 주어진 시간안에 누가 빠른 시간안에 푸는지를 경쟁하는 프로그램입니다. 원래 대로 라면 9시30분에 아침 운동 끝나고 나서 씻고 10시부터 12시까지 두시간 동안 진행해야 하는게 맞는데, 늦게 일어나는 바람에 남은 시간이 30분 밖에 없었네요. 30분 동안 2문제는  pass하고 나머지 한 문제는 풀었는데,  optimized 가 안되어있어서 Time limit이 걸렸네요.  이제 문제에 대해 설명 드리고, 어떻게 풀었는지 코드 및 설명 적도록 하겠습니다. 1935. Maximum Number of Words You Can Type 이건 text, brokenLetters 가 주워지면 text 의 letter 별로 brokenLetters가 포함되어있지 않은 letter에 대한 갯수를 리턴하는 문제입니다. 저는 간단하게 brokenLetters, letter를 set으로 만들고 둘 사이에 intersection 이 없으면 count ++ 를 하는 형태로 코드 구현하였습니다. 코드는 python으로 구현하였습니다. c++이나 자바가 더 빠르다고 하는데, 해당 언어에 대해서는 익숙하거나 그렇지 않아서...

Django + ASGI + Docker 적용하기.

 Django + ASGI + Docker 적용하기. 지금까지 Django wsgi + uWSGI 를 사용하다가 장고 3.0 버전에서 ASGI 서버를 지원하게 되면서 그것에 대해 코드 적용 및 발생 하는 이슈에 대해서 적을까 합니다. 1. Gunicorn worker hanging issue docker 내부에서 gunicorn 사용할때 worker가 가동되는데 그 워커의 tmp directory가  /tmp 로 docker 내부에 있는 overlay 스토리지 타입으로 되어있어서,  docker 내에서 gunicorn worker 가동시 blocking 걸릴수도 있음. 따라서 gunicron 의 worker tmp directory path를 세팅해줌으로써 worker 가 hanging 걸리는 이슈 해결 gunicorn --worker-tmp-dir /dev/shm ....  2. uvicorn --relaod 사용시 high cpu usage uvicorn high cpu 의 경우 reload 사용시 모든 폴더 및 파일을 watching 하고 있어서 이슈가 발생. reload-dir을 어플리케이션 directory 로 세팅해주면  high cpu usage 이슈는 해결됨. 기존에 45% 까지 사용하던 CPU Usage가 25%까지 줄어들었음. uvicorn --reload-dir /app 3. too slow response Application 의 경우는 Django 3.1 을 사용해서 Async view만 적용 되어, ORM 쪽은 async 로직이 아직 적용 안되어있는 상태 따라서 DJANGO_ALLOW_ASYNC_UNSAFE 세팅 필요. settings.py 에 해당 라인 추가 os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true" 그리고 지금 Application의 경우 graphql을 사용하고 있는데, 거기에 제공하는 playgorund를 통해 테스트 진행. 그리고 gun...

Axios request 사용시 self signed certificate chain Error

이미지
 기존에 Axios를 통해 request 를 요청하던중 self signed certificate chain 에러가 발생해서 코드가 다운 되는 이슈가 발생했습니다. 해당 이슈에 대해 확인 해보던 중에 알게 된 사실은 OpenSSL 이슈라는 걸 확인해서 찾아보던 중에 해결 방법으론 2가지가 있는데  1. axios instance 생성시에 httpsAgent 세팅을 통해서 해결 하는 방법 2. NODE_TLS_REJECT_UNAUTHORIZED Environment 세팅을 통해 해결     NODE_TLS_REJECT_UNAUTHORIZED=0 REFERENCES https://github.com/axios/axios/issues/535

Docker build시에 특정 라인 캐싱 제거하기.

이미지
 Docker 빌드 시에 특정 라인 캐싱 제거하기. Docker compose를 사용해서 여러개의 container를 동일한 Dockerfile 파일을 사용해서 만들때, ARGS에 따라서 다르게 빌드 되어야하는 경우, 캐싱처리로 인해서 올바르게 동작하지 않는 이슈가 발생하였습니다. 그래서 이 이슈를 해결 하기 위해 사용했던 방법에 대해서 적을까 합니다. --no-cache Argument 추가하기. docker build시에 --no-cache 추가하면 기존에 캐시 되는 Docker image를 제거 할수 있음. CACHEBUST Argument 사용하기. no-cache의 경우는 모든 Docker image cache를 제거 해서 파일은 업데이트 되는데 필요 없는 라인까지 업데이트 되는 경우가 발생.  CACHEBUST를 사용할 경우 해당 라인 밑에 있는 docker command에 대해서 캐시 처리 없이 항상 실행 됨. 저의 경우 barbel-node 를 사용하는데 그때 CACHEBUST를 추가해서 항상 코드가 업데이트 되도록 세팅함.

June Leetcode

2020/06/15 Cheapest Flights Within K Stops week-2-june-8th-june-14th Which language are used python3 How to solving Graph를 만들고, BFS를 사용해서 Graphql를 순회하면서 min_price를 찾고, 리턴하는 방식으로 개발함. Code class Solution: def findCheapestPrice(self, n: int, flights: List[List[int]], src: int, dst: int, K: int) -> int: # dp = value, step n = len(flights) dp = collections.defaultdict(list) for u, v, w in flights: dp[u].append((v, w)) queue = [] queue = [(src, 0, 0)] min_price = 100000 while len(queue): cur, queue = queue[0], queue[1:] cur_dst, cur_price, cur_step = cur if cur_dst == dst: min_price = min(min_price, cur_price) continue if cur_step<=K and cur_price<=min_price: for d, price in dp[cur[0]]: queue.append((d, price + cur_price, cur_step + 1)) ...

Ruby EBS Platform에서 webpacker not found 이슈 해결하기.

이미지
이번에 적어볼 내용은 Elastic Bean Stalk(EBS) 에서 webpacker not found 이슈 해결하기. 해당 내용을 적는 이유는 기존에 rails를 EBS ruby 2.6 버전에서 작업후 배포 하는 중에 webpack을 찾을수가 없다는 이슈가 발생하였고, 해결하기 위해 log를 찾아보던 중에 기존에 EBS instance에 설치 되어있는 노드 버전이 6으로 설정 되어있어 특정 패키지가 설치 되지 않아서 서버가 동작하지 않는 이슈였습니다. 그 후 구글을 통해 많은 검색을 해서 Node version을 업데이트 하는 스크립트를 찾아서 작성을 했습니다. 이게 초반에 구글을 통해 작성해서 넣었던 스크립트 내용입니다. TODO      EBS Container 스크립트를 통해 Node 업데이트하기. VERSION 1 아래 보시는 스크린샷이 초반에 노드 버전을 container에서 업데이트 하기 위한 초기 스크립트 입니다.  간단하게 설명 드리면 스크립트에 대해서 설명 해 드리면 Node를 curl을 통해 다운받아서 yarn 을 통해 nodejs와 yum을 업데이트 하는 스크립트 입니다. 해당 스크립트 사용시에도 여전히 node version이 업데이트 되지 않는 이슈가 있었습니다. RESULT     FAILURE DEBUG 해당 이슈에 대해 확인해보니  container를 통해서 12버전의 node를 다운 받았더라도,  yum -y install nodejs command 실행시에 기존에 다운 받은 6버전과 충돌 이 발생해 여러개의 repository가 있어서 업데이트 할수 없다는 이슈였습니다. VERSION 2 Version1에서 발생한 이슈를 해결 하기 위해 container에서 node 설치시에 기존에 설치 되어있는 nodesource repo를 제거 하고 배포하는 방식으로 변경하였습니다. 해당 내용은 기존에 node repo를 다운받기 전에 nodesource-re...

GitLab에서 dependatbot 연동하기.

이미지
GitLab에서 dependency 관리하기. 개인 프로젝트에서 github을 사용하고 있는데, 어느날 github을 통해 어느날 dependency 이슈가 될수 있거나,  오래 되서 업데이트가 필요한 libary에 대해서 알람 및 자동 PR까지 만들어서 알려주는 서비스가 있어서 이걸 gitlab에 적용하는 과정을 적을까 합니다.  그렇게 어렵지는 않고,  순서대로 따라만 하면 됩니다.  이걸 통해서 오래된 lib에 대한 변경을 조금이라도 빠르게 하면 좋겠네요. 요구사항 * gitlab access_token * forked  dependabot   project * dependency를 체크할 gitlab project 실행 순서 * dependatbot 프로젝트 fork해서 내 gitlab에 project 생성하기 * 내 계정 세팅에서 access_token 생성하기. * dependabot을 통해 생성된 프로젝트로 가서 settings/variables에 GITLAB_ACCESS_TOKEN 환경변수 세팅하기 * CI/CD에서 scheduler 생성하기. 프로젝트 생성하기 dependabot에서 사용할 gitlab access token 생성하기 dependabot에서 gitlab 환경 변수 세팅하기. scheduler에서 dependabot에서 사용할 환경 변수 세팅하기. TIPS 저의 경우에는 프로젝트 root에 있지 않고, 폴더 안에 package.json 파일이 있어서 찾아보니, 밑에 문서에는 없지만 DIRECTORY_PATH 라는 variable 세팅을 통해서 원하시는 폴더로 접근이 가능합니다. 저는 아래 링크를 참고해서 작업하였습니다. https://bobbybouwmann.nl/blog/dependabot-on-gitl...