投稿時間:2021-12-07 02:36:55 RSSフィード2021-12-07 02:00 分まとめ(42件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
IT 気になる、記になる… iPhone/iPad、本日よりヘッドフォンボタンからのGoogleアシスタントの呼出や着信の音声通知が利用不可に https://taisy0.com/2021/12/07/149458.html google 2021-12-06 16:21:58
AWS AWS Architecture Blog Use a City Planning Analogy to Visualize and Create your Cloud Architecture https://aws.amazon.com/blogs/architecture/use-a-city-planning-analogy-to-visualize-and-create-your-cloud-architecture/ Use a City Planning Analogy to Visualize and Create your Cloud ArchitectureIf you are new to creating cloud architectures you might find it a daunting undertaking However there is an approach that can help you define a cloud architecture pattern by using a similar construct In this blog post I will show you how to envision your cloud architecture using this structured and simplified approach Such … 2021-12-06 16:00:13
AWS AWS Machine Learning Blog AWS computer vision and Amazon Rekognition: AWS recognized as an IDC MarketScape Leader in Asia Pacific (excluding Japan), up to 38% price cut, and major new features https://aws.amazon.com/blogs/machine-learning/aws-computer-vision-and-amazon-rekognition-aws-recognized-as-an-idc-marketscape-leader-in-asia-pacific-excluding-japan-up-to-38-price-cut-and-major-new-features/ AWS computer vision and Amazon Rekognition AWS recognized as an IDC MarketScape Leader in Asia Pacific excluding Japan up to price cut and major new featuresComputer vision the automatic recognition and description of documents images and videos has far reaching applications from identifying defects in high speed assembly lines to intelligently automating document processing workflows and identifying products and people in social media AWS computer vision services including Amazon Lookout for Vision AWS Panorama Amazon Rekognition and Amazon Textract help developers automate … 2021-12-06 16:17:26
AWS AWS Government, Education, and Nonprofits Blog Announcing second AWS Top Secret Region, extending support for US government classified missions https://aws.amazon.com/blogs/publicsector/announcing-second-aws-top-secret-region-extending-support-us-government-classified-missions/ Announcing second AWS Top Secret Region extending support for US government classified missionsAWS Top Secret West is accredited to operate workloads at the Top Secret U S security classification level The new Region adds multiple Availability Zones geographically separated from AWS Top Secret East With two Top Secret Regions customers in the U S defense intelligence and national security communities can deploy multi Region architectures to achieve the highest levels of resiliency and availability essential to their most critical national security missions 2021-12-06 16:56:19
Google Official Google Blog 7 apps we couldn’t live without in 2021 https://blog.google/products/chromebooks/2021-favorite-apps/ apps we couldn t live without in As draws to a close our Chromebook Apps team is taking the time to reflect on all the ways Chromebooks have helped us tackle another year of doing just about everything from home This year we re starting a new tradition sharing a few of the many apps we couldn t live without from our team to you Designing holiday cardsPixlr Tis the season to create memories that bring smiles to friends and family But capturing a photo of my family of five including toddlers is no small feat Pixlr lets you edit photos and create great designs right in your browser I combined a few photos into one to give the appearance of a calm and serene group while giving the background a perfect blur Maria Lundahl Schmidt Chrome OS Apps PartnershipsMaria s family holiday card created with PixlrStaying entertained with Cloud gamingStadia Gaming played a crucial role in keeping me entertained and sane in This year I have been all about cloud gaming and Celeste is the first game that sold me Latency was my main hesitation with cloud gaming so I put it to the test with a pixel perfect platformer I had played Celeste locally so I knew that any delay in responsiveness would render one of my favorite indie games unplayable To my delight I didn t notice any lag when playing on Stadia Sam Richard Chrome OS Developer AdvocateNvidia GeForce NOW And for those looking for a new game that can show off the graphical capabilities of cloud gaming be sure to check out Marvel s Guardians of the Galaxy on NVIDIA GeForce NOW RTX support means it can be played with beautifully ray traced graphics available on Chromebooks that support K turning your Chromebook into the ultimate high fidelity gaming rig Greg Nemeth Chrome OS Games PartnershipsPainting with my kids during shelter in placeKrita Sheltering in place in a cabin outside of Sweden has given my family some extra time to embrace our creative side Krita which is in beta has been an amazing tool for us and we have been able to create a plethora of princesses unicorns and cat like creatures Krita is designed primarily for digital painting and D animation it is open source and completely free of charge The name Krita is inspired by the Swedish words krita meaning crayon and rita which means to draw so it made perfect sense for us to use this wonderful tool for digital artists Maria Lundahl Schmidt Chrome OS Apps PartnershipsConnecting virtually with family and friendsRave When my kids are asleep I use Rave a watch party app with my friends to text and voice message while binging Netflix and watching YouTube videos together We even hosted a few karaoke nights with our friends who live outside of California It became the weekend highlight for us Sanj Nathwani Chrome OS Product ManagerZoom Making sure my and year olds and I can spend virtual time with our loved ones has been important for my family Zoom s new progressive web app PWA for Chromebooks makes it incredibly easy to join any call with a single click It works in Chrome browser on any operating system ーso I never need to worry about whether my friends or family will be able to access a group meeting James Wagner Chrome OS Apps Program ManagerUnleashing my creative sideSumo One of my resolutions this year was to get into painting again When I started using the web based app Sumopaint it was impossible to miss the other tools they have ーlike making music D modeling coding or editing photos and videos My favorite part how easy everything was to learn and how you can share assets between apps in the suite through a common asset library Neel Kshetramade Chrome OS Apps Program ManagerPainting by Neel s daughter created using SumopaintHopefully you ll have some down time over the holidays Some of the ways my team plans to spend that time is watching their favorite holiday movies ーlike Home Alone or The Nightmare Before Christmas on Disney or learning to code as a family with Piper Make or making music with Cubasis s custom Chromebooks app We hope you and your family enjoy these apps as much as we do Give them a spin during the holidays Be sure to check out the Perks page to find special offers on some great apps ーcreated exclusively for Chromebooks 2021-12-06 16:30:00
python Pythonタグが付けられた新着投稿 - Qiita Pythonでemailを送信する 【htmlもファイル添付もEmailMessageのみで十分ですよ!!】 https://qiita.com/tarao1006/items/d257299e3d202fbf4460 Pythonでemailを送信する【htmlもファイル添付もEmailMessageのみで十分ですよ】はじめにPythonでemailを送信する方法を説明する記事はたくさんありますが、ほとんどというか全ての記事でMIMETextおよびMIMEMultipartを使用した例が紹介されています。 2021-12-07 01:59:07
js JavaScriptタグが付けられた新着投稿 - Qiita p5.jsの関数まとめ part.6 randomSeed()とrandom() https://qiita.com/shibuya01055/items/cdb70a36271577986e87 randomはシード値を指定しないと毎回バラバラな乱数を生成するため、randomかつ固定したい時はシード値を設定する。 2021-12-07 01:40:42
js JavaScriptタグが付けられた新着投稿 - Qiita 【PixiJS 覚書】第一回 PIXI.ApplicationとPIXI.Container https://qiita.com/geregeregere/items/d8b7b51dd60f22d5e88a 今回のまとめ要点「PixiJSはPIXIApplicationをインスタンス化して使用する」要点「PixiJSのviewプロパティはHTMLのcanvas要素であり、PixiJSの描画物は全てこのviewcanvas要素に描き出される」要点「PIXIApplicationのstageプロパティはPIXIContainerクラスのインスタンスであり、このstagePIXIContainerインスタンスに描画物をaddChildすることでviewへの描画が行われる」要点「PIXIContainerにaddChildできる物はPIXIDisplayObjectである」要点「PIXIContainer自身もPIXIDisplayObjectの派生クラスであり、また、各描画物はPIXIContainerクラスの派生クラスである。 2021-12-07 01:11:42
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) PyPyの導入につきまして https://teratail.com/questions/372578?rss=all python 2021-12-07 01:51:45
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) 作りながら学ぶ!!Pytorch発展ディープラーニング 第2章7節でのマルチGPUで学習しようとするとき、ギャザー関数がCPUテンソルに含まれていないとエラーが表示される https://teratail.com/questions/372577?rss=all 作りながら学ぶPytorch発展ディープラーニング第章節でのマルチGPUで学習しようとするとき、ギャザー関数がCPUテンソルに含まれていないとエラーが表示される前提・実現したいことPyTorchによるSSDを用いた物体検出の訓練について「作りながら学ぶPyTorchによる発展ディープラーニング」の第章「SSDtrainingipynb」においてnbspnetnbspnbspnnDataParallelnetを追加してマルチGPUで学習を実行した際に以下のエラーメッセージが表示されました。 2021-12-07 01:12:40
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) [Rails Javascript]選択した投稿をモーダルウィンドウで詳細が見れるように実装したいです https://teratail.com/questions/372576?rss=all RailsJavascript選択した投稿をモーダルウィンドウで詳細が見れるように実装したいです解決したいことInstagramのようにUserの詳細ページからUserの投稿したものを選択すると、選択した投稿をモーダルウィンドウで詳細が見れるように実装したいです。 2021-12-07 01:09:58
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) python Androidのロックパターンの総数の計算 https://teratail.com/questions/372575?rss=all pythonAndroidのロックパターンの総数の計算Androidのロックのパターンが何通りあるか計算するプログラムを書いてみましたつの点のうち少なくともつを選び棒線でつないでいくやつです。 2021-12-07 01:02:09
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) iOSで開発者モードになっているかを判定する文が知りたい https://teratail.com/questions/372574?rss=all 開発者 2021-12-07 01:01:05
Linux Ubuntuタグが付けられた新着投稿 - Qiita Qt にバグ報告をして直してもらいました https://qiita.com/task_jp/items/e6f29c32562ca6af840b その前後の流れから分かる可能性もありますが、これはバグレポートを作成した当時年月日よりちょっと前にAGLというプロジェクトでCES向けのデモを作っていたりした際に、とある車メーカーの方から「AGLでQtでアプリを書くと、アプリを非表示にしてバックグラウンドに回った際にイベントループが止まっちゃう」というフィードバックを受けて、調査したものです。 2021-12-07 01:46:36
Linux Ubuntuタグが付けられた新着投稿 - Qiita 【メモ】Ubuntu Server 日本語化 https://qiita.com/masayoshi4649/items/f25736f024e18501cddf langjajputflanguagejajpja 2021-12-07 01:39:11
Linux Ubuntuタグが付けられた新着投稿 - Qiita WindowsにWSLをインストールして、GUI環境を構築する。 https://qiita.com/uene/items/9c543368f11e25a19ae2 最後にWSLでxeyesを実行して、以下のようなウィンドウが出てきたら完了です。 2021-12-07 01:19:14
Docker dockerタグが付けられた新着投稿 - Qiita Windows安定版のDockerでGPUを認識させる https://qiita.com/sanbasan/items/448ea464bc5bdb6d2878 その際、ついにWindows安定版でもDockerコンテナにGPUが認識されたので手順、環境を記事にしておきます。 2021-12-07 01:48:44
海外TECH MakeUseOf 7 Ways to Personalize Your Mac: Color Schemes, Icons, Sounds, and More https://www.makeuseof.com/tag/top-7-ways-personalize-mac-os-x-desktop/ awesome 2021-12-06 16:45:22
海外TECH MakeUseOf 9 DIY Projects for Your Old Hard Drive https://www.makeuseof.com/tag/projects-make-old-hard-drive/ drive 2021-12-06 16:18:17
海外TECH DEV Community Can't cache this! https://dev.to/albertowar/cant-cache-this-5925 Can x t cache this IntroductionWe often see companies publishing a short incident recap after they had a major outage A couple of recent ones were Facebook and Cloudflare Although knowing the actual root cause is interesting I think there is a lot to learn from how the engineers managed to troubleshoot the issue So I decided to take a stab at it and walk you through the troubleshooting process that took place in one of our recent incidents The beginning of it allA few weeks ago my team was preparing for the launch of an alpha version of a new product Engineers were heads down wrapping up the last features and smashing bugs when our QA raised a bug in production The users should have been redirected to the payment page However quite often the underlying request would timeout when anyone was attempting to click on the Buy button This was a regression and a major one hence we decided to jump on it InvestigationThe first step was to dive into the backend app logs Here is what we saw Judging by the logs it looked like the request froze at some point during the execution path This was hard to believe since the app is simple enough that shouldn t lead to any deadlocks However we should have seen an Exception somewhere and that wasn t the case here Also what made it even more interesting was the fact that we also saw some requests that executed normally Nevertheless since the bug was fairly easy to reproduce we needed to keep digging Diving into the codeThe next step in the investigation was to analyze the log lines in the code and pin point the section that was causing the request thread to freeze This can simply be done by looking at the last log line reported and the next log line that should have been reported This exercise brought to light the first suspect As part of the request we fetched a large JSON file from an external service Since this file didn t change very often we added a caching layer to save some network requests and reduce the latency of the request To implement this caching layer we decided to use a Guava cache The cache was configured so that it would return old values while the new values were being fetched Here is a fragment of code showing how the cache was configured var cache CacheBuilder newBuilder refreshAfterWrite Constants CACHE REFRESH TIME MS TimeUnit MILLISECONDS build buildCacheLoader baseUrl private static CacheLoader lt String String gt buildCacheLoader String baseUrl return new CacheLoader lt gt Override public String load final String environment throws Exception log info Fetching data var builder HttpClient newBuilder connectTimeout Duration ofSeconds Constants TIMEOUT IN SECONDS var client builder build final HttpRequest request HttpRequest newBuilder uri URI create baseUrl timeout Duration ofSeconds Constants TIMEOUT IN SECONDS build final HttpResponse lt String gt response client send request HttpResponse BodyHandlers ofString return mapper readValue response body Data class At this point it was clear that the cache wasn t behaving as we expected since It wasn t logging the potential Exception that would explain what was causing the request thread to hang It was causing the request thread to hang Thus I decided to spend some time trying to understand in depth how Guava caches work Setting up the playgroundIn situations like this one I usually create a playground project where I can remove all the noise business logic and focus on what matters I had to come up with a setup as close to production to ensure I was able to reproduce the exact same issue To achieve that I decided to Interact with the cache in separate threads Since the web server framework we rely on executes each request on a different thread within a thread pool Use WireMock to simulate the calls to the external service That way we can make sure the network stack is exercised and that it is easy to set up edge case conditions delays error responses etc Use JUnit to setup the different scenarios and run them To ensure we have visibility in everything that happens during the different test cases the threads will run the following Runnable which includes several log lines Slfjpublic class CacheReader implements Runnable private LoadingCache lt String Data gt cache public CacheReader LoadingCache lt String Data gt cache this cache cache Override public void run try log info Reading value at System currentTimeMillis log info Value at this cache get something System currentTimeMillis catch ExecutionException e log error Exception while loading value at System currentTimeMillis e Mystery Exception MIAThe first mystery to solve was the missing Exception For that there are two potential failures we could have experienced in production that should have reported an Exception The cache failed to be populated on the first attempt The cache was populated but an attempt to refresh the cache later on failed either due to an error on the external service or a network timeout Test Given an empty cache and a slow network connection when fetching the cache it should throw an Exception Test SneakyThrowsvoid givenEmptyCache whenRemoteServiceTimeout shouldThrowException var cache CacheFactory buildCacheWithoutExceptionHandling wireMockServer baseUrl setupRemoteResponse value Constants TIMEOUT IN SECONDS var thread new Thread new CacheReader cache thread start thread join Which reports the following logs Thread INFO org example CacheReader Reading value at Thread INFO org example CacheFactory Fetching data Thread ERROR org example CacheReader Exception while loading value at java util concurrent ExecutionException java net http HttpTimeoutException request timed out lt omitted stacktrace gt When the cache is empty the thread loading the cache seems to be the one that receives the Exception Since we didn t see any Exception in our logs this means this wasn t the failure we observed in production Let s keep going Test Given an empty cache and a external service outage when fetching the cache it should throw an Exception Testvoid givenEmptyCache whenRemoteServiceReturns shouldThrowException throws InterruptedException LoadingCache lt String String gt cache CacheFactory buildCacheWithoutExceptionHandling wireMockServer baseUrl setupFailedResponse var thread new Thread new CacheReader cache thread start thread join Which reports the following logs Thread INFO org example CacheReader Reading value at Thread INFO org example CacheFactory Fetching data Thread ERROR org example CacheReader Exception while loading value at java util concurrent ExecutionException com fasterxml jackson databind exc MismatchedInputException No content to map due to end of input at Source String line column lt omitted stacktrace gt In this case the calling thread is getting a serialization Exception since the response body was not the expected one Again since we didn t see any Exception in our logs we need to continue the investigation Test Given a populated cache due for refresh and a slow network connection when fetching the cache it should get the old value Test SneakyThrows void givenCacheDueForRefresh whenRemoteServiceTimeout shouldGetOldValue var cache CacheFactory buildCacheWithoutExceptionHandling wireMockServer baseUrl setupRemoteResponse new Data old value var thread new Thread new CacheReader cache thread start thread join waitForCacheToExpire setupRemoteResponse new Data new value Constants TIMEOUT IN SECONDS thread new Thread new CacheReader cache thread start thread join Which reports the following logs Thread INFO org example CacheReader Reading value at Thread INFO org example CacheFactory Fetching data Thread INFO org example CacheReader Value Data value old value at Thread INFO org example CacheReader Reading value at Thread INFO org example CacheFactory Reloading Thread INFO org example CacheFactory Fetching datacom google common cache LocalCache Segment runWARNING Exception thrown during refreshjava util concurrent ExecutionException java net http HttpTimeoutException request timed out at com google common util concurrent AbstractFuture getDoneValue AbstractFuture java Thread INFO org example CacheReader Value old value at at com google common util concurrent AbstractFuture get AbstractFuture java lt omitted stacktrace gt In these logs we see that the thread that attempts to load the value after the cache is due for refresh will block we will follow up on this later in attempt to reload the new value However if that fails it will get the old value and an Exception will be logged in the background When we look into the Guava documentation for the type of cache we are using refreshAfterWrite we find the following If an exception is thrown while refreshing the old value is kept and the exception is logged and swallowed This explains why we never saw the Exception in the logs It was logged by Guava and shallowed which was being filtered out when our app sends those logs to NewRelic This was a decision we made to avoid polluting NewRelic with logs that we don t care about but it ended up biting us in the arse Mystery solved Mystery Request thread hangingWhile troubleshooting the previous issue we found that when the cache is due for refresh the thread that attempts to fetch the new value will block and if it fails it will eventually get the old value The next thing to figure out is what happens if many theads attempt to get the value from the cache at the same time when it is due for refresh Test Given a populated cache due for refresh and a slow network connection when many threads attempt to fetch the cache they should all get the old value Test SneakyThrows void givenCacheDueForRefresh whenRemoteServiceTimeout allThreadsShouldGetOldValue var cache CacheFactory buildCacheWithoutExceptionHandling wireMockServer baseUrl setupRemoteResponse new Data old value var thread new Thread new CacheReader cache thread start thread join waitForCacheToExpire setupRemoteResponse new Data new value Constants TIMEOUT IN SECONDS runManyAndWait cache Which reports the following logs Thread INFO org example CacheReader Reading value at Thread INFO org example CacheFactory Fetching data Thread INFO org example CacheReader Value Data value old value at Thread INFO org example CacheReader Reading value at Thread INFO org example CacheReader Reading value at Thread INFO org example CacheReader Reading value at Thread INFO org example CacheFactory Reloading Thread INFO org example CacheReader Value Data value old value at Thread INFO org example CacheFactory Fetching data Thread INFO org example CacheReader Value Data value old value at com google common cache LocalCache Segment run Thread INFO org example CacheReader Value old value at WARNING Exception thrown during refreshjava util concurrent ExecutionException java net http HttpTimeoutException request timed out lt omitted stacktrace gt Here we observe that the unlucky Thread blocks to fetch the new value while all the other threads get the old value and move on with their lives This gives us enough information to conclude what happened in production When our QA was running their regression test their requests would often be the ran by an unlucky thread that gets blocked while fetching the new value Since we have multiple instances of this application this could be reproduced easily Funny enough when multiple people were trying at the same time if they were lucky enough to hit the same instance everything would work just fine which is what we saw in the logs Mystery solved Are we done Not quite We have learnt that when the cache is due for refresh there is always an unlucky thread that has to pay the latency cost of refreshing the value To provide the best experience for our users we should make sure the cache refresh takes place asynchronously and that all requests get the old value while the new one is being fetched So how do we do that Actually fixing the problemIf we look again into Guava s documentation we can see a couple of comments about asynchronous reload As specified in LoadingCache refresh K refreshing a key loads a new value for the key possibly asynchronously If CacheLoader reload is implemented to be asynchronous then the query will not be slowed down by the refresh Unfortunately they forgot to add an example on how to do it It s alright happens A couple of DuckDuckGo searches later we found that we could achieve this by configuring the cache to use asyncReloading public static LoadingCache lt String Data gt buildCacheWithAsyncLoading String baseUrl ExecutorService pool return CacheBuilder newBuilder refreshAfterWrite Constants CACHE REFRESH TIME MS TimeUnit MILLISECONDS build CacheLoader asyncReloading CacheFactory buildCacheLoader baseUrl pool In this case the refresh will take place on a thread from a separate thread pool we have to pass on during instantiation To validate this works as expected we write another test Test SneakyThrowsvoid solution whenFutureResponsesTimeoutAndAsyncLoading returnOldValue ExecutorService pool Executors newFixedThreadPool try var cache CacheFactory buildCacheWithAsyncLoading wireMockServer baseUrl pool setupRemoteResponse new Data old value runAndWait cache waitForCacheToExpire setupRemoteResponse new Data new value Constants TIMEOUT IN SECONDS runManyAndWait cache THREAD COUNT finally Thread sleep pool shutdown Which reports the following logs Thread INFO org example CacheReader Reading value at Thread INFO org example CacheFactory Fetching data Thread INFO org example CacheReader Value Data value old value at Thread INFO org example CacheReader Reading value at Thread INFO org example CacheReader Reading value at Thread INFO org example CacheReader Reading value at Thread INFO org example CacheReader Value Data value old value at Thread INFO org example CacheReader Value Data value old value at pool thread INFO org example CacheFactory Reloading pool thread INFO org example CacheFactory Fetching data Thread INFO org example CacheReader Value Data value old value at pool thread ERROR org example CacheFactory Loading Exception at lt omitted stacktrace gt We can see that there isn t an unlucky thread anymore and that the Exception is reported by the thread in the pool ConclusionWhen we encounter an issue in production depending on its severity and impact we often perform an RCA root cause analysis investigation The goal of this process is to find the root cause of the problem fix it and also to come up with ways we can prevent issues like this happening in the future or at least improve our automated monitoring to ensure we catch these issues as soon as they happen For this particular problem apart from fixing the bug we decided to Use NewRelic scripted browser synthetics to periodically run a smoke test similar to what QA was doing as part of the regression test This will allow us to catch user impacting issues early Tweak our request latency alerts With a similar goal as the one above Come up with a plan to implement browser based EE automation This will allow us to catch regressions in internal environments before they reach production And that s the end of it all If you are curious to see the playground code you can find it in albertowar guava playground This repository contains some tests that I used to investigate a tricky caching bug You can find more information about it in my blog albertowar me View on GitHub 2021-12-06 16:15:45
海外TECH DEV Community How to add custom types to a javascript library https://dev.to/danielart/how-to-add-custom-types-to-a-javascript-library-2dag How to add custom types to a javascript libraryFew weeks ago I started contributing to an open source library called Teaful a Tiny EAsy and powerFUL for React state management with ambitious roadmap Now Teaful reached more than GitHub ️Stars the library and his community are growing fast That means issues and pull requests are growing as well and soon we realized that we need to improve dev experience and provide tools for that reason Bear this in mind implement custom types to allow all the benefits from TypeScript at Teaful is a big step on that way Yes I know migrate a library to pure ts probably is a better solution and it s on our roadmap before IndexAvoiding auto generated typesWhere to place custom typesCreate custom typesConclusions Avoiding auto generated typesIn our case an auto generated custom type full of any was useless So we started implementing custom types We re using microbundle they provide a flag to avoid auto generate types no generateTypes Microbundle according to docs generally respect your TypeScript config at tsconfig json you can read more about here but at this moment we don t need a specific configuration for TypeScriptThen we can inform on package json where are our custom types with types folder index d ts Where to place custom typesCreate a file with extension d ts generally you ll put this file on dist folder Now here you can add your custom types Create custom typesHere I m going to explain how we created custom types specifics for Teaful and why some decisions were taken if you re reading this to know how to add custom types to your js library and already know about TypeScript feel free to skip this section InitialStoreThe store is where Teaful saves data is a key value object you can have more than one store Easy to type type initialStoreType Record lt string any gt So far so good nothing strange here We want to store anything and all keys will be string Then things become more complicated In this article only things about creating types will be explained so if you want to know more about how to implement Teaful I strongly recommend visit the README at github Hook ReturnTo create a new value on store is pretty similar to useState from React Let s see an example const username setUsername useStore username Easy right Ok so what have we here useStore returns an array of two elements Yes Like useState the element in the store and the function to update it The type we need type HookReturn lt T gt T value T value T gt T undefined null gt void If you re not familiar with TS this could looks a little cryptic We re creating a new type called HookReturn which gets a generic type we called T from Type but you can use any name This type is a tuple a data structure that is an ordered list of elements with a fixed length because we aren t going to add more elements for the return of our useStore where first element is T because we want to return a value with specific type that we don t know at the moment of creating the type but we want to ensure for example that the setter function the second element on this tuple will get the same type we are using for the first element as param Then let s pay attention on the second element of our tuple value T value T gt T undefined null gt voidHere our type is a function that returns nothing gt void but accepts one param value T value T gt T undefined null and this param could be a value of type T or a function that get a value of type T and returns null undefined or a value of type T value T gt T undefined null What this means what are we allowing here with this type Ok let s imagine a counter const counter setCounter useStore counter allowed by TsetCounter counter allowed by value T gt T undefined null setCounter counter gt counter setCounter counter gt undefined setCounter counter gt null Yes Teaful accepts a function as param on the setter function Hook typeWhen you create call a new property with useStore you call useStore newProperty This accepts two optional params first for initialValue and the second one is for updateValue a function to update the store property indicated with the proxy The hook looks easy to create here type Hook lt S gt initial S onAfterUpdate afterCallbackType lt S gt gt HookReturn lt S gt Both optional but the second one is a specific function Type onAfterUpdate is a function with two params store before and after the changes both will be same type extending our initialStore type type afterCallbackType lt S extends initialStoreType gt param store S prevStore S gt voidFinally our type Hook will return a tuple property setter so indeed we re going to return our custom type HookReturn with our generic type If we create a number have sense to take care about number type in all places for the initial value the returned tuple etc Hoc typeTeaful allows to use it as Hoc as connect on Redux code explain it by itself const withStore createStore count class Counter extends Component render const store setStore this props store return Similar to useStore const CounterWithStore withStore Counter The HOC withStore wraps a Component and returns the component with a prop called store A second parameter for initial value is allowed and a third one for onAfterUpdate callback type HocFunc lt S R extends React ComponentClass React ComponentClass gt component R initial S onAfterUpdate afterCallbackType lt S gt gt R We need two generic types one for initial value and onAfterUpdate both will use same generic but onAfterUpdate will have a specific type explained later and the other one for React component to wrap that would be the same for the return because we want the same component but with a new prop called store Look at the R type is extending React ComponentClass type provided by React This means that we are taking profit from that type and including it in our generic type called R Why extending component class only and not functional component Well we didn t found a single situation when we wanted to wrap any component that doesn t extend Class with a HOC to get the store Ok third type onAfterUpdate Here we need a function with two params store before and after the changes both will be same type extending our initialStore type Same as first hook we reuse same type for all callbacks paramsNow we only have to export the a type to use export type Hoc lt S gt store HookReturn lt S gt HookDry typeTeaful provides a helper called getStore like useStore but It does not make a subscription So it is no longer a hook and you can use it as a helper wherever you want It s not possible to register events that are executed after a change This means we don t want same as useStoretype we return the same but we want to ensure we don t accept a second param as callback Let s create another one type HookDry lt S gt initial S gt HookReturn lt S gt The return is clear same as Hook Let s type useStore getStore and withStoreOk now we have almost all the work done A custom type is needed for each tool useStore getStoreand withStore type getStoreType lt S extends initialStoreType gt key in keyof S S key extends initialStoreType useStoreType lt S key gt amp HookDry lt S key gt HookDry lt S key gt type useStoreType lt S extends initialStoreType gt key in keyof S S key extends initialStoreType useStoreType lt S key gt amp Hook lt S key gt Hook lt S key gt type withStoreType lt S extends initialStoreType gt key in keyof S S key extends initialStoreType withStoreType lt S key gt amp HocFunc lt S gt HocFunc lt S gt The keyOf type operator ensures that our property will exists on store The ternary here looks weird if you re not familiar with Typescript is used for conditional types The logic shared in three types is get a generic type S that extends our initialStoreType then get a keythat must be on S the property should exists on our store Finally this withStoreType lt S key gt amp HocFunc lt S gt is a Intersection type According to TypeScript documentation An intersection type combines multiple types into one So if S key extends initialStore we set the intersection type if not the hook hoc type only createStoreLast the function to export from Teaful the masterpiece function createStore lt S extends initialStoreType gt initial S afterCallback afterCallbackType lt S gt getStore HookDry lt S gt amp getStoreType lt S gt useStore Hook lt S gt amp useStoreType lt S gt withStore HocFunc lt S gt amp withStoreType lt S gt ConclusionsThat s definitely not everything but there are few steps that you ll face Check how to stop auto generated types check if types are generated by the bundler like our case by tsconfig json or whatever Create a custom types on a d ts file Indicate to package json the place of that file with property types Adding custom types to a javascript library could be difficult at the beginning but will improve the dev experience from your users And most important this could be a great opportunity to learn and improve your skills to start networking with the community or a good way to help other devs I hope it was helpful to you have a super nice day 2021-12-06 16:12:52
海外TECH DEV Community Using WebRTC for a browser multiplayer game - in theory https://dev.to/bornfightcompany/using-webtrc-for-a-browser-multiplayer-game-in-theory-59dk Using WebRTC for a browser multiplayer game in theoryWebRTC is a web technology that enables data exchange between two or more browsers without requiring an intermediary server WebRTC allows web applications and sites to capture and stream video and audio media between peers with help from Media Capture and Stream API Technologies behind WebRTC are implemented as an open web standard and are available as regular Javascript web API To create a multiplayer browser game you first need to select the right communication protocol so that clients can update their in game state in real time Communication can t lag it has to be fast In past the only option for any kind of browser game was a well known Websocket with the server as an intermediary protocol In the past couple of years new technology has emerged that allows as peer to peer communication Why not Websocket Websocket is a communication protocol that sits on the Application layer and uses Transport Layer TCP protocol for bi directional communication between browser and server The main advantage with Websocket is that it is very secure which means that every message that is sent from the browser will arrive at its destination in order If the message in any case doesn t arrive then the receiver will wait until the browser sends the same message again This is a great concept for features like chat where all messages must arrive at their destination in order In the case of multiplayer games it s not a very good feature because in multiplayer games data needs to be exchanged fairly quickly and players don t have time to wait for the message to resend The web is built on top of TCP To deliver data reliably and in order under package loss TCP must hold more recent data in the queue while waiting for dropped packets to be resent Otherwise data would be delivered out of order which is called the head of line blocking and is a problem for web based multiplayer games What are the alternatives maybe UDP UDP like TCP is a transport layer protocol and allows bidirectional communication Unlike TCP UDP doesn t care about messages not arriving at their destination and that is perfectly fine because in some cases not all data needs to arrive at its destination UDP is suitable for time sensitive applications like Voice over IP online games and media streaming UDP is really fast and can be used for query response protocols like DNS So it s UDP not so fast As an alternative to letting users send and receive UDP packets directly from the browser it is not a very good idea Websites would be able to launch DDoS attacks by coordinating UDP packet floods from browsers UDP is not a secure protocol so every package could be sniffed read or modified by an attacker Why WebRTC WebRTC supports data channels that can be configured in unreliable mode providing a way to send and receive unreliable unordered data from a browser using the UDP protocol Looks like WebRTC is everything that peer to peer communication needs but things are not so simple One problem with WebRTC is that it is very complex and it needs to use multiple different technologies to establish peer to peer connections Also NAT protocol that stands as a public IP for a private network further complicates working with WebRTCWhat is NAT Network address translation is a web protocol that allows multiple devices to access the internet through a single public address To achieve this the translation of a private IP address to a public IP is required This is a problem for peer to peer communication because peers must exchange their public IP address and not the one that uses NAT How then to connect two peers Interactive Connectivity Establishment ICE is a technique that helps peers to find each other on the web and establish a connection ICE uses multiple technologies to establish peer connections and two main technologies are STUN and TURN servers STUN serverTo be able to find each other ICE uses STUN servers which enable peers to find their public IP addresses STUN server s only job is to receive a request from a peer to find out his public IP address and returns it to him In most use cases STUN server will be sufficient to establish a connection There is no need to write your own because there are many free STUN servers online although many do not function properly TURN serverAnother technology that ICE uses are TURN servers that help relay messages between peers TURN servers come in handy when dealing with symmetric NAT that allows a router to only accept connections from peers with whom he had a connection before Although TURN servers can be found online it is recommended to write your own Unlike free STUN the TURN server requires authentication SDP Session Description Protocol The standard for describing multimedia content of the connection such as resolution formats codecs encryption so that both peers can understand each other once data is exchanged SDP is a format that needs to be exchanged between peers so they can know where to send data through the data channel How to establish a connection To establish the connection between two peers a signaling server will have to be implemented first The signaling server s purpose is to exchange SDP between two peers The signaling server needs to have bidirectional communication so Websocket can be used for implementing the signaling server When the signaling server is implemented peers can exchange the SDP context of their browser After SDP s are exchanged data channel will open a direct connection between peers and they will be able to exchange their game stats 2021-12-06 16:11:54
Apple AppleInsider - Frontpage News Apple chief says Apple Business Essentials doesn't compete with Jamf https://appleinsider.com/articles/21/12/06/apple-chief-says-apple-business-essentials-doesnt-compete-with-jamf?utm_medium=rss Apple chief says Apple Business Essentials doesn x t compete with JamfIn a detailed new interview Apple s Jeremy Butcher discusses how Apple Business Essentials will work ーand how it will fit in with existing device management services Apple s Jeremy Butcher speaking at a Jamf conference in Now in beta and launching officially in Apple Business Essentials is a service for small business It allows for management of hundreds of devices including Macs iPhones and iPads Read more 2021-12-06 16:20:52
Apple AppleInsider - Frontpage News IOGear 3-Port 4K USB-C and DisplayPort KVMP Switch review: Great for multi-Mac control https://appleinsider.com/articles/21/12/06/iogear-3-port-4k-usb-c-and-displayport-kvmp-switch-review-great-for-multi-mac-control?utm_medium=rss IOGear Port K USB C and DisplayPort KVMP Switch review Great for multi Mac controlIOGear s K USB C and DisplayPort KVMP Switch provides a well rounded way to control your MacBook Pro and two other desktops with one display and set of peripherals IOGear designed a nice looking KVM one that wouldn t look out of place on most desks Power users are familiar with the problem of having too many devices and not enough space to use them Having a monitor and separate peripherals for each Mac or PC can quickly consume all of your available desk space and can leave some users struggling to remember which keyboard and mouse work with which system Read more 2021-12-06 16:16:33
海外TECH Engadget 'The Matrix Awakens' is an Unreal Engine 5 demo you can download today https://www.engadget.com/the-matrix-awakens-unreal-engine-5-interactive-demo-165501226.html?src=rss x The Matrix Awakens x is an Unreal Engine demo you can download todayOn December th Epic Games will release The Matrix Awakens an interactive tie in to The Matrix Resurrections You can preload the demo to your PlayStation or Xbox Series X S console ahead of its debut at The Game Awards Epic built the experience using Unreal Engine and you can see what the next generation engine is capable of in a teaser the company shared today “How do we know what is real asks a life like Keanu Reeves partway through the clip It s a rare movie experience that s any good but that might not matter with The Matrix Awakens For most people this will be their first chance to see UE in action Epic previewed the latest iteration of its popular game engine part way through last year with a stunning PS demo that showed off what it could do In May the company released an early access version of UE to PC but the system requirements meant most people couldn t experience the Valley of the Ancient demo with the hardware they had Digital Keanu Reeves from and pic twitter com bJNWONpfxXーNibel Nibellion December 2021-12-06 16:55:01
海外TECH Engadget Designers hope hydrogen-powered plane will fly halfway around the world without refueling https://www.engadget.com/hydrogen-plane-concept-flyzero-uk-aerospace-technology-institute-163107894.html?src=rss Designers hope hydrogen powered plane will fly halfway around the world without refuelingOne of the toughest nuts to crack when it comes to developing carbon free transportation is flying Commercial electric planes won t be feasible until batteries become more powerful and lightweight Hydrogen powered flight is another possible way forward and a research group has revealed what such a plane could look like The FlyZero project which is led by the Aerospace Technology Institute and funded by the UK government came up with a concept for a liquid hydrogen powered midsize aircraft It said the plane would be able to fly passengers non stop from London to San Francisco or from London to Auckland New Zealand with one stop for refueling The aircraft which has a meter wingspan with two turbofan engines would offer the quot same speed and comfort as today s aircraft quot but with zero carbon emissions nbsp The ATI says its concept plane would have cryogenic fuel tanks in the rear fuselage which would store hydrogen at degrees Celsius degrees Farenheit Two smaller quot cheek quot tanks along the forward fuselage would keep the plane balanced as fuel is used We re years away from commercial hydrogen aircraft becoming a reality though The refueling infrastructure doesn t exist yet and hydrogen is more expensive and difficult to store onboard than kerosene based fuel Those types of planes might not be too much of a pipe dream however The ATI expects that by the middle of the s efficient hydrogen planes might be a more economical option than current planes That s partly because other sectors are shifting toward hydrogen which is likely to reduce supply costs nbsp The FlyZero project plans to publish more detailed findings early next year including concepts for regional narrowbody and midsize aircraft economic and market reports roadmaps for the required tech and a sustainability assessment 2021-12-06 16:31:07
Cisco Cisco Blog Cisco® C245 M6 Servers Powered by 3rd Gen AMD EPYC™ Processors Deliver Enterprise-Grade VDI Capacity and Performance https://blogs.cisco.com/datacenter/cisco-c245-m6-servers-powered-by-3rd-gen-amd-epyc-processors-deliver-enterprise-grade-vdi-capacity-and-performance CiscoC M Servers Powered by rd Gen AMD EPYCProcessors Deliver Enterprise Grade VDI Capacity and PerformanceUsing the AMD based C M server Cisco is able to document that this server can support up to virtual desktops This opens doors for lower TCO and server consolidation for customers 2021-12-06 16:55:52
Cisco Cisco Blog Cisco and Amazon Against Counterfeiting – Fighting the Good Fight, Together https://blogs.cisco.com/smallbusiness/cisco-and-amazon-against-counterfeiting-fighting-the-good-fight-together Cisco and Amazon Against Counterfeiting Fighting the Good Fight TogetherSmall businesses around the globe are increasingly looking for faster simpler and more cost effective ways to buy technology In our last blog we shared the benefits and risks of new routes to market and focused particularly on the ease of purchasing online With this comes a risk of purchasing inferior quality or even counterfeit goods 2021-12-06 16:49:45
金融 金融庁ホームページ 金融審議会「市場制度ワーキング・グループ」(第13回)の議事次第について公表しました。 https://www.fsa.go.jp/singi/singi_kinyu/market-system/siryou/20211206.html 金融審議会 2021-12-06 17:00:00
金融 金融庁ホームページ 金融安定理事会による 「危機管理グループの好事例集」を掲載しました。 https://www.fsa.go.jp/inter/fsf/20211206/20211206.html 危機管理 2021-12-06 17:00:00
ニュース ジェトロ ビジネスニュース(通商弘報) エルバン国庫・財務相が辞任、ネバーティ副財務相が後任に https://www.jetro.go.jp/biznews/2021/12/2a1e16910dfc523e.html 辞任 2021-12-06 16:40:00
ニュース ジェトロ ビジネスニュース(通商弘報) IEA、2026年までの世界の再エネ導入見通しを発表 https://www.jetro.go.jp/biznews/2021/12/20be98adea447f39.html 見通し 2021-12-06 16:30:00
ニュース ジェトロ ビジネスニュース(通商弘報) フランス大手による新たな大規模グリーン水素プロジェクト https://www.jetro.go.jp/biznews/2021/12/f998dba0734d2e83.html 水素 2021-12-06 16:20:00
ニュース ジェトロ ビジネスニュース(通商弘報) チウカ新首相と3党連立内閣が誕生 https://www.jetro.go.jp/biznews/2021/12/4e851aa4044a1e15.html 首相 2021-12-06 16:10:00
ニュース BBC News - Home Bibaa Henry and Nicole Smallman: Met PCs jailed for crime scene images https://www.bbc.co.uk/news/uk-england-london-59474472?at_medium=RSS&at_campaign=KARANGA nicole 2021-12-06 16:50:13
ニュース BBC News - Home Arthur Labinjo-Hughes: Review to start immediately https://www.bbc.co.uk/news/uk-england-birmingham-59552002?at_medium=RSS&at_campaign=KARANGA focuses 2021-12-06 16:54:41
ニュース BBC News - Home Drugs strategy to tackle 300,000 problem users, says PM https://www.bbc.co.uk/news/uk-59540781?at_medium=RSS&at_campaign=KARANGA gangs 2021-12-06 16:40:43
ニュース BBC News - Home Viagra may be useful against Alzheimer's dementia https://www.bbc.co.uk/news/health-59546948?at_medium=RSS&at_campaign=KARANGA researchers 2021-12-06 16:05:11
ニュース BBC News - Home John Miles, best known for his rock ballad Music, has died https://www.bbc.co.uk/news/entertainment-arts-59553438?at_medium=RSS&at_campaign=KARANGA illness 2021-12-06 16:03:21
ニュース BBC News - Home Olesen 'sexually assaulted woman during flight', court hears https://www.bbc.co.uk/sport/golf/59553650?at_medium=RSS&at_campaign=KARANGA olesen 2021-12-06 16:07:14
ニュース BBC News - Home Tommy Fury v Jake Paul: Fight called off with Briton struggling for fitness https://www.bbc.co.uk/sport/boxing/59550892?at_medium=RSS&at_campaign=KARANGA briton 2021-12-06 16:29:15
海外TECH reddit Acend vs Envy / VALORANT Champions 2021 - Group Stage: Winner's (A) / Post-Match Discussion https://www.reddit.com/r/ValorantCompetitive/comments/raaxbp/acend_vs_envy_valorant_champions_2021_group_stage/ Acend vs Envy VALORANT Champions Group Stage Winner x s A Post Match DiscussionAcend Envy NV ban Fracture ACE ban Haven NV pick Ascent ACE pick Bind NV ban Breeze ACE ban Icebox Split remains Ascent Bind Split Acend has qualified for playoffs Acend Liquipedia VLR Official Site Twitter Instagram YouTube Envy Liquipedia VLR Official Site Twitter Instagram Facebook YouTube Twitch VALORANT Champions Tour Information Schedule amp Discussion For spoiler free VALORANT VoDs check out Juked Join the subreddit Discord server for watch parties discussion and more Map Ascent Team DEF ATK Total Acend nbsp ATK DEF nbsp Envy nbsp Acend ACS K D A cNed Jett starxo Astra Kiles Killjoy zeek Kayo BONECOLD Sova Envy ACS K D A yay Jett crashies Sova Marved Astra FNS Killjoy Victor Skye Map Bind Team ATK DEF Total Acend nbsp DEF ATK nbsp Envy nbsp Acend ACS K D A zeek Raze cNed Sage Kiles Viper BONECOLD Brimstone starxo Skye Envy ACS K D A yay Jett crashies Sova Marved Astra FNS Viper Victor Skye submitted by u Razur to r ValorantCompetitive link comments 2021-12-06 16:16:07

コメント

このブログの人気の投稿

投稿時間: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件)