묻고 답해요
164만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결따라하며 배우는 리액트, 파이어베이스 - 채팅 어플리케이션 만들기[2023.12 리뉴얼]
파이어스토어에서 db 값 가져오기 테스트 중...에러
코드샌드박스에서 작성중인 데이터입니다.https://codesandbox.io/s/upbeat-jasper-gfb978?file=/src/App.js:0-563 import "./styles.css";import { db } from "./firebase";import { doc, onSnapshot } export default function App() { const unsub = onSnapshot(doc(db, "cities", "SF"), (doc) => { let word = "hsdsi"; console.log("Current data: ", doc.data().name); word = doc.data().name; }); //word = unsub.name; return ( <div> <p> {word} </p> </div> ); // Add a new document in collection "cities"} word 변수를 선언해서 return 값으로 word 변수를 받아서 rendering 하려고 합니다. onSnapshot( ) 안에서 let word = "" ;으로 초기 변수 설정을 해주지 않으면, 에러가 계속 뜨더라구요.어쩔수없이 이렇게 선언해서 return 값에서 불러왔는데, 렌더링은 잘되지만, 코드 자체는 에러가 뜹니다.제가 볼때도 const 내부에서 선언하면 호이스팅이 안되기때문에 변수 초기화가 안되서 이렇게 하면 안될것 같지만, 일단 렌더링이 되긴하네요. 근데 코드상에서는 빨간줄이 밑줄 그어지면서잘못 코드한것처럼 에러가 나는것 같습니다.어떻게 해줘야할까요?
-
미해결누구든지 하는 리액트: 초심자를 위한 react 핵심 강좌
firebase에서 db 데이터 값 가져오기 중...
코드샌드박스에서 작성중인 데이터입니다.https://codesandbox.io/s/upbeat-jasper-gfb978?file=/src/App.js:0-563 import "./styles.css";import { db } from "./firebase";import { doc, onSnapshot } export default function App() { const unsub = onSnapshot(doc(db, "cities", "SF"), (doc) => { let word = "hsdsi"; console.log("Current data: ", doc.data().name); word = doc.data().name; }); //word = unsub.name; return ( <div> <p> {word} </p> </div> ); // Add a new document in collection "cities"} word 변수를 선언해서 return 값으로 word 변수를 받아서 rendering 하려고 합니다. onSnapshot( ) 안에서 let word = "" ;으로 초기 변수 설정을 해주지 않으면, 에러가 계속 뜨더라구요.어쩔수없이 이렇게 선언해서 return 값에서 불러왔는데, 렌더링은 잘되지만, 코드 자체는 에러가 뜹니다.제가 볼때도 const 내부에서 선언하면 호이스팅이 안되기때문에 변수 초기화가 안되서 이렇게 하면 안될것 같지만, 일단 렌더링이 되긴하네요. 근데 코드상에서는 빨간줄이 밑줄 그어지면서잘못 코드한것처럼 에러가 나는것 같습니다.어떻게 해줘야할까요?
-
미해결팀 개발을 위한 Git, GitHub 입문
강의자료 부탁드립니다.
tykim91@cowave.kr강의자료 부탁드립니다.
-
미해결운영체제 공룡책 강의
퀴즈 7번의 답에 대한 질문입니다.
Quiz 7의 답안은 4로 표기되어 있습니다.atomic_variable 명령어는 변수에 대한 접근을 제어하는 하드웨어적 명령어교수님이 수업 시간에 설명하신 내용 중 일부를 살펴보면, "An atomic variable can be used to ensure mutual exclusion in situations."라는 내용이 있는데, mutual exclusion에 대해서 설명하실 때,"If process P_i is executing in its critical section, then no other processes can be executing in their critical section."이라고 말씀하셨습니다. 즉, atomic variable은 mutual exclusion을 ensure하기 위해 다른 프로세스(혹은 쓰레드)가 critical-section에 있는 변수에 접근하는 것을 제어(handle)하는 하드웨어적 명령어로 해석할 수 있지 않을까요? 답안에 대한 상세한 해설을 원하는 질문은 아니지만, 저처럼 위 선지를 해석하면 어떻게 되는지 의견 부탁드립니다!
-
해결됨[아파치 카프카 애플리케이션 프로그래밍] 개념부터 컨슈머, 프로듀서, 커넥트, 스트림즈까지!
카프카 커넥터를 두가지 사용하는 이유
안녕하세요 카프카 커넥터를 적용해보려고, 공부중인데, 많은 예시에서 JDBC Connector와 Kafka MySQL Conenctor 두가지를 사용하더라구요 JDBC Connector는 데이터를 관계형 DB와 잘 연동되게 가져오고 넣기위한 소스들을 제공하는 커넥터이고, Kafka MySQL Connector는 카프카와 MySQL DB를 연결하기위한 커넥터이다.라고 제가 이해하고 있는데, 맞는건가요?
-
미해결자바(Java) 알고리즘 문제풀이 입문: 코딩테스트 대비
채점 오류
package main;import java.util.Scanner; class Main{ public String solution(String str) { String answer=""; char [] charArray = str.toCharArray(); for( int i=0 ; i<charArray.length; i ++) { if(Character.isUpperCase(charArray[i])) { answer+=Character.toLowerCase(charArray[i]); }else { answer +=Character.toUpperCase(charArray[i]); } } return answer; } public static void main(String[] args) { Main T = new Main(); Scanner sc = new Scanner(System.in); String str = sc.nextLine(); System.out.print(T.solution(str)); } } 대소문자 바꾸기 부분에서 , 이클립스에서는 잘 돌아가는데 자꾸 런타임 에러가 뜹니다
-
해결됨20년 경력자의 알기쉬운 컴퓨터네트워크
이미 구성된 토폴로지 그려보기
토폴로지 구성을 파악하려면 방법이 있을까요?정말 유익한 강의 감사드립니다.다름이 아니라 처음부터 토폴로지를 구성하는 것이 아닌,이미 구성되어 있는(회사같은) End-Point 단말에서 ping 이나 tracert 같은 혹은 더 유용한 툴을 통해서 어떻게 토폴로지가 구성되어 있는지 파악하는건 가능할까요?강의를 보고 ping 이나 tracert 를 해봐도 대부분 제대로 된 응답을 안주는 경우가 많아서 어떻게 구성되어 있는지 보이지가 않습니다.도움말씀 부탁드립니다.
-
미해결10주완성 C++ 코딩테스트 | 알고리즘 코딩테스트
안녕하세요! 재귀함수에 관해서 질문드립니다
교안 p.118에 있는 재귀함수 예제문제에서 for(int i = depth; i < n; i++){ swap(v[i], v[depth]); //첫번째 swap(v[i], v[depth]); makePermutation(n, r, depth + 1); swap(v[i], v[depth]); //두번째 swap(v[i], v[depth]); } return;이렇게 예제가 나와있습니다.제가 이해한 바로는,함수 makePermutation에 (3, 3, 0)을 대입하면 i와 depth는 0으로 첫번째 swap(v[i], v[depth]); 은 swap(0,0)이 되고for문 안에 있는 makePermutation에 의해 매개변수 (3, 3, 0)이 (3, 3, 1)로 변하게되어 (3, 3, 1)에 해당하는 함수 makePermutation을 실행하게 되어 다시 첫번째 swap(v[i], v[depth]);이 실행되는 방식인 것으로 이해를 하였습니다.여기서 첫번째 swap(v[i], v[depth]); 의 역할은 이해가 가지만 두번째 swap(v[i], v[depth]); 의 역할은 이해가 가지 않아서 질문 드렸습니다. 감사합니다!
-
미해결설계독학맛비's 실전 FPGA를 이용한 HW 가속기 설계 (LED 제어부터 Fully Connected Layer 가속기 설계까지)
8장 vitis에 대하여
맛비님 안녕하세요, vitis 관련 궁금사항이 생겨 글 남깁니다. 헤더파일을 확인해 보던 중 sleep함수의 헤더파일이 zynq_fsbl_bsp 안에 include 되어있는것을 확인했습니다.저희가 ip를 만들고 HW export를 진행한 것을 vitis에 올리는 것으로 알고있는데, 그러면 zynq 내부에 sleep 함수에 관한 내용을 포함하고 있다 라고 생각하면 되는지 궁금합니다.
-
미해결AWS Certified Solutions Architect - Associate 자격증 준비하기
실전 문제 풀이 해설 파일 문의
안녕하세요.덕분에 강의 잘 듣고 있습니다. 다름이 아니라 실전문제 pdf외로 각 보기 별 해설이 작성된 파일도 내려받을 수 있을까요?실전문제풀이 강의를 보면 각 보기 별로 틀린 이유에 대해서 작성해 주시는데요. 이 부분도 반영된 파일을 받을 수 있는 지 문의 드립니다. 감사합니다.
-
미해결스프링 부트 - 핵심 원리와 활용
강의 PPT 자료 관련 문의
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? 예2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? 예3. 질문 잘하기 메뉴얼을 읽어보셨나요? 예[질문 내용]안녕하세요! 강의 잘 듣고 있습니다.다름이 아니라 올려주신 수업 자료에는 '스프링 부트 소개' 파트에서 사용하신 PPT 자료가 업로드 되어 있지 않습니다.복습을 위해 해당 자료가 있으면 좋을듯 한데, 추후 따로 업로드 해주실 수 있는지 궁금합니다.감사합니다!
-
미해결
아나콘다 커널연결시 에러
pip로 ipykernel 설치했고,커널 연결하려고 하니까 이런 에러가 뜨고 있습니다 커널 list 에도 "yuseong" 이 아예 뜨지 않는데뭐가 문제일까요?
-
해결됨스프링 시큐리티 OAuth2
Ajax 인증시 인가코드가 발급 되지 않는 원인 문의
Spring Authorization 1.0,1 기반으로 개발을 하고 있습니다. 인가코드를 발급 할떄 FormLogin 기본 설정을 사용하면 인가코드가 발급이 되는데 Ajax 로 로그인을 하면 인가코드가 발급되지 않고 있습니다. 디버깅을 해보면 로그인인 후 OAuth2AuthorizationEndpointFilter 는 실행되는데 @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { if (!this.authorizationEndpointMatcher.matches(request)) { filterChain.doFilter(request, response); return; } try { Authentication authentication = this.authenticationConverter.convert(request); if (authentication instanceof AbstractAuthenticationToken) { ((AbstractAuthenticationToken) authentication) .setDetails(this.authenticationDetailsSource.buildDetails(request)); } Authentication authenticationResult = this.authenticationManager.authenticate(authentication); if (!authenticationResult.isAuthenticated()) { // If the Principal (Resource Owner) is not authenticated then // pass through the chain with the expectation that the authentication process // will commence via AuthenticationEntryPoint filterChain.doFilter(request, response); return; } if (authenticationResult instanceof OAuth2AuthorizationConsentAuthenticationToken) { if (this.logger.isTraceEnabled()) { this.logger.trace("Authorization consent is required"); } sendAuthorizationConsent(request, response, (OAuth2AuthorizationCodeRequestAuthenticationToken) authentication, (OAuth2AuthorizationConsentAuthenticationToken) authenticationResult); return; } this.authenticationSuccessHandler.onAuthenticationSuccess( request, response, authenticationResult); } catch (OAuth2AuthenticationException ex) { if (this.logger.isTraceEnabled()) { this.logger.trace(LogMessage.format("Authorization request failed: %s", ex.getError()), ex); } this.authenticationFailureHandler.onAuthenticationFailure(request, response, ex); } } FormLogin 적용시에는 authenticationResult의 principal 에 UsernamePasswordAuthenticationToken이 설정되어 인가 코드가 정상적으로 발급되는데 AjaxLogin 적용시에는 authenticationResult의 principal 에 AnonymousAuthenticationToken이 설정되어 인가 코드가 정상적으로 발급되지 않고 403 예외가 발생합니다.AuthenticationProvider 구현체에서는 정상적으로 토큰을 저장하고 있습니다. AuthenticationProvider 구현체 소스@Component @RequiredArgsConstructor public class CustomAuthenticationProvider implements AuthenticationProvider { private final CustomUserDetailsService customUserDetailsService; private final PasswordEncoder passwordEncoder; @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { if(authentication == null){ throw new InternalAuthenticationServiceException("Authentication is null"); } LoginRequestDto loginRequestDto = (LoginRequestDto)authentication.getPrincipal(); String password = loginRequestDto.getLoginPassword(); UserAdapter userAdapter = (UserAdapter) customUserDetailsService.loadUserByLoinRequestDto(loginRequestDto); if (!passwordEncoder.matches(password, userAdapter.getCurrentUser().getLoginPwd())) { throw new BadCredentialsException("BadCredentialsException"); } CustomAuthenticationToken result = CustomAuthenticationToken.authenticated(userAdapter.getCurrentUser(), authentication.getCredentials(), userAdapter.getAuthorities()); result.setDetails(authentication.getDetails()); return result; } @Override public boolean supports(Class<?> authentication) { return CustomAuthenticationToken.class.isAssignableFrom(authentication); } } 이외 Custom 소스Spring Security 설정@EnableWebSecurity @RequiredArgsConstructor @Configuration public class DefaultSecurityConfig { private final CustomAuthenticationProvider customAuthenticationProvider; // private final CustomUserDetailsService customUserDetailsService; @Bean public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception { return authenticationConfiguration.getAuthenticationManager(); } @Bean public CustomAuthenticationProcessingFilter customAuthenticationProcessingFilter() throws Exception { CustomAuthenticationProcessingFilter filter = new CustomAuthenticationProcessingFilter(); // filter.setAuthenticationManager(authenticationManager(null)); filter.setAuthenticationManager(new ProviderManager(customAuthenticationProvider)); // filter.setAuthenticationSuccessHandler(customAuthenticationSuccessHandler()); // filter.setAuthenticationFailureHandler(customAuthenticationFailureHandler()); return filter; } // @formatter:off @Bean SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception { http .authorizeHttpRequests(authorizeRequests ->authorizeRequests .requestMatchers(CorsUtils::isPreFlightRequest).permitAll() .requestMatchers(new AntPathRequestMatcher("/")).permitAll() .requestMatchers(new AntPathRequestMatcher("/login/**")).permitAll() .requestMatchers("/api/login/**").permitAll() .requestMatchers("/api/registered-client/**").permitAll() .anyRequest().authenticated() ); http.addFilterBefore(customAuthenticationProcessingFilter(), UsernamePasswordAuthenticationFilter.class); http.exceptionHandling(httpSecurityExceptionHandlingConfigurer -> httpSecurityExceptionHandlingConfigurer .authenticationEntryPoint(new CustomLoginAuthenticationEntryPoint()) .accessDeniedHandler(customAccessDeniedHandler()) ); // http.userDetailsService(customUserDetailsService); // http.formLogin(); http.csrf().disable(); return http.build(); } // @formatter:on @Bean public AccessDeniedHandler customAccessDeniedHandler() { return new CustomAccessDeniedHandler(); } @Bean public AuthenticationSuccessHandler customAuthenticationSuccessHandler() { return new CustomAuthenticationSuccessHandler(); } @Bean public AuthenticationFailureHandler customAuthenticationFailureHandler() { return new CustomAuthenticationFailureHandler(); } } Ajax 로그인 처리 필터 소스public class CustomAuthenticationProcessingFilter extends AbstractAuthenticationProcessingFilter { private final ObjectMapper objectMapper = new ObjectMapper(); private static final AntPathRequestMatcher DEFAULT_ANT_PATH_REQUEST_MATCHER = new AntPathRequestMatcher("/api/login", HttpMethod.POST.name()); public CustomAuthenticationProcessingFilter() { super(DEFAULT_ANT_PATH_REQUEST_MATCHER); } public CustomAuthenticationProcessingFilter(AuthenticationManager authenticationManager) { super(DEFAULT_ANT_PATH_REQUEST_MATCHER, authenticationManager); } @Override public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException { if (!request.getMethod().equals("POST")) { throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod()); } LoginRequestDto loginRequestDto = objectMapper.readValue(request.getReader(), LoginRequestDto.class); if(StringUtils.isEmpty(loginRequestDto.getLoginId())||StringUtils.isEmpty(loginRequestDto.getLoginPassword())) { throw new IllegalStateException("Username or Password is empty"); } CustomAuthenticationToken authRequest = CustomAuthenticationToken.unauthenticated(loginRequestDto, loginRequestDto.getLoginPassword()); authRequest.setDetails(this.authenticationDetailsSource.buildDetails(request)); return getAuthenticationManager().authenticate(authRequest); } } CustomAuthenticationToken 소스public class CustomAuthenticationToken extends AbstractAuthenticationToken { private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID; private final Object principal; private Object credentials; public CustomAuthenticationToken(Object principal, Object credentials) { super(null); this.principal = principal; this.credentials = credentials; setAuthenticated(false); } public CustomAuthenticationToken(Object principal, Object credentials, Collection<? extends GrantedAuthority> authorities) { super(authorities); this.principal = principal; this.credentials = credentials; super.setAuthenticated(true); // must use super, as we override } public static CustomAuthenticationToken unauthenticated(Object principal, Object credentials) { return new CustomAuthenticationToken(principal, credentials); } public static CustomAuthenticationToken authenticated(Object principal, Object credentials, Collection<? extends GrantedAuthority> authorities) { return new CustomAuthenticationToken(principal, credentials, authorities); } @Override public Object getCredentials() { return this.credentials; } @Override public Object getPrincipal() { return this.principal; } }
-
해결됨it 취업을 위한 알고리즘 문제풀이 입문 (with C/C++) : 코딩테스트 대비
테스트 케이스 질문
#include <iostream> #include <vector> using namespace std; int main() { freopen("input.txt", "rt", stdin); int s, n, i, j, tmp, idx; scanf("%d%d", &s, &n); vector<int> a(n); for (i = 0; i < n; i++) { scanf("%d", &tmp); if(i < s) a[s-1-i] = tmp; else { idx = s; for (j = 0; j < s; j++) { if(a[j] == tmp) { idx = j; break; } } for (j = idx - 1; j >= 0; j--) a[j+1] = a[j]; a[j+1] = tmp; } } for (i = 0; i < s; i++) printf("%d ", a[i]); return 0; }이렇게 작성했는데 채점 폴더 전부 통과하는데 만약 입력이 5 51 2 2 3 4 이 들어왔다면 출력이4 3 2 2 1로 출력 되니까 위의 코드는 틀린 코드 같은데 맞나요???
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
numpy.random.default_rng/hyperopt버젼
안녕하세요, 권철민 강사님!강의 잘 듣고있습니다~1.4.9_ 분류실습_산탄데르_고객만족예측 실습 중에numpy.random.default_rng()를 사용하셨는데 default_rng() 를 사용하신 이유가 있으실까요? 이건 어떤때 쓰는게 좋은건가요? 2.저는 코랩을 쓰고 있는데, hyperopt는 실행이 안됩니다. 이전에 답변을 보니 넘파이와 hyperopt의 버젼 문제일거라고 하셨는데, 코랩에서 버젼을 바꾸어야 할까요? 현재 버젼은 다음과 같습니다.hyperopt(0.2), np(1.22.4)감사합니다!
-
미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
한줄 if 쓸 때 return의 필요성
한줄로 if문을 쓰실 때 return을 붙이시는 이유가 있나요??제가 감히 생각해보면 return을 붙일 필요가 없는 것 같은데코드를 좀 더 명확하게 하시려고 붙이시는 건가요??
-
해결됨스프링 프레임워크는 내 손에 [스프1탄]
23.Spring MVC02 버전 만들기(Ajax, jQuery)
SPringMVC01 폴더를 복사 후, SpringMVC02 폴더로 변경해서 강의 순서대로 실행을 했는데, Mapping 경로를 찾지 못하는 오류가 발생했습니다. 그래서 해결 방법으로 [appServlet] - [servlet-context.xml] 파일 안에 19번째 줄 기존의 파일 내용 일부분을 수정했습니다. 이렇게 해도 괜찮을까요 ? 다른 방법이 있으면 알고 싶어요 ㅠ[servlet-context.xml] - 수정 전 <resources mapping="/resources/**" location="/resources/" /> [servlet-context.xml] - 수정 <resources mapping="/assets/**" location="/resources/assets/" /> <resources mapping="/ad_assets/**" location="/resources/ad_assets/" /> a
-
해결됨한 입 크기로 잘라 먹는 리액트(React.js) : 기초부터 실전까지
시간 오류 - getTime()
안녕하세요. 한국에선 문제 없던 앱이. 미국에서 동작할경우 등록한 날짜보다 하루 전의 날짜로 저장되는문제를 겪었습니다.찾아보니 getTime()도 toISOString 와 마찬가지로 UTC 0+ 시간으로 작동되는 부분이 문제였습니다. 스토리지에 저장되는 타임스탬프가 UTC 기반이였던거죠. 달력에서 날짜를 설정할때 시간은 반영되지않고 12am 즉 00시로 설정되는데, 한국은 UTC +9 이라 날짜에 영향을 주지 않았지만, 제가 있는 지역의 타임존은 UTC -5이기에 하루전날의 타임스탬프가 저장되고 다시 그 타임스탬을 이용해 new Date(date)을 해줄때 전날의 날짜가 불러진다고 결론내렸습니다.이문제를 해결하기위해, 스트로지에 타임스탬프가아닌 getStringDate 으로 뽑아낸 스트링 날짜를 넣어주었고. 다이어리 리스트에서 sort 를 위한 비교를할때만 getTime()을 써주었습니다. 전문가의 의견을 듣고싶습니다.
-
미해결Vue.js 중급 강좌 - 웹앱 제작으로 배워보는 Vue.js, ES6, Vuex
github 권한 요청 드립니다
인프런 아이디 : devdh.cho@samsung.com인프런 이메일 : devdh.cho@samsung.com깃헙 아이디 : rhsnfl1122깃헙 Username : JoDongHyuen
-
해결됨외워서 끝내는 네트워크 핵심이론 - 기초
TCP 연결 종료 과정 중 Time wait관련
서버로부터 FIN + ACK을 수신 후, 최종 ACK를 서버로 다시 전달한 다음, TIME_WAIT 상태로 넘어가고, 일정 시간이 지난 다음 Close 처리가 된다는 설명에서,TIME_WAIT 시간은 정해진 값이 있는 것인지? 아니면 소켓 프로그래밍 시 따로 정해주는 것인지?바로 CLOSED하지 않고, TIME_WAIT을 하는 이유(목적)는 무엇인지?질문의 드립니다. :) 널널한개발자님 답변 부탁 드립니다!!