Hyebin‘s blog
article thumbnail
Proxy Server?
Front-end 2022. 1. 29. 23:15

유저가 무언가를 보내면 프록시 서버에서 하는 일 1. 아이피를 프록시서버에서 임의로 바꿔버릴 수 있어 인터넷에서 접근하는 사람의 IP를 모르게 숨긴다. 2. 데이터를 보낼 때 도 데이터도 바꿔서 숨길 수 있다. (더 나은 보안 제공) 3. 방화벽 기능 4. 웹 필터 기능 (회사에서 직원이나 아이들 인터넷 사용 제어) 5. 어떤 사이트에 들어갔을때 static한 이미지를 프록시 서버에 저장을 시킬 수 있어, 인터넷까지 가지 않아도 프록시서버에 담겨 있는 정보를 빠르게 볼 수 있다. (캐쉬를 이용해 더 빠른 인터넷 제공)

article thumbnail
CORS 이슈, Proxy 설정
Other/Error 2022. 1. 29. 22:58

상황 CORS 이슈 발생! 원인 서버는 포트가 5000번이고 클라이언트는 서버가 3000번이다. 이렇게 두개의 다르 포트를 가지고 있는 서버는 아무 설정없이 request를 보낼 수 없다. Cors (Cross-Origin Resource Sharing) 정책은 번역 그대로 리소스를 공유할 때 적용되는 정책으로 다른 웹사이트에서 서버에 뭘 보내면 보안적인 이슈문제가 생긴다. 이때, 3000번, 5000번 각각을 Origin 이라고 하고 그 사이를 왔다 갔다 하는 것이다. 해결방법 프론트엔드 부분만 고쳐야 한다면 JSONP(JSON with Padding 또는 JSON-P) 로 모든 request를 get request로 바꿔서 보내면서 해결 할 수 있지만 제한적이게 된다. 백엔드 부분과 프론트엔드 부분을..

[Codewars/JS] Disemvowel Trolls
Algorithm/Codewars 2022. 1. 21. 00:58

Detail Trolls are attacking your comment section! A common way to deal with this situation is to remove all of the vowels from the trolls' comments, neutralizing the threat. Your task is to write a function that takes a string and return a new string with all vowels removed. For example, the string "This website is for losers LOL!" would become "Ths wbst s fr lsrs LL!". Note: for this kata y isn..

[Codewars/JS] Find the odd int
Algorithm/Codewars 2022. 1. 20. 18:18

Given an array of integers, find the one that appears an odd number of times. There will always be only one integer that appears an odd number of times. Examples [7] should return 7, because it occurs 1 time (which is odd). [0] should return 0, because it occurs 1 time (which is odd). [1,1,2] should return 2, because it occurs 1 time (which is odd). [0,1,0,1,0] should return 0, because it occurs..

article thumbnail
[Codewars/JS] Vowel Count
Algorithm/Codewars 2022. 1. 18. 18:29

Detail Return the number (count) of vowels in the given string. We will consider a, e, i, o, u as vowels for this Kata (but not y). The input string will only consist of lower case letters and/or spaces. function getCount(str) { var vowelsCount = 0; str = str .split("") .filter( (a) => a.match("a") || a.match("e") || a.match("i") || a.match("o") || a.match("u") ); vowelsCount = str.length; retur..

[JavaScript] 자바스크립트 동작원리 (Stack, Queue, 동기와 비동기)
Front-end/JavaScript 2022. 1. 18. 16:26

자바스크립트 코드의 동작 원리 console.log(1+1) setTimeout(function() { console.log(2+2) }, 1000) console.log(3+3) 이 코드를 실행하면 2 6 4 이러식으로 출력 결과가 나온다. 이 원리는 웹브라우저는 자바스크립트 코드를 실행시켜주는 엔진이다. 이때 해석할 때 단계는, 스택이라는 공간에 코드를 집어넣고 한줄한줄 실행을 해준다. (변수를 만났을 때는 힙이라는 공간에 넣고 가져다 쓴다.) 스택은 하나밖에 없기 때문에 한번에 코드 한줄 밖에 실행을 못한다. 이를 single threaded 라고 한다. setTimeout같은 코드는 바로 실행을 할 수 없는 코드이기 때문에, 잠깐 대기실에 놔두고 실행하다. 이 대기실에 보내는 코드들은 Ajax요청..

article thumbnail
[JavaScript] 객체지향 Class 문법 & prototype
Front-end/JavaScript 2022. 1. 18. 00:49

객체지향 Class 문법 만약에 {object} 자료형으로 정보를 가져올 때 그 수가 어마어마하게 많다면 일일히 치기 비 효율적이다. 이때 쉽게 할 수 있는 문법이 클래스 문법이다! 클래스 문법으로 비슷한 object형을 많이 만들어 쓸 수 있다. function 기계(스킬1,스킬2) { this.q = 스킬1; this.w = 스킬2; } this란? 간단하게 말해서 기계로부터 생성되는 object 이다. 이를 instance라고한다. this가 존재하면 클래스 역할이 가능하다. const nunu = new 기계('strike','courage') 클래스를 이용해 간단하게 오브젝트를 생성할 수 있다. new는 기계로 부터 자식을 뽑아주는 문법! ES6 class 문법 class Hero { const..

[Codewars/JS] Moving Zeros To The End
Algorithm/Codewars 2022. 1. 14. 15:40

Detail Write an algorithm that takes an array and moves all of the zeros to the end, preserving the order of the other elements. moveZeros([false,1,0,1,2,0,1,3,"a"]) // returns[false,1,1,2,1,3,"a",0,0] var moveZeros = function (arr) { // 0 카운터 세기 let arrLength = arr.length; let count = 0; for (let i = 0; i v !== 0), ...arr.filter(v => v === 0)] } 이 방법은 애플코딩에서 배웠던 방법이라 다시보니 반가웠다! 이 방법을 자주 활용해서 내 ..

검색 태그