분류 전체보기 208

(React) useCallback

function factory(a, b) {    return a + b; } const sumFunc1 = factory(); const sumFunc2 = factory();console.log(sumFunc1(1, 2)); // => 3 console.log(sumFunc2(1, 2)); // => 3console.log(sumFunc1 === sumFunc2); // => false console.log(sumFunc1 === sumFunc1); // => true같은 factory함수를 가르킨다고 해도 인스턴스 오브젝트는 서로 다르다. 또한 렌더링이 자주 반복되는 경우에도 이전 인스턴스와는 다른 sumFunc1과 sumFunc2 인스턴스가 생성된다. 그럼 언제 useCallback 필요할까?일단..

(React) map 에 의한 루프에서 표시가 되지 않는 문제

{  } 로 감싸여져 있는 경우 반드시 return 이 없는 경우 아무것도 표시되지 않는다.return (     { this.state.task.map((item,contentIndex) => {                   ( hello {item.event} {item.eventpara} ) })               }     ) 해결책 1) return 을 명시return (     { this.state.task.map((item,contentIndex) => {                 return ( hello {item.event} {item.eventpara} ) })              }    ) 해결책 2) { } 를 제거return (       { this...

(React) 무한 렌더링 원인과 방지

const [count, setCount] = useState(0);const handlecart= (item) => {          setCount(count+1);          setItem(item);}무한 렌더링을 유발하는 코드handlecart(item)}>cart 위의 코드는 handlecart 함수의 참조를 패스하는게 아니라 함수 자체를 호출하고 있다. 따라서 인위적으로 클릭하기 전에 인터프리터가 코드를 파스할 시에 함수를 실행하게 된다. 이로인해 함수내에서 스테이트는 업데이트되고 화면은 다시 렌더링하게 되서 무한 루프에 빠지게 된다.   따라서 해결책은 함수의 참조를 설정하는 것이다.() => handlecart(product)}>cart

threading / multiprocessing / asyncio

wikipedia에서 랜덤 100 페이지의 타이틀을 화일로 저장하는 샘플로서 multiprocessing과 async 를 이용하여 처리속도의 향상을 보여주고 있다.multiprcessing : 계산등의 CPU 의존적인 처리에 유리 async : 화일 I/O, 네트워크 I/O 등의 Blocking처리에 유리위의 둘을 이용하여 처리속도를 향상import asyncio                                         # Gives us async/await import concurrent.futures                        # Allows creating new processes import time from math import floor               ..

data science/python 2024.05.02

json

json.dumps vs json.jsonify return json.dumps({"language" : "python"}) return jsonify({"language" : "python"})자동으로 header 의 Content-Type  을 text/html; charset=utf-8 로 설정※ 수동으로 header 를 변경해 줘야 함.자동으로 header 의 Content-Type  을 application/json 로 설정 json.jsonify 와 함께 스테터스 코드로 함께 리턴 return jsonify({"language" : "python"}), 204 리턴하는 한글(비영어) 깨짐 해결 app.config["JSON_AS_ASCII"] = False frontend로부터의 json 데이..

image byte 데이터 <-> numpy string

인터넷 스트림으로 이미지를 전송할 경우 이미지 데이터는 string 형식으로 변환해야 한다.import numpy as np import base64 import sys def base64_encode_image(a):     # base64 encode the input NumPy array     return base64.b64encode(a).decode("utf-8") def base64_decode_image(a, dtype, shape):     # if this is Python 3, we need the extra step of encoding the     # serialized NumPy string as a byte object     if sys.version_info.major =..

data science/python 2024.04.29

Idioms 5개

1. 행동이 앞서다. 옛날 총소리로 출발신호를 알리기 전에 먼전 출발하는 것에 유래. Don't jump the gun! Wait for me! 앞서가지 말고 날 기다려! You jumped the gun. You should have waited for me. 너무 앞서 갔다구! 날 기다려야 했어. 2. 개운치 않게 잠에서 깨다. 찌푸둥 하다. 3. (면접, 첫인사, 미팅등) 좋은 인상을 주려 최상의 자신을 표현하다. 4. 어려운 상황이 닥쳤을때 최선을 다하다. 복싱에서 상대방의 펀치를 살짝 비켜 충격을 최소하는 것에 유래. 5. 여유를 가져라. 1960년대 골프선수의 자서전에서 유래. You need to stop and smell the roses. You're working too much.

youtube english 2024.04.16

미용실 영어

What are we doing with your hair today? 머리 어떻게 해 드릴까요? Well I want it more blonde. 좀 더 금발로 하고 싶네요. Okay, do you want a full dye or just highlights? 풀염색, 부분염색? I think just highlights and to cover my roots. 부분염색으로 가르마도 물들여 주세요. Would you like a haircut as well? 머리도 자르실까요? Just trim the ends. = You want a trim. 끝을 다듬어 주세요. Do you want me to cut your bangs as well? 앞머리도 짜를까요? You want to grow out y..

youtube english 2024.04.16

무한 증세

수탈, 성질난다~ 결국 시작된 기사다 수상의 무한 증세 「収奪、腹立つわー」ついに始まった岸田首相の無限増税「国民年金」月460円、2026年からは「 4月1日から新年度が始まった。毎月支払う国民年金の保険料は、460円増えて1万6980円。2024年度の1年間で、5520円の負担増となる。 2025年度は、さらに530円増で1万7510円と news.yahoo.co.jp 일단 기사를 언급하기 전에 일본에서 소득 800만엔 프리랜서의 1년치 세금과 사회보장비 내용을 살펴 보자. 1. 소득세(소득구간별 차등) : 23% = 184 만엔 2. 동일본지진부흥 특별소득세 : 2.1% = 16.8 만엔 3. 주민세 : 약 10% = 80 만엔 4. (신설) 인보이스제도 소비세 : 5만엔 ⇒ 2023년10월부터 시행한 사실상의 자영업자 증세 이..

10 MAGIC Phrases for Giving Recommendations in English

1. it's a must-see 꼭 봐야돼! 2. you won't regret it 후회하지 않을 거야 3. it's well worth seeing 볼 가치가 있다 4. don't miss it 놓치지 마 5. you should definitely go 꼭 가봐야 돼 6. I really think you would like this ... 좋아 할 거라 생각돼 7. I highly recommend it 매우 추천해 8. You should definitely visit 꼭 방문해 봐 9. make sure 꼭 - 10. you have to watch / visit

youtube english 2024.03.27