묻고 답해요
161만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결홍정모의 따라하며 배우는 C++
9.12 이니셜라이저리스트 연습문제
#include <iostream>#include<cassert>using namespace std;#include<initializer_list> class IntArray{ unsigned mLength = 0; int *mData = nullptr;public: IntArray(unsigned length) : mLength(length) { mData = new int[length]; } ~IntArray() { delete[]this->mData; } IntArray(const std::initializer_list<int> &list): IntArray(list.size()){ int count = 0; for ( auto &e : list ) { mData[count] = e; ++count; } } friend ostream &operator<<(ostream &os, IntArray &arr) { for ( unsigned i = 0; i < arr.mLength; ++i ) { os << arr.mData[i] << " "; } os << endl; return os; } //=operator IntArray& operator=(const std::initializer_list<int> &array) { cout << "assignment operator" << endl; delete[] mData; mLength = array.size(); if(mData!=nullptr ) { mData = new int[mLength+1];//이 부분에서 mData = new int[mLength];로 코딩하면 버퍼 오버런이 뜹는데 오류 메세지를 보면이렇게 나옵니다 0에서 0사이라는 것이 뭔가요?? int i {}; for ( auto &e : array ) { mData[i++] = e; } } else { mData = nullptr; } return *this; }}; int main(){ IntArray intArray = {11,12,13,14,15,16,17,18,19,20}; intArray = {1,2,3,4,5,6,7,8,9,10}; cout << intArray << endl;}
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
start.spring.io 업데이트
강의와 다르게 Project에서 Gradle이 두 가지로 나눠져 있는데 어떤 걸 선택하면 될까요 ?
-
미해결설계독학맛비's 실전 AI HW 설계를 위한 바이블, CNN 연산 완전정복 (Verilog HDL + FPGA 를 이용한 가속기 실습)
챕터5 CNN basic 질문입니다
안녕하세요 좋은 강의 감사합니다.1. 강의내용 중 stride를 설명하실 때 output 피쳐맵의 크기가 X/stride, Y/stride로 일반화가 가능하기 때문에 stride가 1이면 input output featuremap 크기가 동일하다고 설명 해주셨는데, 만약 stride가 1일 때, padding이 없다면 X-2, Y-2만큼의 output feature map이 생기지 않나요? padding이 없다면 컨볼루션 할 때 미정의 값으로 연산을 해야할 것 같아서요..! 2.아래의 그림에서 output 채널의 크기는 예시에서 임의로 주어진 것인지 궁금합니다! output 채널의 크기인 24개 만큼의 depth가 weight에 있다고 가정한 예시일까요?
-
미해결함수형 프로그래밍과 JavaScript ES6+ 응용편
강의에 대한 제언
좋은 강의 정말로 감사합니다. 당연히 아시겠지만, 모든 엘리먼트에 이벤트 리스너를 다는 것 보다, 부모에 이벤트 핸들링을 위임하는 방식이 코드 작성량도 적고 메모리 사용량도 적은것으로 알고 있습니다. 추후 강의 개편을 하실 때, 이 내용을 강의에 넣어주실 수 있을까요?
-
미해결함수형 프로그래밍과 JavaScript ES6+ 응용편
DOM 조작 관련 질문입니다.
$.el 함수를 구현하실 때, 실제 DOM을 만들어서(비록 렌더링 되지는 않았지만) wrapper를 구현하셨는데, document.createDocumentFragment 로 하지 않으신 이유가 있나요?
-
미해결피그마(Figma)를 활용한 UI디자인 입문부터 실전까지 A to Z
강사님 auto arrow는 export시 이미지나 pdf에 표기가 안되는데
pdf나 jpeg로 이거 표기 되게 하는 방법이 있나요?
-
미해결스프링 프레임워크 입문
'프로젝트 세팅' 영상부터 재생이 안돼요;
'프로젝트 세팅' 영상부터 재생이 안돼요;
-
미해결데브옵스(DevOps)를 위한 쿠버네티스 마스터
nodeport tomcat 문의드립니다.
tomcat으로 노드포트 30002 연동하는게 안되서요.일단 서비스랑 np, lb 합쳐서 yaml 만드니까 자꾸 에러가 나서 svc.yaml / np-lb.yaml 을 따로 만들어서 create 하였습니다.tomcat-svc.yamlapiVersion: apps/v1 kind: Deployment metadata: creationTimestamp: null labels: app: tomcat name: tomcat spec: replicas: 1 selector: matchLabels: app: tomcat strategy: {} template: metadata: creationTimestamp: null labels: app: tomcat spec: containers: - image: tomcat name: tomcat ports: - containerPort: 8080 resources: {} status: {}create 성공 tomcat-np-lb.yaml# tomcat-np-lb.yaml # # nodeport apiVersion: v1 kind: Service metadata: name: tomcat-np spec: type: NodePort selector: app: tomcat app.kubernetes.io/name: tomcat ports: - port: 80 targetPort: 8080 nodePort: 30002 --- # LB # apiVersion: v1 kind: Service metadata: name: tomcat-lb spec: type: LoadBalancer selector: app: tomcat app.kubernetes.io/name: tomcat ports: - protocol: TCP port: 80 targetPort: 8080create 성공 둘다 성공해서 -o wide 해서 봤는데LB ip 노드포트(30002) 접속30228 포트는 LB 포트입니다.톰캣 자체가 좀 오래 걸려서 기다렸는데도 불구하고 안돼요. 버전을 console/tomcat-7.0으로 변경해도 그대로입니다. connection refused도 계속 되고요.구글 콘솔로도 확인했는데 deploy랑 전부 만들어진거 확인했습니다.근데도 톰캣 사이트가 안떠요 ㅜㅜ어디가 잘못됐는지 잘 모르겠습니다.ㅜㅜ
-
미해결[코드팩토리] [초급] Flutter 3.0 앱 개발 - 10개의 프로젝트로 오늘 초보 탈출!
await 관련
강사님 안녕하세요,await 관련해서 질문있습니다. 1) HomeScreenint? result = await Navigator.of(context).push<int>(MaterialPageRoute(~~~))2) SettingsScreenNavigator.of(context).pop(maxNumber) 1번 코드를 통해 SettingsScreen 으로 이동한 후 2번 코드를 사용하지 않고 뒤로가기 버튼을 통해 HomeScreen(1번 페이지)로 복귀한 경우, await가 콜백(결과값?)을 받기 위해 스케쥴이나 대기열(?)에 등록된 상태일 것 같은데 이 상태에서 다시 1번 코드를 사용해서 SettingsScreen으로 이동하는 경우, 스케쥴(대기열?)에 동일한 await 가 2개 등록되는 것인지 궁금합니다! 만약 2개가 등록된다면 1개는 사용하지 않는 메모리(가비지..?)가 되는지도 궁금합니다...감사합니다!* C언어 기초는 공부하고 학습하고 있기는 한데 전공자가 아니라...단어나 개념이 정확하지 않습니다;;ㅠㅠ
-
미해결데브옵스(DevOps)를 위한 쿠버네티스 마스터
docker: unauthorized: authentication required
Jupyter LAB 환경 구축 시docker: unauthorized: authentication required. 라고 나오면서 정상적으로 실행이 되지 않습니다.해결방법이 있을까요?
-
미해결
django 스크립트에 비동기 함수를 사용하려면 어떻게 해야 할까요??
안녕하세요? 장고 입문자입니다!현재 웹 크롤링 후 특정 정보를 텔레그램 봇을 통해 전송하는 코드를 구현하고 있는데 갑작스레 비동기 함수를 사용해야 한다는 에러가 발생하더라구요.. (function was never awaited)비동기 함수를 사용해본 적이 없다보니 구글링을 통해 1회성으로 작동하는 스크립트는 완성하였는데, 장고 프로젝트 내의 스크립트로 옮길 때도 다른 문제가 발생하더라구요..from asyncore import loop from datetime import time from bs4 import BeautifulSoup import requests import telegram import asyncio from hotdeal.models import Deal # 특정 웹에 대해 크롤링한 객체(Deal)의 정보를 담고 있습니다. async def test(): response = requests.get('https://www.ppomppu.co.kr/zboard/zboard.php?id=ppomppu') soup = BeautifulSoup(response.text, "html.parser") BOT_TOKEN = 'TOKEN' bot = telegram.Bot(token=BOT_TOKEN) for item in soup.find_all("tr", {'class': ["list1", "list0"]}): try: image = item.find("img", class_="thumb_border").get("src")[2:] title = item.find("font", class_="list_title").text.strip() link = item.find("font", class_="list_title").parent.get("href") link = "https://www.ppomppu.co.kr/zboard/" + link reply_count = int(item.find("span", class_="list_comment2").text) up_count = item.find_all("td")[-2].text up_count = up_count.split("-")[0].strip() up_count = int(up_count) if up_count >= 5: if Deal.objects.filter(link__iexact=link).count() == 0: Deal(image_url = image, title = title, link = link, reply_count = reply_count, up_count = up_count).save() await bot.sendMessage(-1001897599228, '{} {}'.format(title, link)) except Exception as e: print(e) def run(): asyncio.run(test())위 코드를 장고 내에서 작동시키기 위해 runscript를 사용할 경우 에러가 발생합니다ㅠinvalid literal for int() with base 10: '' 'NoneType' object has no attribute 'text' invalid literal for int() with base 10: '' 'NoneType' object has no attribute 'text' invalid literal for int() with base 10: '' 'NoneType' object has no attribute 'text' invalid literal for int() with base 10: '' You cannot call this from an async context - use a thread or sync_to_async. 'NoneType' object has no attribute 'text' invalid literal for int() with base 10: '' 'NoneType' object has no attribute 'text' You cannot call this from an async context - use a thread or sync_to_async. 'NoneType' object has no attribute 'text' You cannot call this from an async context - use a thread or sync_to_async. You cannot call this from an async context - use a thread or sync_to_async. You cannot call this from an async context - use a thread or sync_to_async. You cannot call this from an async context - use a thread or sync_to_async. You cannot call this from an async context - use a thread or sync_to_async. You cannot call this from an async context - use a thread or sync_to_async. 'NoneType' object has no attribute 'text' 'NoneType' object has no attribute 'text' invalid literal for int() with base 10: '' 'NoneType' object has no attribute 'text' invalid literal for int() with base 10: ''async, asyncio, await, time.sleep() 등등 이것저것 사용해봤는데 마땅히 해결책을 찾기가 어렵네용.. 조언주시면 감사하겠습니다ㅠ
-
미해결프로그래밍 시작하기 : 파이썬 입문 (Inflearn Original)
강의자료 관련
안녕하세요, 먼저 파이썬 관련 좋은 강의해주셔서 감사합니다 :)강의자료 파일이 열리지 않아 메일로 보내주셨으면 하여 글 남깁니다. gkalsry@naver.com 여기로 보내주시면 감사하겠습니다! 좋은 하루 보내세요 :)
-
미해결스파크 머신러닝 완벽 가이드 - Part 1
Pandas vs Spark: 비용, 처리시간 비교
안녕하세요 선생님, 항상 좋은 강의 제공해주셔서 감사합니다. 저는 데이터 관련 현업에 종사하고 있는 직장인입니다. 업무를 하다가 궁금한 점이 있어서 질문 드립니다. 데이터:매주 60만개 레코드가 업데이트 및 증가하는 DF_A매일 1000개 레코드가 업데이트 및 증가하는 DF_B Task: 매일 DF_A 와 DF_B를 1) merge하여 2) aggregation (groupby, count, merge 등 포함)을 하고 3) 결과 값을 다른 곳에 저장하는Databricks에 job이 있습니다. 이 둘을 spark로 읽어들여 merge를 함으로써 메모리 및 시간을 (이미 오래걸리지만) 절약하고 있습니다. Spark로 둘을 merge한 후, pandas로 dataframe을 변화하여, aggregation 처리를 하고 있습니다. 제가 이해하기로 Pandas는 아무래도 dataframe을 memory에 올려놓고 하다보니 groupby(), count() 와 같은 aggregation 결과를 즉각적으로 볼 수 있는 반면, spark는 memory에 올려놓지 않아서 dataframe의 레코드 개수 파악을 하기 위해 count()를 하더라도 엄청 오래걸려 aggregation 처리는 pandas로 하고 있습니다. 다만 이 경우, memory의 사용이 너무 과다하여 시간이 지날수록 처리해야하는 데이터 양이 많아지게 되면 out of memory 에러가 날 수 있는 위험이 있다고 생각이 듭니다. 제가 aggregation을 pandas로 바꿔서 하는 이유는1. pandas에 익숙해서2. spark보다 aggregation이 더 빨라서 (테스트해보지 않아 사실 정확하지 않습니다. 눈에 보이는 즉각적인 aggregation 결과만 봤을때 pandas가 더 빠르다고 생각이 들었습니다.) 제가 생각하기에 pandas가 아닌 모든 것을 spark로 aggregation 함으로써 장점은1. memory 에러가 날 걱정이 거의 없다.2. Memory를 덜 사용함으로써 비용 절감의 효과가 있다? (databricks에서 cluster를 리소스 사용량이 아닌 이미 만들어진 cluster에 대해서는 사용량이 적던 많던 사용시간에 비례해서 늘어나는 걸로 알고 있는데 확실치 않습니다.)3. 어쩌면 pandas보다 aggregation이 빠를 수 있다???위에 spark 장점 2, 3번에 대해서 특히 3번에 대해서 spark 보다 pandas의 aggregation 연산이 더 빠른지, 아직 spark로 aggregation 코드를 작성하지 않아 직접 비교는 해보지 않았습니다. 혹시 선생님의 의견으로는 모든 것을 spark로 하는게 좋을지 혹은 현재처럼 pandas로 하는 것도 괜찮을지, 그 외 추가적으로 고려해 보아야할 부분에 대한 조언 여쭙고자 질문 남깁니다. 답변에 대한 추가적인 질문은 대댓글을 남기면 되는지 혹은 질문을 다시 추가해야 선생님이 알림 받기가 편하신지 알려주시면 감사하겠습니다! 항상 좋은 컨텐츠 제공해 주심에 감사합니다!
-
미해결Node.js로 웹 크롤링하기
현재 페이스북 로그인 화면이 좀 바뀌었는데,
페이스북 로그인 버튼 예를 들어 document.querySelector('#loginbutton').click() 강좌의 이런 라벨이 사라졌어요버튼 바로 위가 div 태그인데, div 태그를 클릭하면 반응이 없고,버튼 클래스 이름의 태그를 클릭 해야지만 반응이 있네요 이 부분은 어떻게 다루는게 좋을까요?
-
해결됨Vue.js 완벽 가이드 - 실습과 리팩토링으로 배우는 실전 개념
권한요청 부탁드립니다
인프런 아이디 : jjkim0222인프런 이메일 : jjkim0222@naver.com깃헙 아이디 : jjkm0222@gmail.com깃헙 Username : JJK0104
-
미해결블렌더 처음 시작부터 로우폴리 3D 애니메이션 까지
Bevel 관련
안녕하세요. bevel기능이 평소에는 잘 되는데 가끔가다가 모서리에 적용할 때는 그냥 선만갈라지고 깎이지는 않는 경우가 많습니다. 혹시 왜 그런지 알 수 있을까요?
-
미해결Vue.js 끝장내기 - 실무에 필요한 모든 것
createInstance() 함수를 축약하면 안되는 이유
// 액시오스 초기화 함수 function createInstance() { const instance = axios.create({ baseURL: process.env.VUE_APP_API_URL, }); return setInterceptors(instance); } const instance = createInstance();위 함수를// 액시오스 초기화 함수 const instance = () => { const instance = axios.create({ baseURL: process.env.VUE_APP_API_URL, }); return setInterceptors(instance); };이렇게 줄이려고 해봤는데 자꾸 오류가 뜨더라구요..제가 축약문에 대한 이해도가 덜되었는지 ㅠ 왜 안되는걸까요 ??
-
해결됨스프링 MVC 2편 - 백엔드 웹 개발 활용 기술
필터 등록시 @Configuration과 @Bean
안녕하세요. 서블릿 필터 - 요청로그 편을 공부하다가 궁금한 점이 생겼습니다. 처음에 LogFilter를 만들고 이것을 등록하기 위해WebConfig를 만든 후 @Configuration 처리와 FilterRegistrationBean을 반환하는 메서드 logFilter를 @Bean 처리한 후에 여기다가 LogFilter를 등록하는 것까지는 이해했는데 이렇게 등록한 빈을 사용하려면스프링 기본편에서 ApplicationContext를 이용하여 ApplicationContext applicationContext = new AnnotationConfigApplicationContext(WebConfig.class); 이렇게 작성해야 사용할 수 있는 것 같은데 그 작업이없어서 어떻게 사용할 수 있는지 궁금합니다.
-
해결됨[리뉴얼] React로 NodeBird SNS 만들기
front 부분 여러가지 질문
nodebird react에서 front부분까지만 들은 상태입니다.redux 의 실행 흐름이dispatch(액션) -> 미들웨어(redux-saga) -> 리듀서 -> 스토어이러한 방식으로 알고 있는데언뜻 보면 미들웨어가 먼저 실행되니 success or failure가 먼저 실행될것 같은데saga함수에 딜레이를 안주더라도 실행은 request가 무조건 먼저 되는것 같습니다.왜 이렇게 실행이 되는건가요? 미들웨어와 리듀서가 비동기적으로 실행되는건가요?Success or failure가 먼저 실행되는 케이스가 있나요? 각 기능들에 대한 상태관리를 request, success, failure 3가지의 액션타입으로 관리하는 이유가 뭔가요? 공식문서에는 이렇게 나와있긴 한데 https://lunit.gitbook.io/redux-in-korean/advanced/asyncactions" 하나의 액션 타입에 표지를 두고 사용하건, 여러 액션 타입을 사용하건 여러분에게 달렸습니다. 여러분이 팀과 함께 정할 규칙일 뿐입니다. 여러 타입을 쓰면 실수는 줄겠지만, 여러분이 redux-actions와 같은 헬퍼 라이브러리를 써서 액션 생산자와 리듀서를 만든다면 이게 별 문제가 되지 않을 수도 있습니다. " 제로초님 입장에서는 어떻게 생각하시나요? 또 실무에서는 하나의 액션으로 처리하는지 아니면 강좌처럼 세가지의 액션으로 나누어서 처리하는지 궁금합니다. request에 대한 로직을 하나 보면case LOG_IN_REQUEST: draft.loginLoading = true; draft.logInError = null; draft.logInDone = false; // Done을 왜 굳이 초기화 해야하지?logInDone 같은 경우는 request 이전에도 이미 false라고 생각하는데 따로 초기화를 명시해주는 이유가 있나요? 프론트엔드를 구현할때 처음에 데이터 구조 잡을 때 아직 정해진거 없으면 전체 데이터베이스 구조를 제가 정하고 들어가야 하는건가요?전체 테이블 구조를 관계설정까지 다 잡고 들어가야 하는건지, 아니면 내가 구현하는 기능에 대한 테이블 구조만 하나씩 잡고 들어가면 되는건지 궁금합니다. 사실 이 강좌를 듣기 전에는 프론트엔드 부분 데이터를 구현할 때백엔드로 요청을 보내고, 그 응답으로 데이터를 건네받아서, 해당 데이터를 가지고 프론트에 직접 값을 표시하는 방식으로 웹이 돌아가겠지, 라고 생각을 했습니다.(프론트엔드에서 API 요청 -> 백엔드에서 데이터처리, 응답 -> 응답에서 받은 데이터로 뷰 가공 및 출력)그런데 강좌에서는 벡엔드에서의 처리와 별개로, 프론트에서의 데이터는 프론트에서의 로직만으로 처리하도록 구현하셨는데요. 이렇게 하는 이유가 있으신가요? 프론트를 처음 구현할때 처음에 데이터 구조 잡을 때 아직 정해진거 없으면 먼저 전체 데이터베이스 구조를 제가 정하고 들어가야 하는건가요?전체 테이블 구조를 관계설정까지 다 잡고 들어가야 하는건지, 아니면 내가 구현하는 기능에 대한 테이블 구조만 하나씩 잡고 들어가면 되는건지 궁금합니다. redux saga 함수 로직보면 백엔드API요청 후에 put 연산 success or failure 로직으로 나뉘는데원래 try catch 문 안쓰면 axios.post().then(() => put(action)).catch(e => put(action)) 이런식으로 쓰는 로직이랑 같은건가요?
-
미해결크롤링으로 웹, 텔레그램봇, REST API, 모바일 앱 만들기
텔레그램 봇 만들기 파트에서 에러가 발생합니다.
안녕하세요, 강사님.강의 잘 듣고 있습니다:)현재 크롤링 후 텔레그램을 통해 메세지를 보내고, 장고에 연결하는 부분을 학습하고 있습니다.강의 영상에서는 별도의 동기/비동기 처리 없이 진행이 가능했는데그대로 따라하였더니 coroutine 'bot.sendMessage' was never awaited 에러가 발생하여강의에서 작성한 for문을 async def test(): 로 함수로 감싼 뒤 스크립트 하단에asyncio.run(test()) 함수를 실행시키니 에러가 발생하지 않고 텔레그램으로 메세지가 보내지더라구요.그런데, 해당 스크립트를 django에 연결하기 위해선 def run 함수를 통해 진행해야하는데,함수 형태가 조금 변경돼서 그런지 위와 같이 async, asyncio, await 등을 사용해봐도에러가 발생하여 진행이 되지 않고있습니다..어떻게 하면 좋을까요?? 코드 및 에러 첨부드립니다.from asyncore import loop from datetime import time from bs4 import BeautifulSoup import requests import telegram import asyncio from hotdeal.models import Deal async def test(): response = requests.get('https://www.ppomppu.co.kr/zboard/zboard.php?id=ppomppu') soup = BeautifulSoup(response.text, "html.parser") BOT_TOKEN = 'TOKEN' bot = telegram.Bot(token=BOT_TOKEN) for item in soup.find_all("tr", {'class': ["list1", "list0"]}): try: image = item.find("img", class_="thumb_border").get("src")[2:] title = item.find("font", class_="list_title").text.strip() link = item.find("font", class_="list_title").parent.get("href") link = "https://www.ppomppu.co.kr/zboard/" + link reply_count = int(item.find("span", class_="list_comment2").text) up_count = item.find_all("td")[-2].text up_count = up_count.split("-")[0].strip() up_count = int(up_count) if up_count >= 5: if Deal.objects.filter(link__iexact=link).count() == 0: Deal(image_url = image, title = title, link = link, reply_count = reply_count, up_count = up_count).save() await bot.sendMessage(-1001897599228, '{} {}'.format(title, link)) except Exception as e: print(e) def run(): asyncio.run(test())에러 메세지입니다.invalid literal for int() with base 10: '' 'NoneType' object has no attribute 'text' invalid literal for int() with base 10: '' 'NoneType' object has no attribute 'text' invalid literal for int() with base 10: '' 'NoneType' object has no attribute 'text' invalid literal for int() with base 10: '' You cannot call this from an async context - use a thread or sync_to_async. 'NoneType' object has no attribute 'text' invalid literal for int() with base 10: '' 'NoneType' object has no attribute 'text' You cannot call this from an async context - use a thread or sync_to_async. 'NoneType' object has no attribute 'text' You cannot call this from an async context - use a thread or sync_to_async. You cannot call this from an async context - use a thread or sync_to_async. You cannot call this from an async context - use a thread or sync_to_async. You cannot call this from an async context - use a thread or sync_to_async. You cannot call this from an async context - use a thread or sync_to_async. You cannot call this from an async context - use a thread or sync_to_async. 'NoneType' object has no attribute 'text' 'NoneType' object has no attribute 'text' invalid literal for int() with base 10: '' 'NoneType' object has no attribute 'text' invalid literal for int() with base 10: ''