投稿時間:2022-08-16 00:32:37 RSSフィード2022-08-16 00:00 分まとめ(36件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
python Pythonタグが付けられた新着投稿 - Qiita 仏教での「慈悲の瞑想」を[for文を使った関数]で処理する https://qiita.com/morozumi-kohei/items/5450b0b9e347b159edb9 慈悲の瞑想 2022-08-15 23:59:50
python Pythonタグが付けられた新着投稿 - Qiita 【無限の猿定理】ルービックキューブを猿に解かせてみた https://qiita.com/yusuke_s_yusuke/items/044c2e4e2ccbb949511a infinitemonkeytheorem 2022-08-15 23:41:58
js JavaScriptタグが付けられた新着投稿 - Qiita JavaScriptにおけるreturnをすごくわかりやすく https://qiita.com/pix_shimitomo/items/d5d2c6ec54519de6c57a javascript 2022-08-15 23:52:47
golang Goタグが付けられた新着投稿 - Qiita Go で Stack と FIFO https://qiita.com/mattn/items/774280a746c82ee63fc0 containerlist 2022-08-15 23:15:26
Git Gitタグが付けられた新着投稿 - Qiita 【Git】git commit 後に commit message を変更したい https://qiita.com/watame/items/b93e19b0fbbc37fad22c commitmessage 2022-08-15 23:24:59
Ruby Railsタグが付けられた新着投稿 - Qiita rails sがうまくいかなかった https://qiita.com/satosh_da/items/f9b429a4ed005ec6cc74 aspringpreloaderinprocess 2022-08-15 23:26:53
海外TECH DEV Community Meme Monday! 🤑 https://dev.to/ben/meme-monday-4a5d Meme Monday Welcome to another Meme Monday post Today s cover image comes from last week s thread DEV is an inclusive space Humor in poor taste will be downvoted by mods 2022-08-15 14:49:40
海外TECH DEV Community 🇮🇳Happy Independence Day to all my Indian Family 🇮🇳 https://dev.to/gauravsoni97/happy-independence-day-to-all-my-indian-family-5a2a Happy Independence Day to all my Indian Family Happy Independence Day On August Monday India will mark years of Independence The country gained freedom from British colonial rule on August As we gear up to celebrate the th Independence Day it is crucial to remember the importance of this day the history of our nation and the sacrifices our freedom fighters made to gain freedom from the clutches of the British Empire On this day the country s citizens hoist flags while singing the national anthem and cultural parades take place all over the country The Prime Minister also hoists the national flag and gives a speech at the Red Fort It is a tradition started by the first prime minister of India Jawaharlal Nehru who raised the national flag above the Lahori Gate of Red Fort in Delhi in 2022-08-15 14:49:00
海外TECH DEV Community What is credit in Dev.to? https://dev.to/gauravsoni97/what-is-credit-in-devto-13g1 What is credit in Dev to Can someone explain me what is that credit means in dev to I mean I have credit in my dashboard so what is that mean Waiting for your comments 2022-08-15 14:46:10
海外TECH DEV Community Happy 75th Independence Day India https://dev.to/kavyagreatrgb/happy-75th-independence-day-india-32pd Happy th Independence Day India IntroductionEvery year on August India commemorates its independence The country was ruled by Britain for almost years eventually becoming independent and becoming an independent nation August has become a day of independence It is also commemorated as a memorial to the freedom warriors who gave their lives to make the world a better place for us to live It is celebrated with great enthusiasm and courage by all the citizens of India because IndependenceDay means a lot to them and is very important Here s how it is celebrated in schools colleges and across the country and why it is important forstudents and citizens of the country Celebration of Independence Day in School CollegesAs August is a national holiday Freedom Day celebrations are held yesterday in many schools and colleges across the country Freedom Day celebrations in schools and colleges across the country include flag raising speeches debates and competitions dances repetition of poetry and various other cultural activities Students are very excited about these activities and participate wholeheartedly in them Students of the main league are also seen dressed as freedom fighters These activities draw students closer to their roots and fill them with a sense of patriotism that is lacking in this generation Independence Day Celebration in OfficesThis day is also celebrated in the offices the day before independence day In offices employees are often asked to wear saffron white or green clothing to match the theme of Freedom Day People are seen wearing national costumes in the said colors and the wholeatmosphere is lit Flag raising is done at most offices around the country with special lunch arrangements being made to strengthen the bond between staff Sometimes people also come to give talks and some offices organize cultural events to add to the feeling Also read the conclusion of the Independence Day article Independence Day Residence CelebrationResidential welfare organizations in various residential areas are taking the initiative to celebrate Independence Day these days People gathered in a nearby park in the early hours of the morning on Independence Day to celebrate the day with its true meaning They dress according to the theme of Freedom Day and participate in various activities organized during the program Raising the flag is done at the beginning of the ceremony After the flag was hoisted the people stood in awe and paid homage to the national anthem Patriotic songs are fully played during the celebrations and people seem to be immersed in the spirit of nationalism During these events dance competitions and poetry competitions are organized Luxury dress competitions are also held where children are considered to be freedom fighters such as Jawaharlal Nehru Sarojini Naidu Bhagat Singh etc These competitions are often followed by lunch People stay together and enjoy a meal during these events this is a great time to collaborate with the neighbors In many parts of our country kite flying is practiced as a custom on Independence Day Colorful kites flying freely in the sky are considered a sign of independence People go to their terrace or go to the nearby ground to enjoy the work of a flying kite They invited their friends and relatives to join in the celebration Flying kite competitions are also held at various venues and people participate with great enthusiasm History of Independence DayThe story of India s liberation is very long with various freedom fighters fighting for their courage and tolerance Meanwhile European traders were increasingly seeking to settle in India and establish themselves on the Indian subcontinent At the same time in the Battle of Plessy in and the Battle of Buxar in India faced foreign forces but India could not prove its strength and was defeated in these wars Thereafter the East India Company began to spread its influence in India and by the end of the th century the British had established their monarchy in many parts of India At the same time the company harassed Indian society by enacting a number of stricter laws inIndia as well as many oppressive policies that applied to the people Because the Indians opposed the foreign emperor and created hatred for them At the same time it was because of these British oppressive policies that the uprising began from Meerut in Uttar Pradesh on May At the same time the war of is considered India s first liberation war Also read the conclusion of the Independence Day article Major rebels such as Mangal Pandey Tatya Tope Rani Laxmi Bai Nana Saheb Begum Hazrat Mahal Rani Avanti Bai and Babu Kunwar have played their key role in this war At the same time our country could not stand on its own two feet in this war but this transformation had a profound effect on all Indians and aroused a desire for freedom within the Indians In line with this after the war of the British rulers recognized the power of the Indians andafter this the cruel and oppressive policies of the British East India Company began to weaken After the Revolt of the Indian state was taken over by the British East India Company in and handed over to the British Crown which is the British Monarchy At the end of the war of the liberation struggle spread to India and after that the British felt that they could not rule India for long At the same time it rebelled after the civil war from to led by many major Indian revolutionaries including India s great freedom fighters Gopal Krishna Gokhale Madan Mohan Malviya and Dadabhai Naoroji All the reforms that led to this war were ideological and political which fought for freedom peacefully By the th century however the atrocities perpetrated by the British on the Indian subcontinent had intensified Because at the end of the th century Lala Lajpat Rai Bipin Chandra Pal took many steps against the British and provoked the anger in the minds of the Indians against the British Everyone united in seeking independence in India At the same time as a result of the efforts of these freedom fighters the British became afraid ofthe Indians In the th century several movements including the Non Cooperation Movement CivilDisobedience Movement and the Quit India Movement Mahatma Gandhi s Nonviolent Movement shook the foundations of the British and Indian empires The road to freedom was easy and he left no choice but to leave India and the British Meanwhile in the Indian National Congress Party was formed In the Indian National Congress demanded complete independence After that freedom fighters politicians and the Indian people united and strengthened their British rebellion against independence As a result the British Parliament ordered Lord Mount batten to rule in India until June weakening the British Empire in India but only then did the British see the flames and their level of intolerance within India Lord Mountbatten decided to leave India in August before waiting for the deadline The British who had persecuted the Indians for so many years sacrificed their lives in the face of the courage courage and unity of the Indians So on August India became an independent nation ConclusionAugust is a day to celebrate freedom and to remember the great souls who stood up for theirrights and fought no matter what their lives were This day is celebrated with great enthusiasm throughout the country 2022-08-15 14:42:00
海外TECH DEV Community Best Books For Learning Web Development https://dev.to/langford_dev/best-books-for-learning-web-development-42c7 Best Books For Learning Web DevelopmentTutorial videos and online courses are the most popular ways to learn almost anything However a fraction of people prefers reading from a physical book If you fall into this category and want to learn web development this article is for you We ll go over the best and most highly recommended books for learning and mastering web development Let s get started HTML amp CSS and JavaScript amp JQuery by Jon DuckettThis book deserves to be at the top of this list It is without a doubt one of the most popular web development books among the tech community It is well written and simple to understand especially for beginners This book is also available in digital format on the internet Get it on AmazonDownload here Eloquent JavaScript rd Edition A Modern Introduction to ProgrammingWritten by Marijn Haverbeke Eloquent JavaScript is known as The Best JavaScript Book It is centered around beginners and teaches you JavaScript from the basics to the more complex topics It employs a practical method of teaching by building mini projects and simple games so you can further understand JavaScript Read online hereGet on Amazon HTML and CSS Learn The Fundamentals In days by Michael KnappHere s why I love this book It is geared toward beginnersDoesn t require the reader to have any prior web development experience at allIs excellent for starting your web development journeyThis book touches on almost everything there is to know about HTML and CSS Knapp teaches basic HTML structure hacking together a website analytics and SEO Get on AmazonDownload here A beginner s guide to HTML CSS Javascript and Web Graphics by Jennifer Niederst RobbinsThis book which has over pages breaks down concepts such as how the web and web pages work before delving into HTML CSS JavaScript Responsive Design and web graphics Download here Kyle Simpson s You Don t Know JSYou Don t Know JS is a series of smaller books that cover different topics and delve deeply into the core mechanics of the JavaScript language This book is an excellent recommendation if you re a beginner Download here Bonus The Clean Coder by Robert MartinBased on the title you ve probably guessed what this book is about You are correct It s all about writing clean code Robert Martin teaches us the art of writing clean readable code as well as tips on how to advance in your developer career Download here ConclusionThat s it for this article If you found this article useful consider following me on Twitter and signing up for my weekly newsletter for web and software development content 2022-08-15 14:27:16
海外TECH DEV Community Building a chat app with Socket.io and React 🚀 https://dev.to/novu/building-a-chat-app-with-socketio-and-react-2edj Building a chat app with Socket io and React What is this article about We have all encountered chat over the web that can be Facebook Instagram Whatsapp and the list goes on Just to give a bit of context you send a message to a person or a group they see the message and reply back Simple yet complex To develop a chat app you would need to be aware of new messages as soon as they arrive Usually to get information from the server you need send an HTTP request With websockets the server lets you know when there is new information without asking it In this article we ll leverage the real time communication provided by Socket io to create an open chat application that allows users to send and receive messages from several users on the application You will also learn how to detect the users who are online and when a user is typing To read this article you ll need to have a basic knowledge of React js and Node js to comprehend this article What is Socket io Socket io is a popular JavaScript library that allows us to create real time bi directional communication between web browsers and a Node js server It is a highly performant and reliable library optimized to process a large volume of data with minimal delay It follows the WebSocket protocol and provides better functionalities such as fallback to HTTP long polling or automatic reconnection which enables us to build efficient chat and real time applications Novu the first open source notification infrastructureJust a quick background about us Novu is the first open source notification infrastructure We basically help to manage all the product notifications It can be In App the bell icon like you have in Facebook Websockets Emails SMSs and so on I would be super happy if you could give us a star And let me also know in the comments ️ How to connect a React js app to Node js via Socket ioIn this section we ll set up the project environment for our chat application You ll also learn how to add Socket io to a React and Node js application and connect both development servers for real time communication via Socket io Create the project folder containing two sub folders named client and server mkdir chat appcd chat appmkdir client serverNavigate into the client folder via your terminal and create a new React js project cd clientnpx create react app Install Socket io client API and React Router  React Router is a JavaScript library that enables us to navigate between pages in a React application npm install socket io client react router domDelete the redundant files such as the logo and the test files from the React app and update the App js file to display Hello World as below function App return lt div gt lt p gt Hello World lt p gt lt div gt Next navigate into the server folder and create a package json file cd servernpm init yInstall Express js CORS Nodemon and Socket io Server API Express js is a fast minimalist framework that provides several features for building web applications in Node js  CORS is a Node js package that allows communication between different domains Nodemon is a Node js tool that automatically restarts the server after detecting file changes and Socket io allows us to configure a real time connection on the server npm install express cors nodemon socket io Create an index js file the entry point to the web server touch index jsSet up a simple Node js server using Express js The code snippet below returns a JSON object when you visit the http localhost api in your browser index jsconst express require express const app express const PORT app get api req res gt res json message Hello world app listen PORT gt console log Server listening on PORT Import the HTTP and the CORS library to allow data transfer between the client and the server domains const express require express const app express const PORT New importsconst http require http Server app const cors require cors app use cors app get api req res gt res json message Hello world http listen PORT gt console log Server listening on PORT Next add Socket io to the project to create a real time connection Before the app get block copy the code below New imports const socketIO require socket io http cors origin http localhost Add this before the app get blocksocketIO on connection socket gt console log socket id user just connected socket on disconnect gt console log A user disconnected From the code snippet above the socket io connection function establishes a connection with the React app then creates a unique ID for each socket and logs the ID to the console whenever a user visits the web page When you refresh or close the web page the socket fires the disconnect event showing that a user has disconnected from the socket Next configure Nodemon by adding the start command to the list of the scripts in the package json file The code snippet below starts the server using Nodemon In server package json scripts test echo Error no test specified amp amp exit start nodemon index js You can now run the server with Nodemon by using the command below npm startOpen the App js file in the client folder and connect the React app to the Socket io server import socketIO from socket io client const socket socketIO connect http localhost function App return lt div gt lt p gt Hello World lt p gt lt div gt Start the React js server npm startCheck the terminal where the server is running the ID of the React js client appears in the terminal Congratulations the React app has been successfully connected to the server via Socket io For the remaining part of this article I will walk you through creating the web pages for the chat application and sending messages back and forth between the React app and the Node js server I ll also guide you on how to add the auto scroll feature when a new message arrives and how to fetch active users in your chat application Creating the Home page for the chat applicationIn this section we ll create the home page for the chat application that accepts the username and saves it to the local storage for identification Create a folder named components within the client src folder Then create the Home page component cd srcmkdir components amp cd componentstouch Home jsCopy the code below into the Home js file The code snippet displays a form input that accepts the username and stores it in the local storage import React useState from react import useNavigate from react router dom const Home gt const navigate useNavigate const userName setUserName useState const handleSubmit e gt e preventDefault localStorage setItem userName userName navigate chat return lt form className home container onSubmit handleSubmit gt lt h className home header gt Sign in to Open Chat lt h gt lt label htmlFor username gt Username lt label gt lt input type text minLength name username id username className username input value userName onChange e gt setUserName e target value gt lt button className home cta gt SIGN IN lt button gt lt form gt export default Home Next configure React Router to enable navigation between the pages of the chat application A home and chat page is enough for this application Copy the code below into the src App js file import BrowserRouter Routes Route from react router dom import Home from components Home import ChatPage from components ChatPage import socketIO from socket io client const socket socketIO connect http localhost function App return lt BrowserRouter gt lt div gt lt Routes gt lt Route path element lt Home socket socket gt gt lt Route gt lt Route path chat element lt ChatPage socket socket gt gt lt Route gt lt Routes gt lt div gt lt BrowserRouter gt export default App The code snippet assigns different routes for the Home and Chat page of the application using React Router v and passes the Socket io library into the components We ll create the Chat page in the upcoming section Navigate into the src index css file and copy the code below It contains all the CSS required for styling this project import url wght amp display swap box sizing border box margin padding font family Poppins sans serif home container width height vh display flex flex direction column justify content center align items center home container gt margin bottom px home header margin bottom px username input padding px width home cta width px padding px font size px cursor pointer background color eaa color ffeb outline none border none border radius px chat width height vh display flex align items center chat sidebar height background color ffeb flex padding px border right px solid fdfdfd chat main height flex chat header margin px px chat users gt margin bottom px color eaa font size px online users gt margin bottom px color rgb font style italic chat mainHeader width height vh display flex align items center justify content space between padding px background color ffeb leaveChat btn padding px width px border none outline none background color dd cursor pointer color eaed message container width height vh background color fff padding px overflow y scroll message container gt margin bottom px chat footer padding px background color ffeb height vh form width height display flex align items center justify content space between message width height border radius px border px solid ddd outline none padding px sendBtn width px background color green padding px border none outline none color eaed cursor pointer sendBtn hover background color rgb message recipient background color fccc width px padding px border radius px font size px message sender background color rgb max width px padding px border radius px margin left auto font size px message chats gt p font size px sender name text align right message status position fixed bottom px font size px font style italic We ve created the home page of our chat application Next let s design the user interface for the chat page Creating the Chat page of the applicationIn this section we ll create the chat interface that allows us to send messages and view active users From the image above the Chat page is divided into three sections the Chat Bar sidebar showing active users the Chat Body containing the sent messages and the header and the Chat Footer the message box and the send button Since we ve been able to define the layout for the chat page you can now create the components for the design Create the ChatPage js file and copy the code below into it You will need to ChatBar ChatBody and ChatFooter components import React from react import ChatBar from ChatBar import ChatBody from ChatBody import ChatFooter from ChatFooter const ChatPage socket gt return lt div className chat gt lt ChatBar gt lt div className chat main gt lt ChatBody gt lt ChatFooter gt lt div gt lt div gt export default ChatPage The Chat Bar componentCopy the code below into the ChatBar js file import React from react const ChatBar gt return lt div className chat sidebar gt lt h gt Open Chat lt h gt lt div gt lt h className chat header gt ACTIVE USERS lt h gt lt div className chat users gt lt p gt User lt p gt lt p gt User lt p gt lt p gt User lt p gt lt p gt User lt p gt lt div gt lt div gt lt div gt export default ChatBar The Chat Body componentHere we ll create the interface displaying the sent messages and the page headline import React from react import useNavigate from react router dom const ChatBody gt const navigate useNavigate const handleLeaveChat gt localStorage removeItem userName navigate window location reload return lt gt lt header className chat mainHeader gt lt p gt Hangout with Colleagues lt p gt lt button className leaveChat btn onClick handleLeaveChat gt LEAVE CHAT lt button gt lt header gt This shows messages sent from you lt div className message container gt lt div className message chats gt lt p className sender name gt You lt p gt lt div className message sender gt lt p gt Hello there lt p gt lt div gt lt div gt This shows messages received by you lt div className message chats gt lt p gt Other lt p gt lt div className message recipient gt lt p gt Hey I m good you lt p gt lt div gt lt div gt This is triggered when a user is typing lt div className message status gt lt p gt Someone is typing lt p gt lt div gt lt div gt lt gt export default ChatBody The Chat Footer componentHere we ll create the input and the send button at the bottom of the chat page The message and the username appear in the console after submitting the form import React useState from react const ChatFooter gt const message setMessage useState const handleSendMessage e gt e preventDefault console log userName localStorage getItem userName message setMessage return lt div className chat footer gt lt form className form onSubmit handleSendMessage gt lt input type text placeholder Write message className message value message onChange e gt setMessage e target value gt lt button className sendBtn gt SEND lt button gt lt form gt lt div gt export default ChatFooter Sending messages between the React app and the Socket io serverIn this section you ll learn how to send messages from the React app to the Node js server and vice versa via Socket io To send the messages to the server we will need to pass the Socket io library into the ChatFooter component that sends the messages Update the ChatPage js file to pass the Socket io library into the ChatFooter component import React from react import ChatBar from ChatBar import ChatBody from ChatBody import ChatFooter from ChatFooter const ChatPage socket gt return lt div className chat gt lt ChatBar gt lt div className chat main gt lt ChatBody gt lt ChatFooter socket socket gt lt div gt lt div gt export default ChatPage Update the handleSendMessage function in the ChatFooter component to send the message to the Node js server import React useState from react const ChatFooter socket gt const message setMessage useState const handleSendMessage e gt e preventDefault if message trim amp amp localStorage getItem userName socket emit message text message name localStorage getItem userName id socket id Math random socketID socket id setMessage return lt div className chat footer gt lt div gt export default ChatFooter The handleSendMessage function checks if the text field is empty and if the username exists in the local storage sign in from the Home page before sending the message event containing the user input username the message ID generated and the socket or client ID to the Node js server Open the index js file on the server update the Socket io code block to listen to the message event from the React app client and log the message to the server s terminal socketIO on connection socket gt console log socket id user just connected Listens and logs the message to the console socket on message data gt console log data socket on disconnect gt console log A user disconnected We ve been able to retrieve the message on the server hence let s send the message to all the connected clients socketIO on connection socket gt console log socket id user just connected sends the message to all the users on the server socket on message data gt socketIO emit messageResponse data socket on disconnect gt console log A user disconnected Update the ChatPage js file to listen to the message from the server and display it to all users import React useEffect useState from react import ChatBar from ChatBar import ChatBody from ChatBody import ChatFooter from ChatFooter const ChatPage socket gt const messages setMessages useState useEffect gt socket on messageResponse data gt setMessages messages data socket messages return lt div className chat gt lt ChatBar socket socket gt lt div className chat main gt lt ChatBody messages messages gt lt ChatFooter socket socket gt lt div gt lt div gt export default ChatPage From the code snippet above Socket io listens to the messages sent via the messageResponse event and spreads the data into the messages array The array of messages is passed into the ChatBody component for display on the UI Update the ChatBody js file to render the data from the array of messages import React from react import useNavigate from react router dom const ChatBody messages gt const navigate useNavigate const handleLeaveChat gt localStorage removeItem userName navigate window location reload return lt gt lt header className chat mainHeader gt lt p gt Hangout with Colleagues lt p gt lt button className leaveChat btn onClick handleLeaveChat gt LEAVE CHAT lt button gt lt header gt lt div className message container gt messages map message gt message name localStorage getItem userName lt div className message chats key message id gt lt p className sender name gt You lt p gt lt div className message sender gt lt p gt message text lt p gt lt div gt lt div gt lt div className message chats key message id gt lt p gt message name lt p gt lt div className message recipient gt lt p gt message text lt p gt lt div gt lt div gt lt div className message status gt lt p gt Someone is typing lt p gt lt div gt lt div gt lt gt export default ChatBody The code snippet above displays the messages depending on whether you or another user sent the message Messages in green are the ones you sent and red is messages from other users Congratulations the chat application is now functional You can open multiple tabs and send messages from one to another How to fetch active users from Socket ioIn this section you ll learn how to get all the active users and display them on the Chat Bar of the chat application Open the src Home js and create an event that listens to users when they sign in Update the handleSubmit function as below import React useState from react import useNavigate from react router dom const Home socket gt const navigate useNavigate const userName setUserName useState const handleSubmit e gt e preventDefault localStorage setItem userName userName sends the username and socket ID to the Node js server socket emit newUser userName socketID socket id navigate chat return Create an event listener that updates an array of users on the Node js server whenever a user joins or leaves the chat application let users socketIO on connection socket gt console log socket id user just connected socket on message data gt socketIO emit messageResponse data Listens when a new user joins the server socket on newUser data gt Adds the new user to the list of users users push data console log users Sends the list of users to the client socketIO emit newUserResponse users socket on disconnect gt console log A user disconnected Updates the list of users when a user disconnects from the server users users filter user gt user socketID socket id console log users Sends the list of users to the client socketIO emit newUserResponse users socket disconnect socket on newUser is triggered when a new user joins the chat application The user s details socket ID and username are saved into the users array and sent back to the React app in a new event named newUserResponse In socket io disconnect the users array is updated when a user leaves the chat application and the newUserReponse event is triggered to send the updated the list of users to the client Next let s update the user interface ChatBar js to display the list of active users import React useState useEffect from react const ChatBar socket gt const users setUsers useState useEffect gt socket on newUserResponse data gt setUsers data socket users return lt div className chat sidebar gt lt h gt Open Chat lt h gt lt div gt lt h className chat header gt ACTIVE USERS lt h gt lt div className chat users gt users map user gt lt p key user socketID gt user userName lt p gt lt div gt lt div gt lt div gt export default ChatBar The useEffect hook listens to the response sent from the Node js server and collects the list of active users The list is mapped into the view and updated in real time Congratulations we ve been able to fetch the list of active users from Socket io Next let s learn how to add some cool features to the chat application Optional Auto scroll and Notify users when a user is typingIn this section you ll learn how to add the auto scroll feature when you receive a new message and the typing feature that indicates that a user is typing Auto scroll featureUpdate the ChatPage js file as below import React useEffect useState useRef from react import ChatBar from ChatBar import ChatBody from ChatBody import ChatFooter from ChatFooter const ChatPage socket gt const messages setMessages useState const typingStatus setTypingStatus useState const lastMessageRef useRef null useEffect gt socket on messageResponse data gt setMessages messages data socket messages useEffect gt ️scroll to bottom every time messages change lastMessageRef current scrollIntoView behavior smooth messages return lt div className chat gt lt ChatBar socket socket gt lt div className chat main gt lt ChatBody messages messages lastMessageRef lastMessageRef gt lt ChatFooter socket socket gt lt div gt lt div gt export default ChatPage Update the ChatBody component to contain an element for lastMessageRef import React from react import useNavigate from react router dom const ChatBody messages lastMessageRef gt const navigate useNavigate const handleLeaveChat gt localStorage removeItem userName navigate window location reload return lt gt lt div gt At the bottom of the JSX element lt div ref lastMessageRef gt lt div gt lt gt export default ChatBody From the code snippets above lastMessageRef is attached to a div tag at the bottom of the messages and its useEffect has a single dependency which is the messages array So when the messages changes the useEffect for the lastMessageRef re renders Notify others when a user is typingTo notify users when a user is typing we ll use the JavaScript onKeyDown event listener on the input field which triggers a function that sends a message to Socket io as below import React useState from react const ChatFooter socket gt const message setMessage useState const handleTyping gt socket emit typing localStorage getItem userName is typing const handleSendMessage e gt e preventDefault if message trim amp amp localStorage getItem userName socket emit message text message name localStorage getItem userName id socket id Math random socketID socket id setMessage return lt div className chat footer gt lt form className form onSubmit handleSendMessage gt lt input type text placeholder Write message className message value message onChange e gt setMessage e target value OnKeyDown function onKeyDown handleTyping gt lt button className sendBtn gt SEND lt button gt lt form gt lt div gt export default ChatFooter From the code snippet above the handleTyping function triggers the typing event whenever a user is typing into the text field Then we can listen to the typing event on the server and send a response containing the data to other users via another event called typingResponse socketIO on connection socket gt console log socket id user just connected socket on message data gt socketIO emit messageResponse data socket on typing data gt socket broadcast emit typingResponse data socket on newUser data gt users push data socketIO emit newUserResponse users socket on disconnect gt console log A user disconnected users users filter user gt user socketID socket id socketIO emit newUserResponse users socket disconnect Next listen to the typingResponse event in the ChatPage js file and pass the data into the ChatBody js file for display import React useEffect useState useRef from react import ChatBar from ChatBar import ChatBody from ChatBody import ChatFooter from ChatFooter const ChatPage socket gt const messages setMessages useState const typingStatus setTypingStatus useState const lastMessageRef useRef null useEffect gt socket on messageResponse data gt setMessages messages data socket messages useEffect gt ️scroll to bottom every time messages change lastMessageRef current scrollIntoView behavior smooth messages useEffect gt socket on typingResponse data gt setTypingStatus data socket return lt div className chat gt lt ChatBar socket socket gt lt div className chat main gt lt ChatBody messages messages typingStatus typingStatus lastMessageRef lastMessageRef gt lt ChatFooter socket socket gt lt div gt lt div gt export default ChatPage Update the ChatBody js file to show the typing status to the users lt div className message status gt lt p gt typingStatus lt p gt lt div gt Congratulations you ve just created a chat application Feel free to improve the application by adding the Socket io private messaging feature that allows users to create private chat rooms and direct messaging using an authentication library for user authorization and authentication and a real time database for storage ConclusionSocket io is a great tool with excellent features that enables us to build efficient real time applications like sports betting websites auction and forex trading applications and of course chat applications by creating lasting connections between web browsers and a Node js server If you re looking forward to building a chat application in Node js Socket io may be an excellent choice You can find the source code for this tutorial here Next articleIn the next part of the series I am going to talk about connecting the chat app into browser notifications web push so you can inform users about new messages if they are offline Help me out If you feel like this article helped you understand WebSockets better I would be super happy if you could give us a star And let me also know in the comments ️Thank you for reading 2022-08-15 14:18:46
海外TECH DEV Community Storybook As A Game Development Tool (With Demo) https://dev.to/foxhoundn/storybook-as-a-game-development-tool-with-demo-5203 Storybook As A Game Development Tool With Demo Storybook has become a quintessential tool in the prototyping development and testing of my browser game Not the reading type Here is the link to the Storybook I d suggest reading at least the Introduction story first SYNTHAX Storybook Chrome or Edge required Games and Storybook What Storybook is a tool that helps web developers build components pages and experiences in isolation see storybook js org And it s hella good at it Recently I have un shelved the only side project I have a D browser game called SYNTHAX and slowly started working on it again Having been neck deep in Storybook the past few months professionally I realised that with some luck and tinkering and a lil bit of hacking it would be the quintessential tool for game development weeks ago on a Friday night I decided to give it a try Today I wish I ve done it sooner FeaturesIt s very easy and convenient to work on any part of the game in isolation Meshes Particles Animations UI Interactive elements you name it It s also very helpful to be able to prototype build amp test whole maps and rooms in isolationThe ability to change settings and also environment options on the fly at any timeControllable player character can be spawned in any story except UI only stories Screenshot testing of all stories thanks to Chromatic The Playable DemoLike what you re seeing Well you can try it too Here is the link to the Storybook SYNTHAX Storybook Chrome or Edge required The first story is the Introduction that gives more info on the how and whys There are a bunch of stories and even a playable mini game called Target Practice give it a try and let me know your highest score Enemies start with secondary weaponAfter kills they switch to primary weaponAfter kills they get more healthAfter kills a second enemy spawns with a chainsawGood luck Make sure to join the discord server to stay in touch SYNTHAX Discord Server Thanks for reading and have fun A little backstory feel free to skip this In I started a little side project with no goal no vision and no expectations I just knew I wanted to make something resembling a game using the tools I am very familiar with TypeScript Node React and the web browser After a few hours of research I downloaded the BabylonJS engine and started tinkering Days and weeks have passed and something started to shape That something took a form of a rd person view but from the top battle royale then went through a multiplayer arena shooter phase now I want it to be a single player with rouge like elements It s called SYNTHAX and it s my most favourite thing to work on even if it s so damn challenging 2022-08-15 14:13:53
海外TECH DEV Community Get a video URL from Twitter API v2 https://dev.to/twitterdev/get-a-video-url-from-twitter-api-v2-1713 Get a video URL from Twitter API vTwitter API v has been available for quite a while now but it s an evolving process as we bring more endpoints and features to the new environment One data field that was not initially available at launch was the URL for videos attached to Tweets This information was added to the data expansions earlier this year so if you are making a request to the API today you can now add query parameters to have multiple video variant URLs returned as part of an attached expansion If you re into the details you can always check what functionality is available in the API by grabbing the latest OpenAPI specification document which lives at you can look at the Changelog for a more high level list of updatesTwitter API v has many improvements over the legacy version one of them being the concepts of fields and expansions These are query parameters that control which elements of data are returned on an API call To get the video information the data we want to return is part of the media object contained in variants which is an array of available display formats Building a queryI ll pick a recent Tweet with an attached video from my own timeline at random Andy Piper andypiper biglesp Jolly Device It blinks The module that is…not coded yet PM Aug The Tweet ID here is I got this by taking it from the URL of the Tweet on Twitter but I could have picked it out from an API query If we request that Tweet via the API by default only the the basic fields will be returned for a Tweet these are text and id In this case we want to get the video URLs that are attached In oder to do this we need the following combination of fields and expansions tweet fields I need to ask for any attachments the concept here is that videos are attached to Tweets and so are images polls etc expansions the name of the expansion is attachments media keysThese two parameters will now tell the API to return any media object associated with the Tweet inside the includes section of the response but by default the default fields for the media object are media key the value that links the data to the Tweet itself and type video image etc So we need to add third parameter media fields the video data is in the variants array It may also be useful to request alt text if the user has set alternative text for accessibility preview image url duration ms and possibly also public metrics so that we can see how many times the video has been viewed The final request we ve built includes the URL parameters tweet fields attachments amp expansions attachments media keys amp media fields variants alt text preview image url duration ms public metrics These parameters can be used on any API calls that are expected to return Tweet objects and will expand the media to include appropriate video information when available Show us some code The Twitter team released some beta SDKs for the new API starting with packages for JavaScript and TypeScript in Node and also Java Twitter Dev twitterdev The only thing better than one SDK is two SDKs someone wise probably  Introducing two new open source Twitter API v SDKs in beta for Java and JavaScript TypeScript to help you integrate more easily with the Twitter API v  Learn more twittercommunity com t introducing … PM Mar If you don t code in these languages or even if you do but you re familiar with a different SDK the community has created a range of great libraries to help you code against the Twitter API Let s go ahead and use the TypeScript SDK to run our query You ll need a Twitter Developer Account if you don t have one yet sign up here it s free and to create a project containing an app to get a Bearer Token You ll also need to install the Twitter SDK add twitter api sdk to your package json file Here s the code to get the same Tweet we looked at before using the same set of parameters to the API import Client from twitter api sdk if process env BEARER TOKEN throw new Error Please add your BEARER TOKEN as an environment variable in the Secrets section const client new Client process env BEARER TOKEN as string async function main const data includes await client tweets findTweetsById ids tweet fields attachments expansions attachments media keys media fields alt text duration ms preview image url public metrics variants if data throw new Error Couldn t retrieve Tweet console log nTweet text t data text console log Media t t includes media type console log Alt text t includes media alt text console log Views t t includes media public metrics view count console table includes media variants bit rate url dump whole JSON data objects console log data JSON stringify data null console log includes JSON stringify includes null main Let s go through this code We start out by bringing in the Twitter SDK and then we read the value of the bearer token in from the environment variables you can do this via setting up secrets in a cloud runtime or create a local shell environment variable e g export BEARER TOKEN your bearer token value at the command line Inside our main function we know the ID of the Tweet we want so we use client tweets findTweetsById to call the GET tweets id API passing in our Tweet ID We could easily choose to use a search API or we could request multiple Tweets at once if we wanted to do so Note that when we make the call we request both the data and the includes since the video information is included under includes where attachments are added in the response We know the parameters we need to get the values so we add those to the request Once the data is returned we can grab just the values we want to show In this example we re using console table to quickly throw the URLs and additional fields into a table but we could choose the handle it differently To debug we can simply dump out the whole JSON format data and includes but that can stay commented out if we are confident with the data format Tweet text biglesp Jolly Device It blinks The module that is…not coded yet Media videoAlt text undefinedViews ┌ー┬ー┬ー┐│ index │bit rate │url │├ー┼ー┼ー┤│ │ │ ││ │ │ ││ │ │ ││ ││ container fmp ││ │ │ │└ー┴ー┴ー┘I didn t add alt text for this video which was not very user friendly of me I ll do better That s it that s the sample We looked at where video information exists in the v API responsewhich API parameters are needed the expansions and fields added to the request there are others to experiment with quickly getting started with the beta Twitter SDK for TypeScriptI ve created a template on Replit that can be forked and modified add a valid BEARER TOKEN value to the project secrets You can also find more examples of using the Twitter SDKs on Replit Hope you found this helpful let us know in the comments 2022-08-15 14:09:00
Apple AppleInsider - Frontpage News Price drop: save $100 on Apple's M2 MacBook Air for a limited time https://appleinsider.com/articles/22/08/15/price-drop-save-100-on-apples-m2-macbook-air-for-a-limited-time?utm_medium=rss Price drop save on Apple x s M MacBook Air for a limited timeApple resellers are engaged in a price war on the MacBook Air just in time for back to school with the standard model dipping to Apple s M MacBook Air has dipped to in with GB of storage Save on Apple s new MacBook Air Read more 2022-08-15 14:34:43
Apple AppleInsider - Frontpage News Apple Watch ECG could be a good early heart attack detection system https://appleinsider.com/articles/22/08/15/apple-watch-ecg-could-be-a-good-early-heart-attack-detection-system?utm_medium=rss Apple Watch ECG could be a good early heart attack detection systemA new research paper suggests that the Apple Watch could serve as an early detection system for a heart attack helping to get people to the hospital sooner Apple Watch ECGResearchers at the Texas Heart Institute have published a new paper in the Texas Heart Institute Journal first spotted by MyHealthyApple detailing their exploration of using an Apple Watch electrocardiogram as an early detection system Read more 2022-08-15 14:25:14
Apple AppleInsider - Frontpage News Rodolfo Castro's loose iPhone called safe at third https://appleinsider.com/articles/22/08/15/rodolfo-castro-and-his-loose-iphone-called-safe-at-third?utm_medium=rss Rodolfo Castro x s loose iPhone called safe at thirdPittsburgh Pirates Rodolfo Castro s iPhone made a surprise appearance during a slide into third firing up accusations of cheating ーbut if they are it isn t making a difference in the standings Castro was sliding onto third base during the Pirates game against the Arizona Diamondbacks on August when the crowd and some of his teammates spotted his iPhone go flying That s a thousand dollars worth of high technology in his pocket and it didn t help his game at all That would be because the Pirates don t need better technology they need better players ーthe Pirates are in last place in the National League Central with wins and losses to date Read more 2022-08-15 14:18:55
海外TECH Engadget Weta Workshop is making its own Lord of the Rings game https://www.engadget.com/lord-of-the-rings-game-weta-workshop-private-division-middle-earth-143616832.html?src=rss Weta Workshop is making its own Lord of the Rings gameWeta Workshop is venturing back to Middle earth It s working on a new Lord of the Rings game alongside publisher Private Division The game is in early development and few details have been announced though the two sides hope to release it in Private Division parent Take Two s fiscal year which ends in March Under its deal with Middle earth Enterprises Weta Workshop has quot the broadest creative license to interpret the underlying lore of the books quot according to a press release “It s a privilege to create a new game set in Middle earth especially one that s so different from what fans have played previously Weta Workshop s head of interactive Amie Wolken said “As fans ourselves we re excited for gamers to explore Middle earth in a way they never have before and introduce new fans to the magic of The Lord of the Rings There have been dozens of Lord of the Rings games over the years so it will be interesting to see what kind of fresh spin Weta Workshop is planning Of course Weta Workshop has a ton of experience in this domain It worked on Peter Jackson s The Lord of the Rings movies as well as The Hobbit trilogy The special effects powerhouse which set up a gaming division in is also collaborating with Amazon on The Lord of the Rings The Rings of Power Private Division meanwhile has recently published games like The Outer Worlds OlliOlli World nbsp and Rollerdrome nbsp which is out this week This is not the only Lord of the Rings game that s in the pipeline The Lord of the Rings Gollum had been expected to arrive in early September but Daedalic Entertainment and Nacon recently delayed it quot by a few months quot 2022-08-15 14:36:16
海外TECH Engadget TikTok adds an AI image generator, but it's no DALL-E https://www.engadget.com/tiktok-ai-text-to-image-generator-142534525.html?src=rss TikTok adds an AI image generator but it x s no DALL EYou don t need to fire up DALL E if you want AI to create images from text ーyou just need a popular social media app The Vergenotes TikTok has introduced a rudimentary quot AI greenscreen quot effect in its Android and iOS apps that turns your text descriptions into artwork It s much simpler than OpenAI s DALL E producing abstract blobs rather than photorealistic depictions but it might do the trick if you want an original background for your latest video As The Verge explains though there may be strong reasons to limit the AI generator s capabilities Even if the required computational power isn t a problem the potential output might be Right now attempts to generate sexual or violent images fizzle out They may be relevant to your keywords but they aren t explicit That could help creators avoid bans and spare TikTok any further legal scrutiny If nothing else the effect makes AI image generation much more accessible Experimental tools like DALL E are still limited to a select group TikTok meanwhile has over billion monthly users ーwhile few of them are likely to ever use AI generated art the addition brings the technology to a much wider audience Don t be shocked if there are similar implementations elsewhere 2022-08-15 14:25:34
海外TECH Engadget Samsung's 55-inch Odyssey Ark: Taking gaming monitors to a whole new dimension https://www.engadget.com/samsung-odyssey-ark-hands-on-specs-price-taking-gaming-monitors-to-a-whole-new-dimension-140056568.html?src=rss Samsung x s inch Odyssey Ark Taking gaming monitors to a whole new dimension has been a great year for monitors We ve already gotten the world s first QD OLED monitor from Alienware with another on the way from MSI And earlier this summer Sony joined the fray with its new Inzone brand of gaming hardware But now Samsung is taking things to a whole new level with the Odyssey Ark Boasting a huge quantum mini LED panel with a R curve the Ark delivers an immersive experience with great visuals and surprisingly good sound Not only does Samsung claim that the Ark is the world s first inch monitor with a K resolution Hz refresh rate and a ms response time you also get support for HDR and Dolby Atmos audio And while the sound on many monitors is often an afterthought assuming they can even output anything at all the Ark features a total of six speakers one in each corner and two woofers in back And when combined Samsung says the Ark s speakers were designed to create a dome of sound And now after getting the chance to check this thing out in person I can say this monitor is unlike anything else on the market Even compared to other ultrawide displays the Ark s dimensions allow it to wrap around you like some sort of high tech cocoon Colors are rich and thanks to its matte finish you don t have to worry about reflections ruining your graphics The monitor also supports AMD FreeSync Premium Pro for VRR so you can get the best performance regardless if you re gaming on a console or a PC And while you won t see pure blacks like you would with an OLED display Samsung says the Ark s contrast is times better than its previous gen monitors Meanwhile to make controlling the Ark easy Samsung includes not one but two remotes both of which have built in solar panels so you don t have to worry about keeping them charged The first remote is similar to what you d get with a TV but the one that feels a bit more special is the wireless Ark Dial It lets you quickly change video settings adjust volume and switch between the monitor s special display modes It s super easy to use and best of all it means you don t have to reach around back and fumble with hidden buttons or a joystick like you do with a lot of rival monitors Sam Rutherford EngadgetThe best thing about the Ark is all the modes and features Samsung included to help you get the most out of this giant panel First there s Flex Move Screen which allows you to adjust the size of your content and move it around you know in case you don t need the Ark s full inches There s also Samsung s Gaming Hub which supports game streaming platforms like NVIDIA GeForce Now Xbox Cloud Gaming and Google Stadia natively You even get RGB lighting on the back not that you can really see it with so muchscreen between you and the rear of the display But my favorite thing is the Multi View mode which lets you have up to three different apps open at once including the ability to move and resize windows however you like That means you can game while having a movie and social media on the side or you can double up by having two games open plus YouTube or basically anything in between And if there s a layout you particularly like you can save that arrangement so next time you can open everything up with a single press The one caveat is that due to a limitation of HDMI you can only display content from the Ark s built in apps and one external device at the same time So while you can have a console and a PC plugged in at the same time thanks to support for four HDMI ports all of which are HDMI you can t output content from both simultaneously Finally there s the Ark s special move which is being able to rotate into portrait orientation or as Samsung calls it Cockpit mode You still get support for all of the monitor s features like Multi View and Flex Move but now on a display that curves up and over your head And you know what it really does feel like you re sitting in the pilot s seat on a plane My only regret is that I wish I could have installed a shoot em up like Ikaruga so I could really take advantage of the Ark s verticality in Cockpit mode And if you want a huge new display but don t have a ton of desk space Samsung even includes a VESA wall mount in the box That said starting at the Odyssey Ark is a big financial commitment for anyone But if none of the other monitors released this year are big enough for you Samsung s new flagship gaming monitor could be the massive centerpiece your home battle station needs Pre orders for the Odyssey Ark start today and when combined with reservation discounts potential customers can save up to before sales officially go live sometime in early September 2022-08-15 14:00:56
海外科学 NYT > Science U.K. Approves Covid Booster Vaccine That Targets Two Variants https://www.nytimes.com/2022/08/15/health/uk-covid-booster-variants.html U K Approves Covid Booster Vaccine That Targets Two VariantsBritain is the first country to approve the Moderna made vaccine which generated a strong immune response against both the original virus and the Omicron variant 2022-08-15 14:36:00
金融 RSS FILE - 日本証券業協会 株式投資型クラウドファンディングの統計情報・取扱状況 https://www.jsda.or.jp/shiryoshitsu/toukei/kabucrowdfunding/index.html 株式投資 2022-08-15 15:30:00
金融 RSS FILE - 日本証券業協会 J-IRISS https://www.jsda.or.jp/anshin/j-iriss/index.html iriss 2022-08-15 14:10:00
ニュース @日本経済新聞 電子版 NYダウ、反落で始まる 中国景気に懸念も下値堅く https://t.co/jNpSyIVTLS https://twitter.com/nikkei/statuses/1559181543318650881 景気 2022-08-15 14:13:42
ニュース BBC News - Home Covid: UK first country to approve dual-strain vaccine https://www.bbc.co.uk/news/health-62548336?at_medium=RSS&at_campaign=KARANGA omicron 2022-08-15 14:20:39
ニュース BBC News - Home Monkeypox: Lack of vaccines sparks pause in UK rollout https://www.bbc.co.uk/news/uk-62551821?at_medium=RSS&at_campaign=KARANGA august 2022-08-15 14:26:21
ニュース BBC News - Home Benjamin Mendy: Women 'disposable' to 'predator' footballer, jury told https://www.bbc.co.uk/news/uk-england-manchester-62548845?at_medium=RSS&at_campaign=KARANGA mansion 2022-08-15 14:47:27
ニュース BBC News - Home Kenya election result delayed amid drama https://www.bbc.co.uk/news/world-africa-62554210?at_medium=RSS&at_campaign=KARANGA commission 2022-08-15 14:51:53
ニュース BBC News - Home Egan Bernal: Ineos Grenadiers rider to return at Tour of Denmark seven months after crash https://www.bbc.co.uk/sport/cycling/62552797?at_medium=RSS&at_campaign=KARANGA Egan Bernal Ineos Grenadiers rider to return at Tour of Denmark seven months after crashFormer Tour de France champion Egan Bernal will return to racing at the Tour of Denmark seven months after he suffered a near fatal crash 2022-08-15 14:11:33
北海道 北海道新聞 英、2価ワクチンを世界で初承認 オミクロン株対応 https://www.hokkaido-np.co.jp/article/718107/ 規制 2022-08-15 23:25:51
北海道 北海道新聞 ドイツ軍戦闘機、太平洋へ初派遣 豪で演習、9月に日本へ https://www.hokkaido-np.co.jp/article/718110/ 演習 2022-08-15 23:37:00
北海道 北海道新聞 デジタル田園都市国家構想 道-首都圏の海底ケーブルに補助金出ず 懸念強める鈴木知事 https://www.hokkaido-np.co.jp/article/718094/ 岸田文雄 2022-08-15 23:32:21
北海道 北海道新聞 NY株、もみ合い https://www.hokkaido-np.co.jp/article/718109/ 週明け 2022-08-15 23:32:00
北海道 北海道新聞 「ゴールデンカムイ」効果で来場者増 五稜郭跡の兵糧庫特別公開 https://www.hokkaido-np.co.jp/article/718045/ 特別公開 2022-08-15 23:20:43
北海道 北海道新聞 大幅定員割れで学部新設認めず 規制強化へ、文科省 https://www.hokkaido-np.co.jp/article/718106/ 定員割れ 2022-08-15 23:11:00
北海道 北海道新聞 Fガール、ほんべつ夏まつりに登場 きつねダンスに大喜び https://www.hokkaido-np.co.jp/article/717933/ 夏まつり 2022-08-15 23:06:38

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)