IT |
気になる、記になる… |
Nothingの新型ワイヤレスイヤホン「Ear (2)」の新たな製品画像や新機能などの情報が明らかに |
https://taisy0.com/2023/01/31/167850.html
|
nothing |
2023-01-31 13:29:45 |
AWS |
AWS Government, Education, and Nonprofits Blog |
AWS announces 2023 AWS Space Accelerator to advance global space sustainability |
https://aws.amazon.com/blogs/publicsector/aws-announces-2023-space-accelerator-advance-global-space-sustainability/
|
AWS announces AWS Space Accelerator to advance global space sustainabilityNow in its third year the AWS Space Accelerator is a hybrid technical business and mentorship opportunity open to space startups from around the globe who are looking to power their space missions using AWS In the AWS Space Accelerator will call on teams and resources across Amazon to help emerging startups focus on cloud powered solutions that support the use of space as a sustainable and usable environment for years to come as well as solutions that positively impact life on Earth The application period for the AWS Space Accelerator opens today with proposals due by March |
2023-01-31 13:58:16 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
機械学習初心者におすすめなkaggleの表形式データセットを調査してみた |
https://qiita.com/daifukusan/items/b98f20a79dbd0b83853e
|
titanicirisbostonh |
2023-01-31 22:31:51 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
Django から S3 へ画像をアップロードする Example |
https://qiita.com/takux/items/06115e9b1e4d1d055dde
|
django |
2023-01-31 22:29:00 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
Atcoder ABC-267 C問題、D問題解説 [Python] |
https://qiita.com/Rasukaru-raccoon/items/0f24f7d70dfca72c2020
|
atcoder |
2023-01-31 22:10:16 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
オープンソースAI【Whisper、GPT3、GoogleTextToSpeech】を用いた音声対話ロボットの作成 |
https://qiita.com/KENTAROSZK/items/fda5bb3d1fba4b454450
|
googlecolab |
2023-01-31 22:03:39 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
Ruby timesメソッドで繰り返し処理を行う |
https://qiita.com/ta--i/items/63b822aaa61dd92450c6
|
timesdoend |
2023-01-31 22:03:52 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
CloudFormationの長所・短所と備忘録的Tips |
https://qiita.com/sandy-sunday/items/0476f094c1ab54b93df3
|
cloudformation |
2023-01-31 22:52:19 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
AWS: ChatGPT で DynamoDB の UpdateCommand を再学習してみる |
https://qiita.com/baku2san/items/1f72db057887abbfd358
|
timest |
2023-01-31 22:38:59 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
Django から S3 へ画像をアップロードする Example |
https://qiita.com/takux/items/06115e9b1e4d1d055dde
|
django |
2023-01-31 22:29:00 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
stripe(connect)においてプラットフォームで作成したcustomerと支払い情報を連結アカウントに複製・コピーする方法 |
https://qiita.com/TsujiHiroki/items/8172c714aaf3aa8e8cc1
|
substripesubsc |
2023-01-31 22:07:22 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
Ruby timesメソッドで繰り返し処理を行う |
https://qiita.com/ta--i/items/63b822aaa61dd92450c6
|
timesdoend |
2023-01-31 22:03:52 |
技術ブログ |
Developers.IO |
[AWS CDK] Athenaクエリを実行するLambda関数の権限を設定するカスタムConstructを作ってみた |
https://dev.classmethod.jp/articles/aws-cdk-i-made-a-custom-construct-to-set-permissions-for-lambda-functions-that-execute-athena-queries/
|
amazon |
2023-01-31 13:11:23 |
技術ブログ |
Developers.IO |
すべての AWS プリンシパルを信頼ポリシーで許可している IAM ロールが環境にないか確認する |
https://dev.classmethod.jp/articles/trustpolicy-wildcard-check/
|
許可 |
2023-01-31 13:09:40 |
海外TECH |
MakeUseOf |
6 Electric Vehicle Myths That Are Wrong |
https://www.makeuseof.com/electric-vehicle-myths-that-are-wrong/
|
certain |
2023-01-31 13:15:16 |
海外TECH |
DEV Community |
10 Must-Take FREE Google Data Science Courses for 2023 |
https://dev.to/arjuncodess/10-must-take-free-google-data-science-courses-for-2023-45l4
|
Must Take FREE Google Data Science Courses for Many businesses today require Data Science skills and it is a crucial part of many industries As time has gone on businesses have begun to use data science methods to expand their businesses and improve customer satisfaction Here are Data Science Courses with Certifications Online for FREE Data Science FoundationsLink Python Basics for Data AnalysisLink Basics of Machine LearningLink Machine Learning Crash CourseLink Google Analytics for BeginnersLink Google Cloud Computing Foundations Networking and Security in Google Cloud Link Google Cloud Computing Foundations Cloud Computing FundamentalsLink Google Cloud Computing Foundations Data ML and AI in Google Cloud Link Data Science with PythonLink Google Analytics for Power UsersLink |
2023-01-31 13:41:49 |
海外TECH |
DEV Community |
WhatsApp in React Native (part 3) |
https://dev.to/jacksbridger/whatsapp-in-react-native-part-3-1gmf
|
WhatsApp in React Native part Can we use JavaScript to build WhatsApp This is part three of our series on Chat apps In part one we set up a lot of the UI for Whatsapp In part two we setup the backend using Node js Supabase and Socket io Now in part three we re going to make our chat app actually work We ll cover Setting up Redux and Redux PersistGetting and creating data with SupabaseSetting up real time using Socket ioI won t cover every single line of code but if you have any additional questions put them in the comments You can see the full code for the react native app here and the full code for the backend here Setting up Redux and Redux PersistThe first thing we need to do is to set up redux and redux persist Note we were previously using react context but we wanted an easy way to persist state To set up state management and persistence we ll need to add a few dependencies yarn add redux reduxjs toolkit redux persist react native async storage async storageFirst we create our redux store in redux store tsimport configureStore applyMiddleware from reduxjs toolkit import combineReducers from redux import AsyncStorage from react native async storage async storage import persistReducer FLUSH REHYDRATE PAUSE PERSIST PURGE REGISTER from redux persist import conversationsReducer from conversationsReducer import usersReducer from usersReducer const persistConfig key root storage AsyncStorage version const reducer combineReducers conversations conversationsReducer users usersReducer const persistedReducer persistReducer persistConfig reducer export const store configureStore reducer persistedReducer middleware getDefaultMiddleware gt getDefaultMiddleware this checks our state actions for non serializable values e g functions Promises dates serializableCheck ignoredActions FLUSH REHYDRATE PAUSE PERSIST PURGE REGISTER Infer the RootState and AppDispatch types from the store itselfexport type RootState ReturnType lt typeof store getState gt Inferred type posts PostsState comments CommentsState users UsersState export type AppDispatch typeof store dispatch We are using redux toolkit and the main change we made from their quick start guide is using AsyncStorage TypeScript helps you with Redux stateBelow is one of the most useful lines of this tutorial Having a RootState for your redux store is one of the most useful applications of TypeScript and helps out so much when you use useSelector later export type RootState ReturnType lt typeof store getState gt We also combined multiple reducers const reducer combineReducers conversations conversationsReducer users usersReducer And then we make these reducers persistedconst persistedReducer persistReducer persistConfig reducer What is redux persist actually doing The short version It automatically puts your redux store into persistent storage Anything that goes into your redux store your state is saved in a way that will survive them closing the app and reopening it In our case we use react native async storage It works on Android iOS Web MacOS and Windows Where the state is persisted depends on the platform but the below might be helpful Under the hood react native async storage has written native modules that save our state on devices using for example Android SQLiteiOS small values in serialized dictionary and larger values in separate files ReducersSpeaking of reducers let s take a look at our reducers Here s redux conversationsReducer tsimport createSlice from reduxjs toolkit import type PayloadAction from reduxjs toolkit import Conversation Message from types import sortConversations from helpers sortConversations import storage from react native async storage async storage import PURGE from redux persist export interface ConversationState conversations Conversation currentConversation Conversation null const initialState ConversationState conversations currentConversation null export const conversationsSlice createSlice name conversations initialState reducers addAllConversations state ConversationState action PayloadAction lt Conversation gt void gt state conversations sortConversations action payload setCurrentConversation state ConversationState action PayloadAction lt Conversation gt void gt if action payload state currentConversation action payload addNewConversation state ConversationState action PayloadAction lt Conversation gt void gt if action payload const conversationAlreadyExists state conversations find conv gt conv id action payload id if conversationAlreadyExists state conversations sortConversations state conversations action payload markConversationAsRead state ConversationState action PayloadAction lt Conversation gt void gt if action payload const conversationToUpdate state conversations find conversation gt conversation id action payload id if conversationToUpdate conversationToUpdate messages forEach message gt message isRead true sendMessage state ConversationState action PayloadAction lt Message gt void gt const message action payload const conversationToUpdate state conversations find conversation gt conversation id message conversationID if conversationToUpdate conversationToUpdate messages push message if state currentConversation amp amp message conversationID state currentConversation id state currentConversation messages push message state conversations JSON parse JSON stringify sortConversations state conversations extraReducers builder gt builder addCase PURGE state gt storage removeItem persist root Action creators are generated for each case reducer functionexport const addAllConversations sendMessage setCurrentConversation addNewConversation markConversationAsRead conversationsSlice actions export default conversationsSlice reducer We use the createSlice function and pass in the current state and a name as well as the reducers createSlice “automatically generates action creators and action types that correspond to the reducers and state More hereEach of our reducers is modifying our state in a specific type of way For example addAllConversations addAllConversations state ConversationState action PayloadAction lt Conversation gt void gt state conversations sortConversations action payload addAllConversations receives an array of Conversations via our database and then it sorts them and sets the conversations state to be these conversations And here s redux usersReducer tsimport createSlice from reduxjs toolkit import type PayloadAction from reduxjs toolkit import PURGE from redux persist import storage from react native async storage async storage import User from types export interface UserState currentUser User null users User const initialState UserState users currentUser null export const usersSlice createSlice name users initialState reducers addAllUsers state UserState action PayloadAction lt User gt void gt state users action payload setCurrentUser state UserState action PayloadAction lt User gt void gt state currentUser action payload extraReducers builder gt builder addCase PURGE state gt storage removeItem persist root Action creators are generated for each case reducer functionexport const addAllUsers setCurrentUser usersSlice actions export default usersSlice reducer Once we ve setup these three files we can add them to our app in App tsximport SafeAreaProvider from react native safe area context import store from redux store import Provider as ReduxProvider useSelector from react redux import PersistGate from redux persist integration react import persistStore from redux persist import Navigation from navigation const persistor persistStore store use this to clear out all the data persistor purge export default function App return lt ReduxProvider store store gt lt PersistGate persistor persistor gt lt SafeAreaProvider gt lt Navigation gt lt SafeAreaProvider gt lt PersistGate gt lt ReduxProvider gt The main parts here are that we wrap everything inside our ReduxProvider that has access to our store enabling everything inside to access this store And then inside ReduxProvider we wrap everything inside a PersistGate which tells redux persist to save our store our state in a persistent location We are then able to access data from our screens and trigger actions from our screens using useSelector and useDispatch and when the user closes their app they can maintain the state Here is how we get all the conversations data from inside a screen Notice we use RootState from earlier This saves a lot of silly mistakes import useSelector from react redux const conversations useSelector state RootState gt state conversations conversations And here is how we trigger a new conversation to be added in redux import useDispatch from react redux const dispatch useDispatch dispatch sendMessage message Communicating between React Native amp SupabaseLocalhost for my machine and localhost for my simulator are two different things so I like to use ngrok This gives me a live url that effectively puts my localhost online You ll need to setup an account and download ngrok brew install ngrok ngrok ngrokYes it is actually ngrok ngrok ngrok Explainer hereSo when you have Supabase server running on http localhost you can runngrok http Then you get a url like the one highlighted below that you can copy paste and use as the URL for your APIIn my code I save this in constants ngrokURL ts and we should now be able to communicate with Supabase Getting conversation and user data in React NativeHere is how we get conversations from Supabaseimport MyResponse from types import formatConversations from helpers formatConversations import ngrokURL from constants ngrokURL const requestOptions RequestInit method GET redirect follow const baseURL ngrokURL export default async function getAllConversations userID string Promise lt MyResponse gt try const getconversationsURL string baseURL conversations user id userID const response await fetch getconversationsURL requestOptions const result await response json const formattedConversations formatConversations result return data formattedConversations status response status message response statusText catch error let message if error instanceof Error message error message else message String error return data null status message We use this to update our conversations state in redux from App tsxuseEffect gt if currentUser setShowUserDialog true else if currentUser getAllConversations currentUser id then res gt const conversations res data if conversations dispatch addAllConversations conversations Creating conversations and users in React NativeWe create conversations when users click on a person Here s what onPress looks likeconst onPress gt if currentUser const newGroupName user username amp currentUser username createConversation user id currentUser id newGroupName user id then conversation gt const formattedConversation formatConversation conversation dispatch setCurrentConversation formattedConversation dispatch addNewConversation formattedConversation navigation dispatch state gt const routes state routes filter r gt r name CreateNewChat const chatRoute name Chat params conversation formattedConversation path undefined const newRoutes routes chatRoute return CommonActions reset state routes newRoutes index newRoutes length navigation navigate Chat conversation formattedConversation catch err gt console log err We create a conversation then we set the current conversationadd the conversation to our conversations listnavigate to the conversationNavigating to “Chat was interesting At first I straight up navigated with navigation navigate Chat but that meant when you press back you came back to the create conversation screen instead of the home screen It looked a bit weird So we modified the route state so that when you press back from the conversation you go straight back to Chats And here s the API call to create a conversation import ngrokURL from constants ngrokURL const myHeaders new Headers myHeaders append Content Type application json export default async function createConversation participantIDs string groupName string ownerID string const uniqueparticipantIDs new Set participantIDs ownerID const raw JSON stringify owner id ownerID group name groupName participant ids uniqueparticipantIDs const baseURL ngrokURL const createConversationURL string baseURL conversations create const requestOptions RequestInit method POST headers myHeaders body raw redirect follow try const res await fetch createConversationURL requestOptions const data await res json return data catch err console log err Sending a messageHere is the code that executes when a message is sent onPress gt if userID Alert alert user id is null else const message prepMessage newMsg thisConversation id userID setNewMsg isTyping setIsTyping if message addNewMessage message then res gt dispatch sendMessage message We format our message in the correct format Then we make the API call to add a meessage Then we add our message to the conversationHere is the code for our API call to create the message import Message from types import ngrokURL from constants ngrokURL const baseURL ngrokURL const myHeaders new Headers myHeaders append Content Type application json export default async function addNewMessage message Message const addNewMessageURL string baseURL conversations message conversationID messages create const raw JSON stringify user id message userID message message message const requestOptions RequestInit method POST headers myHeaders body raw redirect follow const response await fetch addNewMessageURL requestOptions const res response json return res Creating a new userIn WhatsApp users are linked to phone numbers But in our example we re going to have a simple concept of a user When there is no user stored in redux state we will send a popup modal that asks for a username lt CreateUserDialog visible showUserDialog setShowUserDialog setShowUserDialog gt It will then create a user and set it in redux sate import View from react native import Dialog from react native dialog import React useState from react import useDispatch from react redux import setCurrentUser from redux usersReducer import User from types import createUser from api createUser export default function CreateUserDialog visible setShowUserDialog visible boolean setShowUserDialog vis boolean gt void const dispatch useDispatch const username setUsername useState lt string gt const createUser async gt const user User await createUser username dispatch setCurrentUser user setShowUserDialog false return lt View gt lt Dialog Container visible visible gt lt Dialog Title gt Set name lt Dialog Title gt lt Dialog Input label username onChangeText username string gt setUsername username gt lt Dialog Input gt lt Dialog Button label Create new user onPress createUser gt lt Dialog Container gt lt View gt And here s the API call to Supabase to create a user import ngrokURL from constants ngrokURL import SupabaseUser User from types export default async function createUser username string Promise lt User gt const baseURL ngrokURL const createUserURL string baseURL users create var myHeaders new Headers myHeaders append Content Type application json var raw JSON stringify username var requestOptions RequestInit method POST headers myHeaders body raw redirect follow try const res await fetch createUserURL requestOptions const resjson SupabaseUser await res json const newUser User id resjson id username resjson username createdAt resjson created at if newUser return newUser else throw new Error user not created catch err console log err throw err Real timeSocket io is a technology that easily enables bidirectional communication between client and server For us this means Our client can listen for updates from our server and adjust the stateOur server can listen for updates from our client and adjust our dataFun aside Socket io does not only use WebSockets for communication it first establishes a connection using HTTP long polling transport Then once the connection is established it tries to upgrade to a WebSocket connection The reason it does this is because its not always possible to establish a WebSocket connection because of corporate policies personal firewall etc An unsuccessful WebSocket connection attempt could lead to a second wait from the user s perspective so it s really worth avoiding We need to add socket io to our project yarn add socket io clientWe initialize our socket inside navigation index tsximport io from socket io client import ngrokURL from constants ngrokURL const socket io ngrokURL Then we can join the socket inside our useEffect in navigation index tsxuseEffect gt if currentUser socket emit join id currentUser id username currentUser username created at currentUser createdAt return gt currentUser Our server fires two different events message when a new message is creatednewConversation when a new conversation is created Listening for new conversationsIn the same userEffect we can setup our socket to listen for newConversation event navigation index tsxsocket on newConversation conv SupabaseConversation gt const conversation formatConversation conv dispatch addNewConversation conversation When we are notified about a new conversation event we add it to our conversations state redux conversationsReducer tsaddNewConversation state ConversationState action PayloadAction lt Conversation gt void gt if action payload const conversationAlreadyExists state conversations find conv gt conv id action payload id if conversationAlreadyExists state conversations sortConversations state conversations action payload Listening for new messagesAnd this is how we listen to message inside useEffect navigation index tsxsocket on message message SupabaseMessage gt const newMessage Message id message id message message message conversationID message conversation id userID message users id isRead false time message created at dispatch sendMessage newMessage And we add our message to conversations state as well as the currentConversation if it has been selected sendMessage state ConversationState action PayloadAction lt Message gt void gt const message action payload const conversationToUpdate state conversations find conversation gt conversation id message conversationID if conversationToUpdate conversationToUpdate messages push message if state currentConversation amp amp message conversationID state currentConversation id state currentConversation messages push message state conversations JSON parse JSON stringify sortConversations state conversations And that s it it should all be working for you now Please check out our previous tutorials and if you have questions let me know in the comments Part one WhatsApp UIPart two setting up Supabase backendFull source code |
2023-01-31 13:20:57 |
Apple |
AppleInsider - Frontpage News |
Wedbush calls Cook 'Hall of Fame CEO,' says no layoffs coming |
https://appleinsider.com/articles/23/01/31/wedbush-calls-cook-hall-of-fame-ceo-says-no-layoffs-coming?utm_medium=rss
|
Wedbush calls Cook x Hall of Fame CEO x says no layoffs comingAnalyst Dan Ives says that Apple will not lay off thousands of workers as many Big Tech firms are doing because it is so well run by Tim Cook Apple has made layoffs in its retail chain specifically employees in Best Buy stores It s also cut recruiters but it has so far avoided the mass redundancies that many major technology firms have done Apple never hired at the pace of these other tech giants Wedbush analyst Dan Ives told Yahoo Finance You ll see cost cutting around the edges but Cupertino ーI mean they re tacticians Read more |
2023-01-31 13:23:33 |
Cisco |
Cisco Blog |
Experience Enabled by Technology Turns Customers into Fans |
https://blogs.cisco.com/customerexperience/experience-enabled-by-technology-turns-customers-into-fans
|
Experience Enabled by Technology Turns Customers into FansThere s been a shift in BB where customers now expect BC experience They don t want to feel a difference between the experiences they have on their personal devices and the apps they use for work They want technology to be magically everywhere but unobtrusive It just needs to work without thinking about it |
2023-01-31 13:00:55 |
Cisco |
Cisco Blog |
10 Surprises of Remote Work from Security Engineers |
https://blogs.cisco.com/security/10-surprises-of-remote-work-from-security-engineers
|
cisco |
2023-01-31 13:00:49 |
Cisco |
Cisco Blog |
Speak With Confidence |
https://blogs.cisco.com/wearecisco/speak-with-confidence
|
learning |
2023-01-31 13:00:45 |
金融 |
金融庁ホームページ |
信用格付業者の関係法人の指定に係る金融庁告示(無登録格付の説明事項に係るグループ指定)の一部改正について公表しました。 |
https://www.fsa.go.jp/news/r4/shouken/20230131/20230131_groupshitei.html
|
信用格付業者 |
2023-01-31 14:00:00 |
海外ニュース |
Japan Times latest articles |
Putin’s war in Ukraine pushes ex-Soviet states toward new allies |
https://www.japantimes.co.jp/news/2023/01/31/world/putin-war-ex-soviet-states/
|
Putin s war in Ukraine pushes ex Soviet states toward new alliesOfficials from ex Soviet states in central Asia and the Caucasus say the war has prompted their governments to look for ways to reduce dependence on |
2023-01-31 22:02:33 |
ニュース |
BBC News - Home |
Hillsborough disaster: Families profoundly failed, say police |
https://www.bbc.co.uk/news/uk-england-merseyside-64454778?at_medium=RSS&at_campaign=KARANGA
|
critical |
2023-01-31 13:10:49 |
ニュース |
BBC News - Home |
Secretive Saudi executions leave families in the dark |
https://www.bbc.co.uk/news/world-middle-east-64338876?at_medium=RSS&at_campaign=KARANGA
|
saudi |
2023-01-31 13:00:46 |
ニュース |
BBC News - Home |
Man admits killing Bennylyn and Jellica Burke at his Dundee home |
https://www.bbc.co.uk/news/uk-scotland-tayside-central-64424265?at_medium=RSS&at_campaign=KARANGA
|
burke |
2023-01-31 13:18:11 |
ニュース |
BBC News - Home |
Sam Smith: What's behind I'm Not Here to Make Friends backlash? |
https://www.bbc.co.uk/news/newsbeat-64451510?at_medium=RSS&at_campaign=KARANGA
|
double |
2023-01-31 13:40:32 |
コメント
コメントを投稿