-
항해 99 5기 TIL_17항해 99 2022. 1. 27. 04:19
▶ Today I Learned
<CS 스터디>
하드웨어에 10진 숫자보다도 비트를 사용해야 하는 이유?
1. 10진수 숫자 하나 세는 것 보다 비트를 세는 게 훨씬 많은 숫자를 나타낼 수 있으므로
ex) 10진수: 손가락으로 1부터 10까지 표현
비트: 2진수 방법으로 표현되므로 20인 1부터 29까지 표현
2. 재량권이 훨씬 커지기 때문에
비트의 경우 문턱값이 하나 뿐이기에 문턱값 전후 출력의 차이가 심함 → 간섭이 있어도 어느 한 쪽의 명령이 제대로 작동할 수 있음
[하드웨어]
<릴레이>
선을 둥글게 감아 코일을 만듬, 거기에 전기를 흘려보내면 코일이 전자석이됨
전자석은 켜고 끌 수 있어 물건을 움직일 때 활용가능
예시)
코일에 전력이 들어가지 않아 스위치가 열려있는 경우 → 열린 릴레이
코일에 전력이 들어가 스위치가 닫혀있는 경우 → 닫힌 릴레이
장점
1. 더욱 복잡한 연산이 가능
릴레이를 이어서 AND나 OR 구현, 한 스위치의 조건이 다른 스위치를 제어하게 될 수도 있음
→ 컴퓨터에 필요한 복잡한 논리 생성 가능
2. 전이 함수에서 문턱 값이 수직이다.
: 극이 이쪽으로 전환, 아니면 저쪽으로 전환, 둘 뿐이다.
(위의 재량권이 커진다는 장점으로 이어짐)
단점
느리고 전기를 많이 소모, 먼지나 벌레같은 이물질이 스위치 접점에 있으면 제대로 작동하지 않음
cf) 한 과학자는 오류를 추적하다가 릴레이에 낀 나방을 발견하였고 이맘 때 쯤 ‘버그’라는 단어가 유명해짐
<진공관>
물체를 가열하면 전자가 튀어나오는 열전자 방출 이라는 현상 기반으로 제작
애노드 ———
그리드- - - - (캐소드에서 나오는 전자를 쫓아내서 애노드에 도착하지 못하게 하는 역할)
캐소드 ____
히터 0000
히터를 제외한 셋을 삼극관이라 함
장점
1. 릴레이보다 빠르다.
단점
1. 진공관도 뜨겁고 깨지기 쉽다.
cf) 1세대 컴퓨터는 진공관을 사용했다.
<트랜지스터>
Transistor is a compound word of Transfer and Resistor. 진공관과 비슷하지만 반도체 사용
(반도체는 온도에 따라 도체나 부도체 성질로 왔다 갔다 가능)
온도 상승 → 전기 저항 하락 → 전도도 상승 → 도체 방향
온도 하락 → 전기 저항 상승 → 전도도 하락 → 부도체 방향
cf) 반도체는 쉽게 녹을 수 있기 때문에 주의,
- 생산과정 -
광식각: 실리콘 웨이퍼(얇은 판)위에 투영해서 현상하는 방법, 기판 위에 도핑을 하는 물질은 n과 p로 나뉨
여러 유형 중 중요한 두 가지 유형
쌍극 접합 트랜지스터: 전기가 한 방향으로만 흐를 수 있음
필드 효과 트랜지스터: 정전기 효과로 스위치를 움직임
현대 컴퓨터 칩에서 널리 쓰이는 것은 전력 소모가 적은 N채널, P채널 MOSFET
- 장점: 작고 빠르고 신뢰할만하며 전력 적게 소모
- 단점: 회로 구성 시 부품이 매우 많이 필요
<집적 회로>
integrated circuit, 생긴 모양 때문에 chip이라고 불림
장점: 복잡한 시스템을 트랜지스터 하나 비용으로 제작 가능
<홈페이지 구현>
input태그에 type에는 여러 종류가 있는데 여기서 password를 주게되면
브라우저 상에서 비밀번호가 가려져서 나옴
[넘기는 데이터와 스키마]
게시글 작성 API
router.post("/new_posting", async (req, res) => { // body는 payload와 같은 것, 전송하는 데이터, get을 제외한 method들에서 보통 사용함 const {title, name, text, pwd, date} = req.body; console.log(title, name, text, pwd, date) const createPostings = await new_posting.create({ title, name, text, pwd, date }) // create을 하면 연결된 db내 생성과 동시에 insert 해주는 것과 같은 역할 console.log(title, name, text, pwd, date) res.json({ postings: createPostings }); });
여기서 req.body부분에 들어가는 각각의 변수명과 Schema 코드 내 변수명들이 일치하지 않으면
validationError, Path 'title' is required 같은 오류가 발생한다.
아래는 스키마 (데이터 모델링 부분, db에 저장할 때 이렇게 구조화 해주세요 하는 느낌이다.)코드
const mongoose = require('mongoose'); const newPostingSchema = mongoose.Schema({ title: { type: String, required: true, }, name: { type: String, required: true, }, text: { type: String, }, pwd: { type: String, required: true, }, date: { type: Date, default: Date.now, }, }); module.exports = mongoose.model("newPosting", newPostingSchema);
[배열 내 json 형태 데이터 추출 불가능 할뻔]
$.ajax({ type: "GET", url: '/api/showPostings', data: {}, error: function (xhr, status, error) { // 에러 시 코드 }, success: function (response) { let postings = response; console.log(postings) console.log(postings.length) // 왜 json 형식의 값을 읽을 수 없는지.. // console.log(postings[0].title) // console.log(postings[0][title]) // console.log(postings[0]['title'])
배열 내 json 형태의 값이 들어있을 때 postings[0].키_이름 또는 postings[0]["키_이름"] 과 같이 작성해주면 됨.
▶ 느낀 점
오늘도 홈페이지의 많은 것을 구현하기에 쉽지 않은 하루였다. 예상은 했지만 매일 매일 막히는 부분이 많았다.
그러나 여러 팀원분들 덕에 으쌰으쌰 열심히 하고 있다. 얼른 자고 내일은 마무리까지 지어보자!
▶ 공부 시 참고 링크들
https://hianna.tistory.com/302
https://opentutorials.org/module/2919/22904
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
https://www.delftstack.com/ko/howto/javascript/javascript-json-array-of-objects/
튜터님이 추천해주신 자바스크립트 영상! 당장 보진 않았지만 조만간 한번 보도록 해야겠다 :)
본다고 다 이해되진 않겠지만 한 번 보고 필요한 정보를 찾아보고 활용하고 추후 다시 본다면 이해할 수 있겠지!
https://www.youtube.com/watch?v=v67LloZ1ieI
https://www.w3schools.com/jsref/met_his_back.asp
https://developer.mozilla.org/en-US/docs/Glossary/Callback_function
https://koonsland.tistory.com/114
'항해 99' 카테고리의 다른 글
항해 99 5기 TIL_19 (0) 2022.01.29 항해 99 5기 TIL_18 (0) 2022.01.28 항해 99 5기 TIL_16 (0) 2022.01.26 항해 99 5기 TIL_15 (0) 2022.01.25 항해 99 5기 WIL_2 (0) 2022.01.23