제일 바깥쪽에 ConstraintLayout 로 감싸고 그 안에 배치할 것을 추가합니다. 예제에서는 2개의 요소만 배치를 했기 때문에 선언된 것도 2개뿐 입니다만, 여러 개 있다면 그것들을 다 기술해 주어야 합니다. 그리고 각 요소들의 Modifier.constrainAs을 활용하여 위치 지정을 시작합니다.
예제에서는 parent 라고 기술되는 제일 상위 ConstraintLayout으로부터 위치만 지정하도록 구성을 해 보았지만, parent 대신에 이전 요소인 runBtn 등의 이름이 적용될 수 도 있습니다.
이제는 화면 전체에 자유자재로 요소들을 배치하여 유연한 UI도 만들어 볼 수 있을 듯 합니다.
오늘은 챗봇과 스무고개 게임에 대한 이야기를 잠시 해 보았습니다. 챗봇에게 나의 의도를 설명하고 그 놀이를 할 수 있는지 물어보았고, 챗봇은 흔쾌히(?) 가능하다고 합니다. 해서 챗봇과 질문과 응답을 해 보았습니다.
챗봇이 외국계이기 때문에 질문은 영어로 하고 답도 영어로 받습니다. 여기서 번역은 구글 번역기를 활용 했습니다. 혹시나 영어를 잘하는 것으로 오해를 하실까 싶어 미리 밝힙니다. ㅋㅋ~
내가 한 질문: I want to play a question and answer game with you. The method of the game is that you remember the name of an object and I match it. I'm going to ask you 20 questions before you tell me the answer, you have to answer it like this, right, wrong, similar, and after the 20 questions are over, it's a game where you tell me if the answer I'm talking about is right or not. If the answer I said is wrong even after 20 questions, you win the game, and if I got it right, I win the game. can i do it
답 : Yes, I can play the question and answer game with you. Let's get started!
내가한 질문 : Then did you start remembering one thing?
답 : Yes, I have something in mind. You can start asking your questions.
내가한 질문 : is it an animal 답 : No, it is not an animal.
내가한 질문 : is it a thing 답 : Yes, it is a thing.
내가한 질문 : can it ride 답 : Yes, it is possible for this thing to be ridden.
내가한 질문 : is it a car 답 : No, it is not a car.
내가한 질문 : Does it have an engine 답 : Yes, it has an engine.
내가한 질문 : does it have two wheels 답 : Yes, it has two wheels.
내가한 질문 : is it a motorcycle 답 : Yes, it is a motorcycle.
내가한 질문 : Wow... I won, right? 답 : Yes, that's correct! You correctly guessed that the thing I was thinking of is a motorcycle. Congratulations, you win the game!
내가한 질문 : Did my number of questions exceed the first 20? 답 : No, you correctly guessed the answer within the first 6 questions, so we didn't need to go through all 20 questions. Well done!
내가한 질문 : Can you make a game like this with python code 답 : Yes, it is possible to create a similar game using Python code. Here is some sample code to get you started:
import random
# Create a list of items to be guessed items = ["motorcycle", "bicycle", "scooter", "skateboard", "rollerblades", "unicycle"]
# Select a random item from the list selected_item = random.choice(items)
# Define a function to play the game def play_game(item): guesses = 0 max_guesses = 20 while guesses < max_guesses: guesses += 1 guess = input("Guess the item: ") if guess == item: print("Congratulations, you win!") return elif guesses == max_guesses: print(f"Sorry, you've used all {max_guesses} guesses. The item was {item}.") return else: print("Incorrect guess. Please try again.")
# Play the game with the selected item play_game(selected_item)
This code randomly selects an item from a list and allows the user to guess the item within 20 attempts. If the user correctly guesses the item, the program ends with a congratulatory message. If the user uses all 20 guesses and still hasn't correctly guessed the item, the program ends with a message revealing the correct answer. You can modify the list of items to make the game more challenging or interesting.
내가한 질문 : There doesn't seem to be a function in this code to answer a question like you do. Can't you create a code that thinks and answers when you ask a question like I did with you?
답 : Ah, I understand what you're asking now. I apologize for the confusion earlier. What you're describing is a natural language processing (NLP) chatbot that can understand and respond to user input. While it's possible to create a simple NLP chatbot using Python, it's a complex task that requires significant knowledge in machine learning and natural language processing. There are various libraries and frameworks available in Python for developing NLP chatbots, such as spaCy, NLTK, and TensorFlow. However, creating a sophisticated chatbot that can understand and respond to a wide range of user input requires significant development effort and training data. If you'd like to learn more about developing chatbots with Python, there are many online tutorials and resources available that can help you get started.
내가한 질문 : Can you recommend just 20 online tutorials and resources?
답 : Sure, here are 20 online tutorials and resources for learning about chatbot development with Python:
내가한 질문 : thank you so much 답 : You're welcome! Don't hesitate to reach out if you have any further questions or if there's anything else I can help you with.
대화중에 파이썬 코드로 스무고개 게임을 할 수 있는 코드를 구현해 달라고 했더니 그것도 흔쾌히 해 주기는 했습니다만, 나의 의도와 다르길래 그 이야기를 했더니 이해를 했다면서 공부를 해야할 부분에 대한 조언도 해 주었습니다.
그래서 20개의 온라인 자습서나 리소스를 알려 달라고 해서 받았습니다. 다 영어로 되어 있는 정보들이라서... 흠...
#스하리1000명프로젝트, 가끔 외국인 노동자들과 대화가 힘들 때가 있죠? 도움이 되는 간단한 앱을 만들어 봤습니다! 당신은 당신의 언어로 글을 쓰고, 다른 사람들은 그것을 그들의 언어로 봅니다. 설정에 따라 자동 번역됩니다. 쉬운 채팅에 매우 편리합니다. 기회되면 꼭 보세요! https://play.google.com/store/apps/details?id=com.billcoreatech.multichat416
물론 50대 중년 남성이 일자리를 찾을 때 염두에 두어야 할 20가지 사항은 다음과 같습니다.
1. 가장 최근의 업적과 기술을 강조하도록 이력서를 업데이트하십시오. 2. 이전 동료, 친구 및 가족과 네트워크를 형성하여 직업 리드 및 추천을 받으세요. 3. 채용 박람회 및 업계 회의에 참석하여 잠재적인 고용주를 만나고 취업 기회에 대해 알아보세요. 4. 기술을 업데이트하고 시장성을 높이기 위해 직업 훈련이나 인증을 찾는 것을 두려워하지 마십시오. 5. LinkedIn과 같은 소셜 미디어 플랫폼을 활용하여 전문 네트워크를 구축하고 경험을 선보이세요. 6. 경력에 고용 공백이나 경력 변경 사항을 설명할 준비를 하십시오. 7. 잠재적인 고용주를 조사하고 필요에 맞게 이력서와 커버레터를 조정하십시오. 8. 취업 기회를 찾는 데 도움이 되는 채용 담당자 또는 인력 대행사와 협력하는 것을 고려하십시오. 9. 구직 과정 내내 긍정적이고 열정적인 태도를 유지하십시오. 10. 원래 경력 경로와 일치하지 않을 수 있는 직업 기회에 대해 유연하고 열린 마음을 가지십시오. 11. 기꺼이 낮은 수준에서 시작하거나 임시 또는 계약직 역할을 맡아 경험을 쌓고 자신의 가치를 증명하십시오. 12. 면접 기술을 연습하고 어려운 질문에 답할 준비를 하십시오. 13. 전문적인 복장을 하고 인터뷰를 위해 일찍 도착하십시오. 14. 열정을 보여주고 면접 중에 사려 깊은 질문을 하여 직업에 대한 관심을 보여주세요. 15. 인터뷰 후 감사 노트를 작성하여 감사를 표현하고 해당 업무에 대한 관심을 다시 한번 확인하십시오. 16. 참고 문헌 목록을 준비하고 그들이 당신이 구직 중이라는 것을 알고 있는지 확인하십시오. 17. 채용 제안을 받은 후 급여와 혜택을 협상할 준비를 하십시오. 18. 구직이 예상보다 오래 걸리더라도 정신을 차리고 동기를 유지하십시오. 19. 기술을 구축하고 전문 네트워크를 확장하기 위해 자원 봉사나 프리랜서 작업을 고려하십시오. 20. 풍부한 경험, 지식 및 성숙도를 직장에 가져오므로 나이가 자산이 될 수 있음을 기억하십시오.
오늘은 앱을 구현하는 동안에 필요했던 network interface을 통해서 Local IP을 얻어오는 코드에 대한 기술을 해 볼까 합니다.
@Throws(SocketException::class) fun getLocalIpAddress(): String {
//Device에 있는 모든 네트워크에 대해 뺑뺑이를 돕니다. val en = NetworkInterface.getNetworkInterfaces() while (en.hasMoreElements()) { val intf = en.nextElement()
//네트워크 중에서 IP가 할당된 넘들에 대해서 뺑뺑이를 한 번 더 돕니다. val enumIpAddr = intf.inetAddresses while (enumIpAddr.hasMoreElements()) { val inetAddress = enumIpAddr.nextElement()
//네트워크에는 항상 Localhost 즉, 루프백(LoopBack)주소가 있으며, 우리가 원하는 것이 아닙니다. //IP는 IPv6와 IPv4가 있습니다. //IPv6의 형태 : fe80::64b9::c8dd:7003 //IPv4의 형태 : 123.234.123.123 //어떻게 나오는지는 찍어보세요. if (inetAddress.isLoopbackAddress) { Log.e("IPAddress", "ip=" + intf.displayName + "(loopback) | " + inetAddress.hostAddress) } else { Log.e("IPAddress", "ip=" + intf.displayName + " | " + inetAddress.hostAddress) } if (!inetAddress.isLoopbackAddress && inetAddress is Inet4Address) { Log.e("", "") return inetAddress.getHostAddress().toString() } } } return "" }
물론 코드는 kotlin 코드 입니다. 구글링을 많이 해 보아도 java로 되어 있는 코드들은 많은데, kotlin 으로 되어 있는 코드는 잘 찾기가 힘이 듭니다. 해서 이번에 찾은 코드를 기록해 두려고 합니다. 그래야 나중에 또 사용할 일이 생길 수 있으니까요
우리가 찾는 IP 주소는 IPv4, IPv6 등등이 있을 수 있습니다. IPv6은 이제 너무 많아서 포화 상태가 되어가는 IPv4의 확장판이라고 보면 될 것 같습니다. 아직 까지는 IPv4로 지칭 되는 192.168.0.1 형식의 IP주소가 나오게 됩니다.
실행된 모습은 직접 만들어서 확인해 보시면 좋을 듯 합니다. 그래야 또 하나 배움의 길로 들어설 테니 말입니다.
#billcorea #운동동아리관리앱 🏸 Schneedle, a must-have app for badminton clubs! 👉 Match Play – Record Scores & Find Opponents 🎉 Perfect for anywhere, alone, with friends, or in a club! 🤝 If you like badminton, definitely try it
Go to app 👉 https://play.google.com/store/apps/details?id=com.billcorea.matchplay
오늘은 python 코드를 이용해서 스크랩하는 코드를 만들어 보았습니다. 이 코드도 openAI에게 요청해서 받은 코드 2가지를 공개해 볼까 합니다.
첫 번째 요청 결과는 아래와 같이 구성해 알려 주었습니다. 다만, 저기 있는 URL 이 검색이 되지 않는 코드 이기 때문에 그다지 도움이 되지 못할 것으로 생각이 됩니다.
import requests from bs4 import BeautifulSoup
# set the URL of the website to scrape url = "https://www.thecrazytourist.com/15-best-places-to-visit-in-south-korea/"
# send a GET request to the URL response = requests.get(url)
# parse the HTML content of the response using BeautifulSoup soup = BeautifulSoup(response.content, 'html.parser')
# find all the article elements on the page articles = soup.find_all('article')
# iterate over each article and extract the title and description for article in articles: title = article.find('h2').text description = article.find('div', {'class': 'entry-content'}).text.strip()
# print the title and description of the article print(f"Title: {title}") print(f"Description: {description}\n")
두 번째 시도를 해 보았습니다. 이번에 알려주는 URL은 실제 조회가 됩니다.
import requests from bs4 import BeautifulSoup
# the URL of the page to scrape url = 'https://www.tripadvisor.com/Attractions-g294196-Activities-South_Korea.html'
# send a GET request to the URL response = requests.get(url)
# parse the HTML content of the page with BeautifulSoup soup = BeautifulSoup(response.content, 'html.parser')
# find all the links to attractions on the page attraction_links = soup.find_all('a', {'class': 'attractions-attraction-overview-pois-PoiCard__poiLink--3PWj5'})
# print the titles and links of the attractions for link in attraction_links: title = link.get_text() href = link.get('href') print(f'{title}: https://www.tripadvisor.com{href}')
이렇게 만들어진 코드를 그대로 사용할 수 있을까요?
그건 좀 어렵게 생각이 됩니다. 다만, 이런 기본적인 코드를 얻음으로 인해서 배움의 길을 넓혀갈 수 있는 기초는 되지 않을까 하는 생각을 해 보게 되었습니다.
openAI에 대한 많은 기사거리, youtube 콘텐츠 많이 많이 생성이 되고 있습니다. 이것도 한 시간의 유행일까요? 아무튼 따라 해 보기는 해야 할 것 같습니다.