묻고 답해요
164만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결프로그래밍, 데이터 과학을 위한 파이썬 입문
과제 확인 부탁드립니다.
dic은 처음에 주어진다고 가정을 하고 작성을 해 보았습니다. def value_key_back(i): user_dic = {"America": 1, "Korea": 82, "China": 86, "Japan": 81} user_key_list = list(user_dic.keys()) user_value_list = list(user_dic.values()) key_index_num = user_value_list.index(i) result = user_key_list[key_index_num] return result print('user_dic = {"America": 1, "Korea": 82, "China": 86, "Japan": 81}') dic_value = int(input("Input any value: ")) print("The Key is {0}". format(value_key_back(dic_value)))
-
미해결[C#과 유니티로 만드는 MMORPG 게임 개발 시리즈] Part4: 게임 서버
Connect를 이용하여 여러소켓 생성후 문제점
안녕하세요 루키스님 정말 강의 도움 많이 받고 있어요 !!소켓을 10번 생성과함께 커넥트를 요청하는 부분에0.1초 딜레이를 주면 (*대부분*) 잘작동하더라구요 하지만, 저 딜레이를 빼면 아래 그림과같은 에러가 나와요! 저는 이것을 비동기에서 발생하는 문제점이라고 생각했습니다. 그래서 Receive에 _lock을 걸어서 실험도해봤지만여전히 같은 오류를 내고 있더라구요 혹시 이런 에러가 발생하는 부분의 가능성이나해결방법이 어떤게 있을까요? 딜레이를 주는경우대부분 잘되는것은 비동기 문제가 맞는걸까요?
-
미해결홍정모의 따라하며 배우는 C++
멀티쓰레딩 예제 실행시간 재질문
말씀하신 코드는 다음과 같습니다 #include<iostream> #include<chrono> #include<mutex> #include<random> #include<thread> #include<utility> #include<vector> #include<atomic> #include<future> #include<numeric> //std::inner_product #include<execution> // parallel_execution using namespace std; mutex mtx; void dotProducNaive(const vector<int>& v0, const vector<int>& v1, const unsigned i_start, const unsigned i_end, unsigned long long& sum) { for (unsigned i = i_start; i < i_end ; i++) { sum += (v0[i] * v1[i]); //내적 구현 한 것 } } void dotProductLock(const vector<int>& v0, const vector<int>& v1, const unsigned i_start, const unsigned i_end, unsigned long long& sum) { //cout<<"Thread start"<<endl; for (unsigned i = i_start; i < i_end; i++) { std::scoped_lock lock(mtx); //c++17 sum += v0[i] * v1[i]; } } void dotProducAtomic(const vector<int>& v0, const vector<int>& v1, const unsigned i_start, const unsigned i_end, atomic<unsigned long long>& sum) { for (unsigned i = i_start; i < i_end ; i++) { sum += (v0[i] * v1[i]); //내적 구현 한 것 } } int main() { const long long n_data = 100'000'000; const unsigned n_threads = 8; //initialize vectors std::vector<int> v0, v1; v0.reserve(n_data); v1.reserve(n_data); random_device seed; mt19937 engine(seed()); uniform_int_distribution <> uniformDist(1, 10); for (long long i = 0; i < n_data; i++) { v0.push_back(uniformDist(engine)); v1.push_back(uniformDist(engine)); } cout << "std::inner_product" << endl; { const auto sta = chrono::steady_clock::now(); //시간 재는중 const auto sum = std::inner_product(v0.begin(), v0.end(), v1.begin(), 0ull); const chrono::duration<double> dur = chrono::steady_clock::now() - sta; //시간 재는 중 //계산한 시간 출력 cout << dur.count() << endl; cout << sum << endl; cout << endl; } cout << "Native" << endl; { const auto sta = chrono::steady_clock::now(); unsigned long long sum = 0; vector<thread> threads; threads.resize(n_threads); //쓰레드 마다 맡길 일의 양을 결정 const unsigned n_per_thread = n_data / n_threads; //assumes remainder=0 //쓰레드 할당 중 + 쓰레드에 값을 넣어주는 중 for (unsigned t = 0; t < n_threads; t++) { threads[t] = std::thread(dotProducNaive,std::ref(v0),std::ref(v1), t* n_per_thread, (t + 1)* n_per_thread, std::ref(sum)); } //join으로 기다리는 코드 for (unsigned t = 0; t < n_threads; t++) { threads[t].join(); } const chrono::duration<double> dur = chrono::steady_clock::now() - sta; cout << dur.count() << endl; cout << sum << endl; cout << endl; } cout << "Lock guard" << endl; { const auto sta = chrono::steady_clock::now(); unsigned long long sum = 0; vector<thread> threads; threads.resize(n_threads); //쓰레드 마다 맡길 일의 양을 결정 const unsigned n_per_thread = n_data / n_threads; //assumes remainder=0 //쓰레드 할당 중 + 쓰레드에 값을 넣어주는 중 for (unsigned t = 0; t < n_threads; t++) { threads[t] = std::thread(dotProductLock, std::ref(v0), std::ref(v1), t * n_per_thread, (t + 1) * n_per_thread, std::ref(sum)); } //join으로 기다리는 코드 for (unsigned t = 0; t < n_threads; t++) { threads[t].join(); } const chrono::duration<double> dur = chrono::steady_clock::now() - sta; cout << dur.count() << endl; cout << sum << endl; cout << endl; } cout << "atomic" << endl; { const auto sta = chrono::steady_clock::now(); atomic<unsigned long long> sum = 0; vector<thread> threads; threads.resize(n_threads); //쓰레드 마다 맡길 일의 양을 결정 const unsigned n_per_thread = n_data / n_threads; //assumes remainder=0 //쓰레드 할당 중 + 쓰레드에 값을 넣어주는 중 for (unsigned t = 0; t < n_threads; t++) { threads[t] = std::thread(dotProducAtomic, std::ref(v0), std::ref(v1), t * n_per_thread, (t + 1) * n_per_thread, std::ref(sum)); } //join으로 기다리는 코드 for (unsigned t = 0; t < n_threads; t++) { threads[t].join(); } const chrono::duration<double> dur = chrono::steady_clock::now() - sta; cout << dur.count() << endl; cout << sum << endl; cout << endl; } return 0; }
-
미해결[리뉴얼] React로 NodeBird SNS 만들기
ssr 관련 질문
styled-component들은 서버사이드렌더링이 안되서 적용이 안된다고 하셨는데 현재 이 강의 기준으로 서버사이드 렌더링이 적용되고 있는건가요? pages폴더안에 파일들만 코드스플릿팅만 적용되고 있는줄알았습니다. 자동으로 서버사이드렌더링이 적용중인건지 궁금합니다.
-
미해결홍정모의 따라하며 배우는 C++
레이스 컨디션 재질문
#include<iostream> #include<thread> #include<atomic> #include<mutex> #include<chrono> using namespace std; int main() { mutex mtx; int shared_momory(0); auto count_func = [&]() { for (int i = 0; i < 1000; i++) { //this_thread::sleep_for(chrono::milliseconds(1)); //std::scoped_lock lock(mtx); shared_momory++; } }; thread t1 = thread(count_func); thread t2 = thread(count_func); t1.join(); t2.join(); cout << "After" << endl; cout << shared_momory << endl; return 0; } 코드는 이렇습니다.
-
미해결프로그래밍 시작하기 : 파이썬 입문 (Inflearn Original)
예제문제
예제문제는 어디있는건가요... 교재 파일인 PDF 는 강의 초반 주제부분만 나오는 2장이고 소스파일을 열어도 나오지 않네요..
-
미해결따라하며 배우는 도커와 CI환경 [2023.11 업데이트]
강의 관련 정리.
안녕하세요. 강의를 잘보고 있는 학생입니다. 도커에 대한 내용을 잊지 않기 위해 기록을 남기려고 합니다. 강의와 같이 도표형식을 사용하여 비슷하게 블로그에 남겨도 될까요?
-
미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
unresolved methods
안녕하세요 user.js에서 userSchema.pre userScema.methods var token = jwt.sign(user._id.toHexString(), secretToken) 에서 pre, methods, toHexString() 세 부분에 밑줄이 뜨며 unresolved methods or functions 등 unresolved 라는 에러가 뜹니다. 작동에는 오류가 없지만 왜 뜨는건지 궁금해서 질문드립니다. 웹스톰 사용하고 있고, 위의 사진과 같습니다. 감사합니다!! //user.js const mongoose = require('mongoose'); const bcrypt = require('bcrypt'); const saltRounds = 10; const jwt = require('jsonwebtoken'); const userSchema = new mongoose.Schema({ name: { type: String, maxlength: 50 }, email: { type: String, trim: true, //공백을 제거 unique: 1 //이메일은 하나. 유니크 했으면 좋겠음. }, password: { type: String, minlength:5 }, lastname: { type: String, maxlength: 50 }, role: { type: Number, default: 0 }, image: String, //오브젝트를 사용하지 않고 이렇게 하나로 줘도 된다. token: { type: String //유효성 검사를 위해 }, tokenExp: { type: Number //유효기간. } }) userSchema.pre('save', function(next){ //비밀번호를 암호화 시킨다 //index.js 의 save를 하기 전에, function을 하면서 암호화 시킨다. //이때 salt를 이용해서 비밀번호를 암호화한다. 그 전에 salt를 먼저 생성해야함. //saltround는 salt가 몇글자인지임 //genSalt: salt를 만든다. var user = this; //this는 이때 위의 user 객체를 가리킨다. if(user.isModified('password')){ bcrypt.genSalt(saltRounds, function(err, salt){ if (err) return next(err); bcrypt.hash(user.password, salt, function (err, hash){ //user.password : this, 즉 객체의 password. 암호화 되기 전의 패스워드 //hash : 암호화된 비밀번호 //store hash in your password DB if (err) return next(err) user.password = hash }) }) } else{ next() } next() }) userSchema.methods.comparePassword = function(plainPassword, cb) { //plainpassword와 암호화된 비밀번호가 같은지 확인하기 -> plainpassword를 암호화 해서 암호화한 password와 같은지 확인하기. bcrypt.compare(plainPassword, this.password, function(err, isMatch){ if(err) return cb(err), cb(null, isMatch) }) } userSchema.methods.generateToken = function(cb){ var user = this; //jsonwebtoken을 이용해서 token을 생성하기 var token = jwt.sign(user._id.toHexString(), 'secretToken') user.token = token user.save(function(err, user){ if(err) return cb(err) cb(null, user) }) } const User = mongoose.model('User', userSchema) //스키마를 모델로 감싸준다 module.exports = { User } //다른 파일에서도 쓸 수 있도록 export
-
미해결데이터 자동화(with VBA)
혹시
교집합 범위내의 타겟에 문자를 입력 하면 타겟 왼쪽에 현재 시간을 넣겟다고 구문을 만드는데요 중간에 if VBA.Len(targer) > 1 then target.offset( , 1) = 현재시간 이렇게 응용해보려는데 안되네요..
-
미해결[텐서플로2] 파이썬 딥러닝 완전정복 - GAN, BERT, RNN, CNN 최신기법
코드를 그대로 돌렸는데 애로가 나오는 이유가 알고 싶습니다
안녕하십니까 선생님 코드를 그대로 붙여서 실행했는데 다음과 같은 애로 사항이 발생했습니다 tensorflow도 2.3이고 keras도 설치 되어있는데 어떤 제반 사항이 잘못되었는지 알려주시면 감사드리겠습니다. ImportError Traceback (most recent call last) ~\anaconda3\lib\site-packages\keras\__init__.py in <module> 2 try: ----> 3 from tensorflow.keras.layers.experimental.preprocessing import RandomRotation 4 except ImportError: ~\anaconda3\lib\site-packages\tensorflow\__init__.py in <module> 40 ---> 41 from tensorflow.python.tools import module_util as _module_util 42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader ~\anaconda3\lib\site-packages\tensorflow\python\__init__.py in <module> 45 from tensorflow.python import data ---> 46 from tensorflow.python import distribute 47 from tensorflow.python import keras ~\anaconda3\lib\site-packages\tensorflow\python\distribute\__init__.py in <module> 27 from tensorflow.python.distribute import one_device_strategy ---> 28 from tensorflow.python.distribute.experimental import collective_all_reduce_strategy 29 from tensorflow.python.distribute.experimental import parameter_server_strategy ~\anaconda3\lib\site-packages\tensorflow\python\distribute\experimental\__init__.py in <module> 24 from tensorflow.python.distribute import parameter_server_strategy ---> 25 from tensorflow.python.distribute import tpu_strategy 26 # pylint: enable=unused-import ~\anaconda3\lib\site-packages\tensorflow\python\distribute\tpu_strategy.py in <module> 42 from tensorflow.python.tpu import device_assignment as device_assignment_lib ---> 43 from tensorflow.python.tpu import tpu 44 from tensorflow.python.tpu import tpu_strategy_util ~\anaconda3\lib\site-packages\tensorflow\python\tpu\tpu.py in <module> 27 from tensorflow.python.compat import compat as api_compat ---> 28 from tensorflow.python.compiler.xla import xla 29 from tensorflow.python.framework import device as pydev ~\anaconda3\lib\site-packages\tensorflow\python\compiler\xla\__init__.py in <module> 22 from tensorflow.python.compiler.xla import jit ---> 23 from tensorflow.python.compiler.xla import xla 24 # pylint: enable=unused-import ~\anaconda3\lib\site-packages\tensorflow\python\compiler\xla\xla.py in <module> 24 ---> 25 from tensorflow.compiler.jit.ops import xla_ops 26 from tensorflow.compiler.jit.ops import xla_ops_grad # pylint: disable=unused-import ~\anaconda3\lib\site-packages\tensorflow\compiler\jit\ops\xla_ops.py in <module> 7 ----> 8 from tensorflow.python import pywrap_tfe as pywrap_tfe 9 from tensorflow.python.eager import context as _context ~\anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py in <module> 28 from tensorflow.python import pywrap_tensorflow ---> 29 from tensorflow.python._pywrap_tfe import * ImportError: DLL load failed: 지정된 프로시저를 찾을 수 없습니다. During handling of the above exception, another exception occurred: ImportError Traceback (most recent call last) <ipython-input-1-210029f2541c> in <module> 1 from __future__ import print_function ----> 2 import keras 3 from keras.datasets import mnist 4 from keras.models import Sequential 5 from keras.layers import Dense, Dropout, Flatten ~\anaconda3\lib\site-packages\keras\__init__.py in <module> 4 except ImportError: 5 raise ImportError( ----> 6 'Keras requires TensorFlow 2.2 or higher. ' 7 'Install TensorFlow via `pip install tensorflow`') 8 ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow`
-
해결됨[리뉴얼] React로 NodeBird SNS 만들기
401에러 관련 질문드립니다
401 에러가 발생하여 문제 찾아보던 중에 서버사이드렌더링 방식으로 axios 통신을 했을때 headers에 쿠키를 담아줘서 그런지 백서버 미들웨어에서 isLoggedIn에 로그인 정보가 잘 넘어오는 것을 확인하였습니다. 하지만 브라우저에서 백서버로 요청을 할때는 isLoggedIn에 로그인 정보가 넘어오지 않았는 것 같아 문의 드립니다. req.isAuthenticated()가 false 여서 401에러가 뜨는 장면입니다.
-
미해결페이스북 클론 - full stack 웹 개발
ajax 통신이 안 되는 것 같습니다!
저는 지금 구름IDE 에서 컨테이너를 만들어서 공부하고 있는데요! 좋아요 버튼을 눌러도 ajax 통신이 잘 안 되는 것 같습니다! 첫번째 사진은 여기 사이트에서 올려진 선생님의 소스 코드를 실행해봤을 때의 사진이고 두번째 사진은 제가 직접 작성해서 시도해봤을 때의 사진입니다! 어떻게 문제를 해결해야 하나요? 이러한 경우가 로컬서버를 설치하지 않아서 ajax 통신을 못하는 경우라면 웹스톰을 사용하지 않고 로컬서버를 설치를 하는 방법이 있을까요?
-
미해결스프링과 JPA 기반 웹 애플리케이션 개발
Edit Configuration에서 질문이 있습니다.
안녕하세요 백기선님 강의를 들으면서 따라하는 도중 오류가 발생하여 질문드립니다. maven을 compile 한 후에 Edit Configuration을 클릭하면 이렇게 SpringBoot가 나오지 않고 unknown으로 나오게 됩니다. 혹시 인텔리제이 커뮤니티 버전에선 지원을 하지 않는 기능인가요?? 아래는 강좌에서 나오는 화면입니다.
-
미해결파이썬 알고리즘 문제풀이 입문(코딩테스트 대비)
저장공간을 n+3을 한 이유가 무엇인가요?
res = [0] * (n + 3)위의 코드(n+3) 대신 n만 넣어줘도 문제가 없는거 같은데혹시 이유가 무엇인가요?
-
해결됨웹 게임을 만들며 배우는 React
$문법 질문
' 답은 ${this.state.answer}' 이런식으로 적으니 '...'안에 적은 문구가 그대로 출력이되서 ' 답은 ' + this.state.answer 이런식으로 작성하니 프로그램이 돌아가네요. $문법이 jquery 를 사용한건가요?
-
미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
강의 정말 감사합니다! 질문하나만 부탁드리겠습니다
const express = require("express"); const app = express(); const port = 5003; const bodyParser = require("body-parser"); const { User } = require("./models/User"); //applicatioin /x-www-form -url encoded app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); const mongoose = require("mongoose"); mongoose.connect( "mongodb+srv://euan:abcd1234@boilerplate.tywi2.mongodb.net/<dbname>?retryWrites=true&w=majority", { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: false, } ); app.get("/", (req, res) => { res.send("Hello World!"); }); app.post("/register", (req, res) => { const user = new User(req.body); user.save((err, userInfo) => { if (err) return res.josn({ success: false, err }); return res.status(200).json({ success: ture, }); }); }); app.listen(port, () => { console.log(`Example app listening at http://localhost:${port}`); });
-
미해결취미로 해킹#5(DIMICTF)
이문제는 이렇게푸는게나을것같습니다(5초내로풀림)
#include <stdio.h> #include <stdlib.h> #include <Windows.h> #pragma warning(disable:4996) #pragma section("flag_data", read) __declspec(allocate("flag_data")) char table[45] = { 102, 124, 124, 107, 78, 117, 17, 87, 100, 69, 114, 2, 80, 106, 65, 80, 6, 66, 103, 91, 6, 125, 4, 66, 125, 99, 2, 112, 76, 110, 103, 1, 98, 91, 106, 6, 18, 106, 115, 91, 69, 5, 113, 0, 76 }; char flags[45]; void genFlag(int key1, int key2, int key3) { for(int i = 0; i<45; i++) { if (i % 3 == 0) flags[i] = table[i] ^ key1; else if (i % 3 == 1) flags[i] = table[i] ^ key2; else if (i % 3 == 2) { flags[i] = table[i] ^ key3; } } } int main() { int key1; int key2; for(int i = 0; i<255;i++) { for(int j = 0; j<255;j++) { key1 = i; key2 = j; key1 ^= key2 ^= key1 ^= key2; int key3 = (key1-3) ^ (key2+3); key3 += 10; key3 &= 0xff; genFlag(key1,key2,key3); if(flags[0] == (int)'D' && flags[1] == (int)'I' && flags[2] == (int)'M') { printf("Flag : %s\n", flags); } } } getchar(); }
-
미해결React로 NodeBird SNS 만들기
혹시 디비 테이블을 그린다면 이게 맞는걸까요?
그리고 workbench 에 테이블이 5개생기는데 나머지 테이블은 뷰같은 개념인건가요? ㅜ 시퀄라이즈 헷갈리네요..
-
미해결Vue.js 완벽 가이드 - 실습과 리팩토링으로 배우는 실전 개념
<p> 태그 : The template root disallows 'v-for' directives오류
삭제된 글입니다
-
미해결우리를 위한 프로그래밍 : 파이썬 중급 (Inflearn Original)
함수 객체 질문
함수인데 객체 취급을 한다는 것이 자세히 어떤 의미인가요??