카테고리 없음

ChatGPT - 코딩까지 되는 open ai (+쓸데없는거 물어보기

socialcomputer 2022. 12. 21. 23:32
반응형

요즘 charGPT가 뜨겁길래, 또 무료길래 한번은 써봐야 싶어 써봤다. 

정확한 지식인을 보는 듯한.. 정리 잘된 구글검색 결과를 본 듯한 기분이다. 

너무 잘 정리해서 알려줘 놀라웠다. 예제도 다양하게 보여준다. 

모르는 것 찾고 싶을 때마다 chat하고 싶은 심정

( 한국어로 하면 오래걸린다. 영어로 물어보는게 좋은듯 )

 

크리스마스에 명동에 사람이 얼마나 많을지 물어봤다. 

 
Q: How many people will gather in Myeong-dong, Korea on Christmas?

A: It is not possible for me to accurately predict how many people will gather in Myeong-dong, Korea on Christmas without access to current information. Factors such as the COVID-19 pandemic and any related restrictions, weather conditions, and local events or attractions can all influence the number of people who may gather in a particular location on a specific day.
 In general, Myeong-dong is a popular shopping and tourist destination in Seoul, and it is likely to attract a significant number of people on Christmas and other holidays. However, it is important to follow local guidelines and restrictions to ensure the safety of yourself and others. If you are planning to visit Myeong-dong on Christmas, it is a good idea to check the latest information on travel advisories and safety measures before making any plans.
 

ai도 예측하기 어려운가보다. 그래도 고려해야되는 요소들을 알려준다. 사실 아무도 예측할 수 없는 일이기에 확답을 내주지 않는 것 같다. 그래도 %로 알려줄 줄 알았는데ㅎㅎ 

 

두유를 먹고 양치를 해야 하는지 가글만 해도 되는지 물어봤다ㅋㅋㅋ

Q: Should I brush my teeth after drinking soy milk? Can I just gargle?
A: It is generally a good idea to brush your teeth or at least rinse your mouth with water after drinking soy milk or any other food or beverage. This is because many foods and drinks can leave residue on your teeth, which can lead to the build-up of plaque and increase the risk of tooth decay and gum disease. Brushing your teeth helps to remove this residue and helps to keep your teeth and gums healthy.If you are unable to brush your teeth, you can also rinse your mouth with water or mouthwash. This will help to remove any food particles or bacteria from your mouth and can help to freshen your breath. However, it is not a substitute for brushing your teeth, which is the most effective way to remove plaque and prevent tooth decay.

왠만하면 양치를 해라. 치과의사쌤이 해주실 만한 정직한 얘기를 한다. 그리고 정 안되면 물이라도 헹궈라 하지만 대안은 아니란다. ㅎㅎ  당연히 양치는 해야죠

 

도커가 무엇이고 언제 쓰는지 물어봤다. 

Q: what is docker? and when use it?
A: Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package.

By using Docker, you can run multiple instances of your application on a single host, and each instance will be isolated from the others.
This is useful for many reasons, including the ability to easily deploy applications in different environments (e.g., staging, production), and the ability to run multiple versions of an application side by side.Docker is typically used in the following situations:
- When you want to run multiple instances of an application on a single host, and you want each instance to be isolated from the others.
- When you want to deploy an application in different environments (e.g., staging, production) without having to worry about differences in the underlying infrastructure.
- When you want to run multiple versions of an application side by side, without having to worry about conflicts between the different versions.
- When you want to automate the build, test, and deployment process for your application.
- When you want to create lightweight, portable development environments that can be easily shared with other developers.Overall, Docker is a powerful tool that can help you more easily develop, deploy, and run applications in a consistent and reliable way.

인터넷에서 도커가 뭔지 짜집기로 알아가다가 이렇게 한번에 정리되어 있는 것을 보니 머리가 복잡하던게 사라진 기분이였다...

원하는 정보를 얻으려면 검색어도 다르게, 글도 여러개 다 읽어보고 해야 해서 시간이 배로 걸렸는데 한번에 딱 알려주니 편하다. 

지금도 그렇지만 앞으로 책으로 지식을 얻는게 더욱 줄어들것 같다. 

 

이번엔 코딩을 부탁했다. 리뷰쓰는 페이지를 만드는 코드

Q: code about page to post reviews in html, javascript, css.

A: Here is an example of a page that allows users to post reviews using HTML, JavaScript, and CSS:

HTML:
<html>
  <head>
    <title>Reviews</title>
    <link rel="stylesheet" href="style.css">
  </head>
  <body>
    <h1>Leave a Review</h1>
    <form id="review-form">
      <label for="name">Name:</label><br>
      <input type="text" id="name" name="name"><br>
      <label for="review">Review:</label><br>
      <textarea id="review" name="review"></textarea><br>
      <button type="submit">Submit</button>
    </form>
    <h1>Recent Reviews</h1>
    <div id="reviews"></div>
    <script src="script.js"></script>
  </body>
</html>​


JavaScript:
const form = document.getElementById('review-form');
const reviewsDiv = document.getElementById('reviews');

form.addEventListener('submit', (event) => {
  event.preventDefault(); // prevent the form from being submitted
  const name = document.getElementById('name').value;
  const review = document.getElementById('review').value;
  // create a new review element and append it to the reviews div
  const reviewElement = document.createElement('p');
  reviewElement.innerHTML = `<strong>${name}</strong>: ${review}`;
  reviewsDiv.appendChild(reviewElement);
});​


CSS:
body {
  font-family: sans-serif;
}

form {
  display: flex;
  flex-direction: column;
  width: 50%;
  margin: 0 auto;
}

label {
  font-weight: bold;
}

input[type="text"], textarea {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-bottom: 12px;
  width: 100%;
}

button[type="submit"] {
  background-color: #4CAF50;
  color: white;
  padding: 12px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

button[type="submit"]:hover {
  background-color: #45a049;
}​

This code creates a form that allows users to enter their name and a review, and then submit the review by clicking a button. When the form is submitted, a new review element is created and appended to the reviews div. The CSS styles the form and the review elements to make them look more visually appealing.

Note that this is just a basic example, and you may want to add additional features and functionality to your review page. For example, you could add a rating system, or allow users to reply to and vote on reviews. You could also add server-side logic to store the reviews in a database and retrieve them when the page is loaded.

오.. 항상 어려운게 프론트 페이지를 어떻게 만들까 하는게 고민이였는데 초안은 괜찮겠다. 

 
 
 

 

 

 

 

 

 

atm 컨트롤러를 만들라고 시켜봤다.

Q: code atmcontroller in java
A: Here is an example of an ATM controller class in Java:
import java.util.Scanner;

public class ATMController {
  private static final Scanner input = new Scanner(System.in);

  private static final String[] MAIN_MENU_OPTIONS = {
    "Check balance",
    "Withdraw cash",
    "Deposit cash",
    "Exit"
  };

  private Bank bank; // the bank that the ATM is connected to
  private Customer currentCustomer; // the customer currently using the ATM

  public ATMController(Bank bank) {
    this.bank = bank;
  }

  public void start() {
    // display the welcome message
    System.out.println("Welcome to the ATM!");

    // loop until the user chooses to exit
    while (true) {
      // prompt the user to enter their card number
      System.out.print("Please enter your card number: ");
      long cardNumber = input.nextLong();

      // look up the customer using the card number
      currentCustomer = bank.findCustomerByCardNumber(cardNumber);
      if (currentCustomer == null) {
        System.out.println("Invalid card number. Please try again.");
        continue;
      }

      // prompt the user to enter their PIN
      System.out.print("Please enter your PIN: ");
      int pin = input.nextInt();

      // check the PIN
      if (!currentCustomer.checkPIN(pin)) {
        System.out.println("Incorrect PIN. Please try again.");
        continue;
      }

      // the customer has successfully logged in, so show the main menu
      showMainMenu();
    }
  }

  private void showMainMenu() {
    // loop until the user chooses to exit
    while (true) {
      // display the main menu options
      System.out.println("Main menu:");
      for (int i = 0; i < MAIN_MENU_OPTIONS.length; i++) {
        System.out.println((i + 1) + ". " + MAIN_MENU_OPTIONS[i]);
      }

      // prompt the user to enter their choice
      System.out.print("Enter your choice: ");
      int choice = input.nextInt();

      // handle the user's choice
      switch (choice) {
        case 1:
          checkBalance();
          break;
        case 2:
          withdrawCash();
          break;
        case 3:
          depositCash();
          break;
        case 4:
          return; // exit the main menu
        default:
          System.out.println("Invalid choice. Please try again.");
          break;
      }
    }
  }

  private void checkBalance() {
    System.out.println("Your balance is: $" + currentCustomer.getAccount().getBalance());
  }

  private void withdrawCash() {
    System.out.print("Enter the amount you want to withdraw: $");
    double amount = input.nextDouble();
    if (!currentCustomer.getAccount().withdraw(amount)) {
      System.out.println("Insufficient funds. Please try again.");
    } else {
      System.out.println("Successfully withdrew $" + amount);
    }
  }​

참.. 똑똑하다. 말의 뜻을 이해하고 기능과 목적을 이해한 후 코드를 짠걸까?  나눈 왜  bank를 주입받는걸 생각 못했을까.. 그리고 메뉴 입력은 System.in해도 되는 거였나 하는 생각이..

 

 

반응형