목록IT 인터넷 (520)
반업주부의 일상 배움사
글로벌 이벤트라고 생각하면 편해요. 실제는 그렇지 않겠지만 스토어는 리듀서들을 가진 오브젝트고, 실제 데이터는 리듀서에 들어있다고 생각해보세요. store.reducer.data 파일 하나로 끝낼께요. import React from 'react'; import { Provider, useDispatch, useSelector } from 'react-redux'; import { createStore, combineReducers } from 'redux'; ///////////////////////////////////////// // // Main // ///////////////////////////////////////// function Main() { const dispatch = useDi..
SCSS 같은거라 보면 돼요. 설치할께요. npm install --save styled-components 상속도 되고 구조화도 가능해요. 종합 예제를 만들어봐요. import styled, { css } from 'styled-components'; const BoxParent = styled.div` padding: 50px; `; const Box = styled(BoxParent)` background-color: ${(props) => props.bgColor}; color: red; // &는 this와 같은 의미 & > div { color: blue; ${(props) => props.bgColor === 'grey' && css` color: yellow; `} } `; function..
리액트로 여러개의 페이지를 구축할 수 있어요. 주소창에 /admin, /user 등을 입력하면 서로 다른 페이지를 보여주는거죠. 그걸 라우팅이라고 불러요. 우선 간단하게 해시를 이용할께요. 주소창에 /#a를 입력하면 A 컴포넌트를 보여주고 /#b를 입력하면 B 컴포넌트를 보여주면 될 것 같네요. import { useState } from 'react'; function A() { return A 페이지; } function B() { return B 페이지; } function App() { const [hash, setHash] = useState(document.location.hash); function onHashChanged() { setHash(document.location.hash); }..
React.createElement()를 많이 쓰면 코드 파악이 어려워요. 그래서 HTML과 유사한 방식으로 컴포넌트들을 생성할 수 있도록 JSX가 나왔어요. create-react-app으로 프로젝트를 생성해요. npx create-react-app jsxtest src/App.js를 열어보면 div, img, p, a 등 익숙한 태그들이 보이죠? 컴파일 하면 HTML로 변환되지만 현재 상태는 리액트 컴포넌트에요. class 대신 className을 쓰고 for 대신 htmlFor를 쓰는 등의 차이가 있어요. import logo from './logo.svg'; import './App.css'; function App() { return ( Edit src/App.js and save to relo..
index.html 파일 하나로 끝내보죠. react.js와 react-dom.js만 있으면 돼요. 에 이걸 넣어요. ReactDOM으로 리액트의 루트를 원하는 위치에 끼워넣는다고 생각하면 돼요. 이번엔 클래스 컴포넌트를 만들어 봐요. 이번엔 함수 컴포넌트를 만들어 봐요. 클래스 컴포넌트의 props에 값을 넘겨봐요. 컴포넌트를 재사용할 수 있어요. 함수 컴포넌트의 props에도 값을 넘겨요. 클래스 컴포넌트는 생성주기에 따라 자동으로 호출되는 메소드가 있어요. 태그를 생성할 때 속성값을 넣을 수 있어요. 태그로 해보죠. 한 번 보여주고 끝나는 페이지는 재미없죠? 클래스 컴포넌트에는 state라는 속성과 setState라는 메소드가 있어서 값이 변할 때마다 render가 다시 호출되요. 화면을 다시 그린..
노마드 강의 듣고 기억을 더듬어 코딩했어요. 그래서 코드가 조금 달라요. 일단 고루틴을 안 썼더니 평균 3.5초가 나오네요. package main import ( "fmt" "net/http" "time" ) var urls []string = []string{ "https://yeastudio.kr", "https://google.com", "https://naver.com", "https://yahoo.com", "https://kakao.com", "https://facebook.com", "https://twitter.com", } func main() { tm := time.Now() for _, v := range urls { res, err := checkURL(v) fmt.Println(..
import import math print(math.sqrt(4)) # math로 부터 호출 from ... import * from math import * print(sqrt(4)) # 내부 함수처럼 직접 호출 영어, 중국어 공부중이신가요? 홈스쿨 교재. 한 권으로 가족 모두 할 수 있어요! 한GLO 미네르바에듀 : 네이버쇼핑 스마트스토어 한글로 영어가 된다?! 한글로[한GLO]는 영어 중국어 일어 러시아어 스페인어가 됩니다!! smartstore.naver.com
VSCode에서 Run 했는데 아래와 같은 에러가 나나요? go: go.mod file not found in current directory or any parent directory; see 'go help modules' 터미널에서 아래 코드를 실행하세요. go env -w GO111MODULE=auto 2023.02.05 - [IT 인터넷/Golang] - Go 언어를 ChatGPT에게 배우다 :: Golang Go 언어를 ChatGPT에게 배우다 :: Golang [ 설치 ] MacOS에서 Go (Golang)을 설치하는 방법은 다음과 같습니다. Go의 최신 버전을 다운로드합니다: https://golang.org/dl/ 다운로드한 파일을 압축 해제합니다. 압축 해제한 폴더를 /usr/local..
샘플 데이터는 여기서 구해요. people.sc.fsu.edu/~jburkardt/data/csv/csv.html Pandas를 설치해요. pip install pandas main.py import pandas as pd url = "https://people.sc.fsu.edu/~jburkardt/data/csv/tally_cab.csv" x = pd.read_csv(url) for i, v in enumerate(x): print('header', i, v) for rowIndex, row in enumerate(x.values): for columnIndex, column in enumerate(row): print(rowIndex, columnIndex, column) 결과 ('header', ..
PyMySQL을 설치해요. pip install PyMySQL main.py import sys import logging import pymysql HOST = "수정하세요" PORT = 3306 USERNAME = "수정하세요" PASSWORD = "수정하세요" DATABASE = "수정하세요" def connect(host, port, username, password, database): try: conn = pymysql.connect(host=host, user=username, passwd=password, db=database, port=port, use_unicode=True, charset='utf8') cursor = conn.cursor() return conn, cursor exc..