投稿時間:2022-10-24 07:12:39 RSSフィード2022-10-24 07:00 分まとめ(13件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
IT ビジネス+IT 最新ニュース 老舗ファイザーと新興モデルナ、ワクチンで注目の両社はこんなにも「正反対」だった https://www.sbbit.jp/article/cont1/96728?ref=rss 老舗ファイザーと新興モデルナ、ワクチンで注目の両社はこんなにも「正反対」だったCOVIDの感染拡大ではmRNAワクチンの開発が世界で注目された。 2022-10-24 06:10:00
技術ブログ Developers.IO [Gather.town]参加者全員に祝福してもらう方法 https://dev.classmethod.jp/articles/gather-town-all-blessing/ gathertown 2022-10-23 21:45:17
海外TECH DEV Community Processing user input in Bubble Tea with a menu component https://dev.to/andyhaskell/processing-user-input-in-bubble-tea-with-a-menu-component-222i Processing user input in Bubble Tea with a menu componentIn the last tutorial we did a hello world app and it processed just a bit of user input press Ctrl C to exit But we didn t really get a feel for actually using user input to change the model s data and in turn change what we see in the app So in this tutorial we re going to create a menu component that lets us move between buttons Defining our dataThe first thing we need for any Bubble Tea component is the data our model is in charge of If you recall in our simplePage model the data was just the text we were displaying type simplePage struct text string In our menu what we need to do is Display our optionsShow which option is selectedAdditionally let the user press the enter to go to another page But we ll add that in a later tutorial For now we can still make an onPress function passed in that tells us what we do if the user presses enter So our model s data will look like this if you re following along write this in a file named menu go type menu struct options menuItem selectedIndex int type menuItem struct text string onPress func tea Msg A menu is made up of menuItems and each menuItem has text and a function handling pressing enter In this tutorial we ll just have the app toggle between all caps and all lowercase so it s at least doing something It returns a tea Msg because that s we re able to change the data in response to this user input We ll see why in the next section when we re implementing the Model interface 🧋Implementing the Model interfaceIf you recall for us to use our model as a UI component it needs to implement this interface type Model interface Init Cmd Update msg Msg Model Cmd View string First let s write the Init function func m menu Init tea Cmd return nil Again we still don t have any initial Cmd we need to run so we can just return nil For the View function let s make an old school menu with an arrow to tell us which item is currently selected func m menu View string var options string for i o range m options if i m selectedIndex options append options fmt Sprintf gt s o text else options append options fmt Sprintf s o text return fmt Sprintf sPress enter return to select a list item arrow keys to move or Ctrl C to exit strings Join options n As mentioned in the last tutorial one of the things that makes Bubble Tea really learnable is that the display for your UI is basically one big string So in menu View we make a slice of strings where the selected option has an arrow and the non selected options have leading spaces Then we join them all together and add our contols to the bottom Finally let s write our Update method to handle user input func m menu Update msg tea Msg tea Model tea Cmd switch msg type case tea KeyMsg switch msg tea KeyMsg String case ctrl c return m tea Quit case down right up left return m moveCursor msg tea KeyMsg nil return m nil func m menu moveCursor msg tea KeyMsg menu switch msg String case up left m selectedIndex case down right m selectedIndex default do nothing optCount len m options m selectedIndex m selectedIndex optCount optCount return m The Update method is the most complex part of this app so let s break that down case ctrl c return m tea QuitLike before we re handling the KeyMsg type and we re the Ctrl C keypress to quit the app by returning the Quit cmd case down right up left return m moveCursor msg tea KeyMsg nilFor the arrow keys though we use a helper function moveCursor which returns an updated model func m menu moveCursor msg tea KeyMsg menu switch msg String case up left m selectedIndex case down right m selectedIndex default do nothing optCount len m options m selectedIndex m selectedIndex optCount optCount return m The up and left KeyMsg strings serve as our navigate up keys and the down and right ones navigate us down decrementing and incrementing m selected Then we use the mod operator to ensure that m selected is one of the indices of our options Finally with the model updated moveCursor returns the model that in turn is returned by Update and the new model ultimately gets processed by our View method Before we move on to processing the enter key though we should see our app run So let s put our new menu component into a main function and run it func main m menu options menuItem menuItem text new check in onPress func tea Msg return struct menuItem text view check ins onPress func tea Msg return struct p tea NewProgram m if err p Start err nil panic err For now onPress is just a no op that returns an empty struct Now let s run our app go build check insYou should see something like this Cool Now the menu can toggle what s selected Now let s handle that user input Handling the enter key and seeing what the tea Cmd type actually doesSo far we haven t really taken a close look at the tea Cmd type It s one of the two return values for the Update method but we ve only used it so far to exit the app Let s take a closer look at its type signature type Cmd func tea MsgA Cmd is some sort of function that does some stuff and then gives us back a tea Msg That function can be time passing it can be I O like retrieving some data really anything goes The tea Msg in turn gets used by our Update function to update our model and finally our view So handling a user pressing the enter key and then running an arbitrary onPress function is one such way to use a Cmd So let s start with an enter button handler case tea KeyMsg switch msg tea KeyMsg String case q return m tea Quit case down right up left return m moveCursor msg tea KeyMsg nil case enter return return m m options m selectedIndex onPress Notice that when the user presses enter we return the model unchanged but we also return the selected item s onPress function If you recall when we defined the menuItem type the type of its onPress field was func tea Msg In other words that exactly matches the Cmd type alias There s one other thing we need to do inside the Update method though Right now we re only handling the tea KeyMsg type The type we re returning for toggling the selected item s capitalization will be a brand new type ot tea Msg so we need to define it and then add a case to our Update method for it First let s define the struct type toggleCasingMsg struct We don t need any data to be passed in so our Msg is just an empty struct if you recall the tea Msg type is just an empty interface so we can have a Msg contain as much or as little data as we need Now back in the Update method let s add a case for toggleCasingMsg First add the method toggleSelectedItemCasefunc m menu toggleSelectedItemCase tea Model selectedText m options m selectedIndex text if selectedText strings ToUpper selectedText m options m selectedIndex text strings ToLower selectedText else m options m selectedIndex text strings ToUpper selectedText return m Then add it to the Update method func m menu Update msg tea Msg tea Model tea Cmd switch msg type case toggleCasingMsg return m toggleSelectedItemCase nil case tea KeyMsg our KeyMsg handlers hereOn a toggleCasingMsg we update the casing of the selected menu item and then return the updated model Finally in app go let s use our toggleCasingMsg menuItem text new check in onPress func tea Msg return struct onPress func tea Msg return toggleCasingMsg menuItem text view check ins onPress func tea Msg return struct onPress func tea Msg return toggleCasingMsg Now let s try our app out go build check insThe app should now look like this Note by the way that at this stage of the app this isn t the only way we could have processed enter we also could have just processed all the toggling entirely in the update function rather than having to process it with a Cmd The reason I chose to use a Cmd were To show a simple use case for a non Quit Cmd in Bubble TeaBy using a Cmd we can pass arbitrary event handler functions into our components a similar pattern if you ve coded in React Next up we ve got a menu but it s not very flashy just yet In the next tutorial we ll see how to use Bubble Tea to make our app look cool first by hand then with Bubble Tea s CSS like Lip Gloss package 2022-10-23 21:25:24
海外TECH DEV Community Intro to Bubble Tea in Go https://dev.to/andyhaskell/intro-to-bubble-tea-in-go-21lg Intro to Bubble Tea in GoDoing stuff in the command line is cool and can make you feel like you re the hero in a hacker movie But it can also feel old school with monochromatic avalanches of text or intimidating with all the command line flags and dollar sign prefixes and different ways to break things without warning But the command line isn t the only way to use your terminal there s also TUIs terminal user interfaces which give a more user friendly feel to your program I really like TUIs because they feel like the new and the old at the same time And in Go lately the Bubble Tea library and all of Charm Bracelet s other tools has been getting a lot of attention for making it easy to make TUIs The advantages of Bubble Tea that have jumped out at me so far are Uses the Elm architecture that s shared with browser UI frameworks so if you ve already done some React Vue or Elm it will feel familiarThe Elm architecture isn t just familiar for modern frontend devs it s a great way to organize UI code so it s conducive to building starting your app simple and growing its logic in a manageable wayBecause it s in Go the language s consistent syntax is conducive to learning by reading other people s codeIn this series I m going to be building a basic TUI app from the ground up for logging what you ve been learning in code each day if you re doing a program like Devs or one of the ones in the DaysOfCode family At the time I m writing this it s not finished yet so each tutorial will be about looking at specific concepts The approximate roadmap is going to be Writing a simple hello world app and seeing how its architecture worksBuilding our first real Bubble Tea component a menuMaking our menu look cool with some styling using the CSS like Lipgloss libraryAdding routing to our app to display different pages🫧Using Bubble Tea components other people have made using the Bubbles librarySaving our check ins to a JSON fileSo get your terminal ready and a boba sized straw because without further ado it s time to jump into Bubble Tea Writing our first basic appAs a first step we re going to make a hello world app in Bubble Tea that you exit by pressing Ctrl C which will also introduce us to each part of a Bubble Tea app First in a new directory titled code journal run go mod initgo get github com charmbracelet bubbleteaThen create a file called app go and add the following code package mainimport tea github com charmbracelet bubbletea func main p tea NewProgram newSimplePage This app is under construction if err p Start err nil panic err Then let s make another file called simple page go that contains our first UI a simple page that just displays some text package mainimport fmt strings tea github com charmbracelet bubbletea MODEL DATAtype simplePage struct text string func newSimplePage text string simplePage return simplePage text text func s simplePage Init tea Cmd return nil VIEWfunc s simplePage View string textLen len s text topAndBottomBar strings Repeat textLen return fmt Sprintf s n s n s n nPress Ctrl C to exit topAndBottomBar s text topAndBottomBar UPDATEfunc s simplePage Update msg tea Msg tea Model tea Cmd switch msg type case tea KeyMsg switch msg tea KeyMsg String case ctrl c return s tea Quit return s nil Before we break down the code let s run it and see what it does In your terminal run go build code journaland you should see something like this Cool You ve got your first Bubble Tea app running Now let s take a closer look at the code 🧋Model is the main interface of Bubble TeaThe main function starts the program by creating a new program with the simplePage model func main p tea NewProgram newSimplePage This app is under construction if err p Start err nil panic err We call tea NewProgram whose signature is func NewProgram initialModel Model Programand then calling that program s Start method starts our app But what is the initialModel Model is the main interface of Bubble Tea It has three methods type Model interface Init Cmd Update msg Msg Model Cmd View string The Init method is called when the app starts returning a tea Cmd A Cmd is more or less stuff happening behind the scenes like loading data or time flowing But for the current tutorial we don t have any background stuff so our init method just returns nil func s simplePage Init tea Cmd return nil Next up we ve got the View method One of the cool abstractions of Bubble Tea is that your whole UI s display is a string And View is where you make that string func s simplePage View string textLen len s text topAndBottomBar strings Repeat textLen return fmt Sprintf s n s n s n nPress Ctrl C to exit topAndBottomBar s text topAndBottomBar So we put the text of our simplePage in a box made of asterisks with a message at the bottom saying Press Ctrl C to exit But we can t exit our app if it doesn t handle user input so that s where our Update method comes in func s simplePage Update msg tea Msg tea Model tea Cmd switch msg type case tea KeyMsg switch msg tea KeyMsg String case ctrl c return s tea Quit return s nil The Update method takes in a tea Msg and returns a new tea Model and sometimes a tea Cmd like if an action results in retrieving some data or a timer going off A tea Msg s type signature istype Msg interface So it can be any type and carry as much or as little data as you need It s sort of like a browser event in JavaScript if you ve done frontend there a timer event doesn t carry any data a click event tells you what clicked on etc The kind of message we re processing is tea KeyMsg which represents keyboard input We re checking if the user pressed Ctrl C and if so we return the tea Quit command which is of the type tea Cmd and tells Bubble Tea to exit the app For any other kind of input though we don t do anything We just return the model as is If we were doing something though like UI navigation though we would change some fields on the Model and then return it causing the UI to update And that s what we re going to see in the next tutorial where we make a menu component 2022-10-23 21:23:52
海外TECH Engadget Apple’s next Mac Pro could feature an M2 chip with up to 48 CPU cores https://www.engadget.com/apple-mac-pro-m2-ultra-extreme-report-215731047.html?src=rss Apple s next Mac Pro could feature an M chip with up to CPU coresAmong the new computers Apple plans to announce in the coming months is an M variant of the Mac Pro according to Bloomberg s Mark Gurman Writing in his latest Power On newsletter Gurman reports the company has been testing a version of its high end desktop that features a chipset with a core CPU and core GPU as well as GB of memory He predicts Apple will ultimately let customers choose between two different chipsets when configuring the Mac Pro For the moment Gurman has taken to calling those the “M Ultra and “M Extreme “My belief is that the Mac Pro will be offered with options for and CPU cores and and graphics cores ーalong with up to gigabytes of memory he writes Gurman adds those chips will be “at least twice or four times as powerful as the M Max a processor Apple has yet to announce To put those core counts in perspective the base M features CPU cores and GPU cores Meanwhile the unannounced M Max is expected to feature CPU cores and GPU cores Before the new Mac Pro arrives Gurman expects Apple to announce updated versions of the and inch MacBook Pro as well as a new Mac mini According to him Apple s latest high end laptops will feature the company s new M Pro and M Max chips while the Mac mini will ship with the same M silicon found in its MacBook Air Gurman notes Apple has also internally tested an M Pro variant of the Mac mini though he doesn t mention if the company plans to release that version of the computer Those devices should arrive sometime in the coming months 2022-10-23 21:57:31
ニュース BBC News - Home Standing not the right thing to do, says Johnson https://www.bbc.co.uk/news/uk-politics-63368396?at_medium=RSS&at_campaign=KARANGA right 2022-10-23 21:38:23
ニュース BBC News - Home How many backers do Rishi Sunak and Penny Mordaunt have? https://www.bbc.co.uk/news/uk-politics-63343308?at_medium=RSS&at_campaign=KARANGA minister 2022-10-23 21:33:02
ニュース BBC News - Home ‘Newcastle starting to upset the big boys’ - Alan Shearer on Magpies' top-four hopes & win at Spurs https://www.bbc.co.uk/sport/football/63366602?at_medium=RSS&at_campaign=KARANGA Newcastle starting to upset the big boys Alan Shearer on Magpies x top four hopes amp win at SpursMatch of the Day pundit Alan Shearer was not expecting his old side Newcastle to be in the Premier League top four after games but says their results show they mean business 2022-10-23 21:13:47
ニュース BBC News - Home Tottenham manager Antonio Conte calls for ‘money’,’time’ and ‘patience’ – but did VAR let Spurs down? https://www.bbc.co.uk/sport/football/63368417?at_medium=RSS&at_campaign=KARANGA Tottenham manager Antonio Conte calls for money time and patience but did VAR let Spurs down Tottenham boss Antonio Conte says Spurs need time and patience and also for sure money after suffering a third defeat in five Premier League games 2022-10-23 21:11:06
北海道 北海道新聞 ジョンソン氏、不出馬表明 英与党党首選 https://www.hokkaido-np.co.jp/article/749781/ 首相 2022-10-24 06:12:00
北海道 北海道新聞 タリバン、日本大使館再開を歓迎 内相、岡田大使と会談 https://www.hokkaido-np.co.jp/article/749780/ 日本大使館 2022-10-24 06:02:00
ビジネス 東洋経済オンライン 「AI契約チェックは違法の疑い」の衝撃的な中身 法務省判断は急成長のリーガルテックに激震 | 最新の週刊東洋経済 | 東洋経済オンライン https://toyokeizai.net/articles/-/627571?utm_source=rss&utm_medium=http&utm_campaign=link_back 東洋経済オンライン 2022-10-24 06:30:00
海外TECH reddit Post-Race Discussion Thread: NCS Dixie Vodka 400 at Homestead-Miami Speedway https://www.reddit.com/r/NASCAR/comments/ybu3n0/postrace_discussion_thread_ncs_dixie_vodka_400_at/ Post Race Discussion Thread NCS Dixie Vodka at Homestead Miami SpeedwayPlease post all post race responses and congratulatory remarks in this thread rather than creating a separate post to avoid a bulk of repeated information in the subreddit Race Center at NASCAR com Post Race Press Conference at NASCAR com Support NASCARThreadBot an automated bot maintained by XFile submitted by u NASCARThreadBot to r NASCAR link comments 2022-10-23 21:55:09

コメント

このブログの人気の投稿

投稿時間:2021-06-17 22:08:45 RSSフィード2021-06-17 22:00 分まとめ(2089件)

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

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