投稿時間:2021-06-29 04:35:00 RSSフィード2021-06-29 04:00 分まとめ(39件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
AWS AWS Architecture Blog Field Notes: Automating Data Ingestion and Labeling for Autonomous Vehicle Development https://aws.amazon.com/blogs/architecture/field-notes-automating-data-ingestion-and-labeling-for-autonomous-vehicle-development/ Field Notes Automating Data Ingestion and Labeling for Autonomous Vehicle DevelopmentThis post was co written by Amr Ragab AWS Sr Solutions Architect EC Engineering and Anant Nawalgaria former AWS Professional Services EMEA One of the most common needs we have heard from customers in Autonomous Vehicle AV development is to launch a hybrid deployment environment at scale As vehicle fleets are deployed across the globe they … 2021-06-28 18:35:49
AWS AWS Partner Network (APN) Blog How TalaTek Uses Amazon CloudWatch for Security Information and Event Management https://aws.amazon.com/blogs/apn/how-talatek-uses-amazon-cloudwatch-for-security-information-and-event-management/ How TalaTek Uses Amazon CloudWatch for Security Information and Event ManagementLearn how TalaTek uses Amazon CloudWatch as an alternative to traditional SIEM solutions with the same functionality CloudWatch gives TalaTek system wide visibility allowing them to monitor their AWS based SaaS solution the TalaTek Intelligent Governance and Risk Integrated Solution TiGRIS CloudWatch helps TalaTek keep TiGRIS running efficiently while allowing us to meet FedRAMP logging requirements 2021-06-28 18:32:50
AWS AWS Database Blog Verify delivery conditions with the Accord Project and Amazon Quantum Ledger Database – Part 2 https://aws.amazon.com/blogs/database/verify-delivery-conditions-with-the-accord-project-and-amazon-quantum-ledger-database-part-2/ Verify delivery conditions with the Accord Project and Amazon Quantum Ledger Database Part This is part two of the two part series of nbsp blog nbsp posts discussing how to apply smart legal contracts technology to verify delivery conditions with open source nbsp Accord Project nbsp and nbsp Amazon Quantum Ledger Database nbsp service In the first part we introduced the smart legal contract technology a sample delivery process and reviewed the solution to run smart legal contracts on AWS with nbsp Accord Project … 2021-06-28 18:29:50
AWS AWS Database Blog Verify delivery conditions with the Accord Project and Amazon Quantum Ledger Database – Part 1 https://aws.amazon.com/blogs/database/verify-delivery-conditions-with-the-accord-project-and-amazon-quantum-ledger-database-part-1/ Verify delivery conditions with the Accord Project and Amazon Quantum Ledger Database Part Smart legal contracts are an emerging technology in the legal tech domain Their main goal is to make the verification of terms and conditions in legal contracts more efficient Unlike smart contracts which are self running programs in distributed ledger databases usually in blockchain based systems smart legal contracts represent an entire legal contract They combine a … 2021-06-28 18:28:12
AWS AWS DevOps Blog Introducing new self-paced courses to improve Java and Python code quality with Amazon CodeGuru https://aws.amazon.com/blogs/devops/new-self-paced-courses-to-improve-java-and-python-code-quality-with-amazon-codeguru/ Introducing new self paced courses to improve Java and Python code quality with Amazon CodeGuruThis post announces the availability of new self paced where you learn how to use CodeGuru Reviewer to automatically scan your code base identify hard to find bugs and vulnerabilities and get recommendations for fixing the bugs and security issues 2021-06-28 18:01:37
js JavaScriptタグが付けられた新着投稿 - Qiita TypeError: Cannot read property 'map' of undefined https://qiita.com/xia_chim/items/0e5695c404a49174b908 TypeErrorCannotreadpropertyxmapxofundefined概要Reactで書いたコードで↓のエラーが発生したので対処方法メモTypeErrorCannotreadpropertymapofundefined原因mapメソッドを使っている配列にデータが入ってなかったcostabcfetchltデータ取れてないconstabcmapfunctionvalreturnval解決方法APIのエンドポイントが間違っていたため、修正。 2021-06-29 03:32:04
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) Python3 ImageTkをインポートできない https://teratail.com/questions/346654?rss=all PythonImageTk を イン ポート でき ない fromPILimportImageTk で イン ポート できる はず の imageTk が イン ポート でき ませ ん 。 2021-06-29 03:29:30
海外TECH Ars Technica The Linux Foundation is working to improve voice recognition ethics https://arstechnica.com/?p=1776791 linux 2021-06-28 18:31:15
海外TECH Ars Technica We finally have a release date and new teaser for Apple TV+ series Foundation https://arstechnica.com/?p=1776719 episodes 2021-06-28 18:05:26
海外TECH DEV Community Functools - The Power of Higher-Order Functions in Python https://dev.to/martinheinz/functools-the-power-of-higher-order-functions-in-python-3dg0 Functools The Power of Higher Order Functions in PythonPython standard library includes many great modules that can help you make your code cleaner and simpler and functools is definitely one of them This module offers many useful higher order functions that act on or return other functions which we can leverage to implement function caching overloading creating decorators and in general to make our code a bit more functional so let s take a tour of it and see all the things it has to offer CachingLet s start off with the simplest yet quite powerful functions of functools module These are caching functions and also decorators lru cache cache and cached property First of them lru cache provides least recently used cache of function results or in other words memoization of results from functools import lru cacheimport requests lru cache maxsize def get with cache url try r requests get url return r text except return Not Found for url in get with cache url print get with cache cache info CacheInfo hits misses maxsize currsize print get with cache cache parameters maxsize typed False In this example we are doing GET requests and caching their results up to cached results using lru cache decorator To see whether the caching really works we can inspect cache info of our function using cache info method which shows number of cache hits and misses The decorator also provides a clear cache and cache parameters methods for invalidating cached results and inspecting parameters respectively If you want to have a bit more granular caching then you can also include optional typed true argument which makes it so that arguments of different types are cached separately Another caching decorator in functools is a function simply called cache It s a simple wrapper on top of the lru cache which omits the max size argument making it smaller and after as it doesn t need to evict old values There s one more decorator that you can use for caching and it s called cached property This one as you can probably guess is used for caching results of class attributes This is very useful if you have property that is expensive to compute while also being immutable from functools import cached propertyclass Page cached property def render self value Do something with supplied value Long computation that renders HTML page return htmlThis simple example shows how we could use cached property to for example cache rendered HTML page which would get returned to user over and over again Same could be done for certain database queries or long mathematical computations Nice thing about cached property is that it runs only on lookups therefore allowing us to modify the attribute After the attribute is modified the previously cached value won t be used instead new value will be computed and cached It s also possible to clear the cache all we need to do is delete the attribute I would end this section with a word of caution for all of the above decorators do not use them if your function has any side effects or if it creates mutable objects with each call as those are not the types of functions that you want to have cached Comparing and OrderingYou probably already know that it s possible to implement comparison operators in Python such as lt gt or using lt gt or eq It can be quite annoying to implement every single one of eq lt le gt or ge though Luckily functools module includes total ordering decorator that can help us with that all we need to do is implement eq and one of the remaining methods and rest will be automatically provided by the decorator from functools import total ordering total orderingclass Number def init self value self value value def lt self other return self value lt other value def eq self other return self value other valueprint Number gt Number Trueprint Number lt Number Trueprint Number gt Number Trueprint Number lt Number FalseThe above shows that even though we implemented only eq and lt we re able to use all of the rich comparison operations The most obvious benefit of this is the convenience of not having to write all those extra magic methods but probably more important is the reduction of code and it s improved readability OverloadingProbably all of us were taught that function overloading isn t possible in Python but there s actually an easy way to implement it using two functions infunctools module singledispatch and or singledispatchmethod These functions help us implement what we would call Multiple Dispatch algorithm which is a way for dynamically typed programming languages such Python to differentiate between types at runtime Considering that function overloading is pretty big topic on its own I dedicated a separate article to Python s singledispatch and singledispatchmethod so if you want to know more about this then you can read more about it here PartialWe all work with various external libraries or frameworks many of which provide functions and interfaces that require us to pass in callback functions for example for asynchronous operations or for event listeners That s nothing new but what if we need to also pass in some arguments along with the callback function That s where functools partial comes in handy partial can be used to freeze some or all of the function s arguments creating new object with simplified function signature Confusing Let s look at some practical examples def output result result log None if log is not None log debug f Result is result def concat a b return a bimport loggingfrom multiprocessing import Poolfrom functools import partiallogging basicConfig level logging DEBUG logger logging getLogger default p Pool p apply async concat Hello World callback partial output result log logger p close p join The above snippet demonstrates how we could use partial to pass function output result along with its argument log logger as a callback function In this case we use multiprocessing apply async which asynchronously computes result of supplied function concat and returns its result to the callback function apply async will however always pass the result as a first argument and if we want to include any extra as in this case log logger we have to use partial This was fairly advanced use case so a more basic example might be simply creating function that prints to stderr instead of stdout import sysfrom functools import partialprint stderr partial print file sys stderr print stderr This goes to standard error output With this simple trick we created a new callable function that will always pass the file sys stderr keyword argument to print allowing us to simplify our code by not having to specify the keyword argument every time And one last example for a good measure We can also use partial to utilize little known feature of iter function it s possible to create an iterator by passing callable and a sentinel value to iter which can be useful in following application from functools import partialRECORD SIZE Read binary file with open file data rb as file records iter partial file read RECORD SIZE b for r in records Do something with the record Usually when reading a file we want to iterate over lines but in case of binary data we might want to iterate over fixed sized records instead This can be done by creating callable using partial that reads specified chuck of data and passing it to iter which then creates iterator out of it This iterator then calls read function until end of file is reached always taking only specified chuck of data RECORD SIZE Finally when the end of file is reached sentinel value b is returned and iteration stops DecoratorsWe already spoke about some decorators in the previous sections but not about decorators for creating more decorators though One such decorator is functools wraps to understand why we need it let s first take a look at the following example def decorator func def actual func args kwargs Inner function within decorator which does the actual work print f Before Calling func name func args kwargs print f After Calling func name return actual func decoratordef greet name Says hello to somebody print f Hello name greet Martin Before Calling greet Hello Martin After Calling greetThis example shows how you could implement a simple decorator we wrap the function that does the actual task actual func with outer decorator function which becomes the decorator that we can then attach to other functions as for example with greet function here When the greet function is called you will see that it prints both the messages from actual func as well as its own Everything looks fine no problem here right But what if we try the following print greet name actual funcprint greet doc Inner function within decorator which does the actual workWhen we inspect name and docstring of the decorated function we find that it was replaced by the values from inside the decorator function That s not good we can t have all our function names and docs overwritten every time we use some decorator So how do we solve this With functools wraps from functools import wrapsdef decorator func wraps func def actual func args kwargs Inner function within decorator which does the actual work print f Before Calling func name func args kwargs print f After Calling func name return actual func decoratordef greet name Says hello to somebody print f Hello name print greet name greetprint greet doc Says hello to somebodyThe only job of wraps function is to copy name docstring argument list etc to prevent them from being overwritten And considering that wraps is also a decorator we can just slap it onto our actual func and the problem is solved ReduceLast but not least in the functools module is reduce You might know it from other languages as fold Haskell What this function does is take a iterable and reduce or fold all its values into single one This has many different applications so here are some of them from functools import reduceimport operatordef product iterable return reduce operator mul iterable def factorial n return reduce operator mul range n def sum numbers Use sum function from standard library instead return reduce operator add numbers def reverse iterable return reduce lambda x y y x iterable print product print factorial print sum print reverse hello ollehAs you can see from the above code reduce can simplify and oftentimes compress code into single line that would otherwise be much longer With that said overusing this function just for sake of shortening code making clever or making it more functional is usually a bad idea as it gets ugly and unreadable really quickly so in my opinion use it sparingly Also considering that usage of reduce generally produces one liners it s ideal candidate for partial product partial reduce operator mul print product And finally if you need not only the final reduced result but also intermediate ones then you can use accumulate instead function from another great module itertools This is how you can use it to compute running maximum from itertools import accumulatedata print list accumulate data max Closing ThoughtsAs you could see here functools features a lot of useful functions and decorators that can make you life easier but this module is really just a tip of an iceberg As I mentioned in the beginning Python standard library includes many modules that can help you build better code so besides functools which we explored here you might also want to checkout other modules such as operator or itertools I wrote article about this one too you can check it out here or just go straight to Python module index and click on whatever catches your attention and I m sure you will find something useful in there 2021-06-28 18:59:40
海外TECH DEV Community Create an executable JAR file on VS Code n Command line https://dev.to/rohitk570/create-an-executable-jar-file-on-vs-code-n-command-line-154b Create an executable JAR file on VS Code n Command line So what exactly is JAR The Jar Java Archive tool of JDK used to package one or more Java class files and associated metadata and resources text images etc into one file to distribute application software or libraries on the Java platform And it provides the facility to create the executable jar file which calls the main method of the class if you double click it Simply speaking this is a format for archiving data This is similar to you using WinRAR or WinZIP You can read Oracle documentation on jar here In this article We will learn how to create an executable jar file we will take a Java application and explore two ways to run it as a jar just by double clicking on it Using VsCode amp Command lineWhat does it mean when we say that the file is an executable JAR file Well when you double click on the JAR file it automatically calls the main method of the program And if program have JAVA GUI such as frames panel present inside the main method that would also be executed VisualStudioCodeVS Code is a more flexible IDE in today s competition so its important to know to create jar file here which will get our job done faster with ease If you want to learn more about VsCode and other text editors you can go through this Blogpost Best IDE s and Text Editors KUMAR HARSH・Jun ・ min read productivity programming codenewbie NOW Follow the following steps Download the extensionIn VsCode marketplace install extension Java Extension Pack which includes set of extensions needed for configuring java enviroment in vscode or you can just download Project Manager for Java extension which is just needed here Write your Java programI am using my java code of calculator a gui application using AWTNOTE application needs to have a class with a main method This class provides our entry point into the application Export jar fileIn order to compile the code by packing JAR inside Vscode at bottom left corner you will find and option JAVA PROJECTS there you will find and symbol saying EXPORT JAR Click itIMP now its a very important task it will ask you to specify main class just provide the main class here MyCalcthis class provide the entry point so its important to mention NOTE Otherwise the jar file will become normal jarfile not an executable ones NOW ENJOY your EXECUTABLE JAR FILE has been created here CALC jar you can go to your directories and just double click it or choose and option open with JAVA TM Platform SE Binary Command lineNOW using command line you should know the jar tool provides certain switches with which we can create an executable jarfilesome of them are as follows c creates new archive filev generates verbose output It displays the included or extracted resource on the standard output m includes manifest information from the given mf file f specifies the archive file namex extracts files from the archive fileWrite the java file and then and then follow the following step Compile java codeWe can do this with javac from the command line javac MyCalc javaThe javac command creates MyCalc class in the current directory If you have multiple java file compile them too We can now package that into a jar file Creating manifest fileA manifest file is essential as it sets an entry points to our application which main class that we are going to execute to the jarfile So Create a manifest file with MF extensions in same directories so that not needed to set class path explicitlyYou need to write Main Class then colon then space then classname which you want to make an entry point here MyCalc then press enter NOTE It s important that we end our manifest file with a newline Otherwise no main manifest attribute error is thrown now save the MF file here manifest MF Creating the executable jarOpen the Command Prompt write the command using jar tool switches providedusing jar commandjar cvfm lt jarfilename jar gt lt manifestfile gt lt classname class gt Command order shouldn t be change jar command to create a jar file switchc used to indicates we are creating new file switchv generates verbose output information switchf tell about the jarfile name we are creating switchm it includes the manifest informationHence the corresponding filename are also written in the same order and if there is multiple class files then include them too example Running the JarNOW we can use the jar option of the java command to run our application since executable jarfile has been created java jar CALC jarhere I named my jarfile as CALC jarnow our application will be executed after this command ORYou can run this just by DOUBLE CLICKING as our main motive of making our jar file executable And that s it Now you can also run your jarfile with an ease just by clicking it If you would like to download amp run my CALC jar you can find hereas to show how one can easily share justifying its properties that import anywhere it is required AND You can check my Blogpost where I had explained how I created this basic calculator using java AWT Creating a Calculator using Java AWT ROHIT KUMAR・Jun ・ min read java programming tutorial guiapplication With this I will end my articles here Hope you all find it valuable and if you have any doubt then you ask me just by commenting below If the program runs you re done Happy coding Thank You You can follow me on TwitterLinkedin 2021-06-28 18:29:26
海外TECH DEV Community Red, Red, Green, Refactor https://dev.to/tyrw/red-red-green-refactor-n0h Red Red Green RefactorIn this article I describe a simple approach we use at Userfront to make our tests easier to write and less prone to error The classic Red Green RefactorIn Test Driven Development a common approach is Red Green Refactor This is where we write failing test code Red then write application code to make it pass Green Then when we have the code working we can refactor to make it look nicer perform better etc The abyss a moving targetThe problem with TDD is that it can be hard to get started and easy to forget about covering things For example let s say we want to make an API call and parse the results Our test setup could look like it should make an API call and parse the results async gt But now how do we start writing the actual test code In order to write the test code first we have to have a very good idea of What we want to buildAll the test suite s syntax and featuresThe libraries we ll use and how they workWhich functions to mockThis can be a moving target and is often a lot to keep in our head In software keeping everything in your head leads to errors An extra RedOur team has taken to using an extra failing step in the Red Green Refactor model to help get our tests started and to not miss things We write pseudo tests that outline the process and give some idea of what tools we ll use and how to use them These tests are more like notes but we add them to the actual test suite so that they fail where they re supposed to it should make an API call and parse the response async gt expect Make the API call with fetch toEqual true expect The mock webhook endpoint toHaveBeenCalled expect The API response toEqual results count Note that these tests don t mean anything on their own We don t expect this to pass expect The mock webhook endpoint toHaveBeenCalled This is only a shorthand note for later but it lets us get the concept out of our head to free up capacity and it keeps us from forgetting about it later We ve found that this is a really nice pattern for simplifying the test writing process It allows us to code with a clearer head and with less worry about whether we forgot something If you ve ever felt overwhelmed writing tests or missed something important because you forgot to cover it consider Red Red Green Refactor 2021-06-28 18:23:54
海外TECH DEV Community Per-project configuration, Storybook support for Angular 12, auto-refresh for Dependency Graph, and more in Nx 12.5! https://dev.to/nx/per-project-configuration-storybook-support-for-angular-12-auto-refresh-for-dependency-graph-and-more-in-nx-12-5-3c8f Per project configuration Storybook support for Angular auto refresh for Dependency Graph and more in Nx Nx includes many new features including Per project configuration Storybook support for Angular and more Nx is a smart extensible build framework to help you architect test and build at any scale   integrating seamlessly with modern technologies and libraries while providing a robust CLI computation caching dependency management and more If you aren t familiar with it learn about Nx at nx dev angular nx dev react and nx dev node Per project ConfigurationTraditionally in Nx workspaces configuration for all projects is all contained in workspace json and nx json files For medium to large workspaces these can be a source of merge conflicts and limiting for existing repository structures We ve wanted to make this more flexible and scale easier for a long time and have introduced per project configuration in Nx workspaces using project json files Project specific configuration filesProject configurations can be independent files referenced by workspace json For instance a workspace json may contain projects configured as below projects mylib libs mylib This tells Nx that all configuration for that project is found in the libs mylib project json file This file contains a combination of the project s configuration from both workspace json and nx json making projects in the root nx json optional root libs mylib sourceRoot libs mylib src projectType library targets tags implicitDependencies Independent project configurations provide more flexibility for projects and less possibility of merge conflicts for larger workspaces Integration and autocompletion still work as intended with Nx Console Generating new standalone projects is done by passing the standaloneConfig flag nx g nrwl react app my app standaloneConfigTo convert your existing workspace to a per project configuration use the convert to nx project generator nx g nrwl workspace convert to nx project allAlternatively you can convert individual projects with the project flag nx g nrwl workspace convert to nx project project my project Storybook Support for Angular Storybook is an open source tool for building UI components and pages in isolation It streamlines UI development testing and documentation Nx has first class support for Storybook with Angular With the latest release of Nx we support Angular version with Storybook and some updated support for moving from knobs to controls From knobs to controlsStorybook v moves from knobs to args and controls when it comes to defining and manipulating your storybook component properties More can be found on the official Storybook docs From Nx v and on the nrwl storybook package will be using storybook addon controls instead of storybook addon knobs to generate stories For new Nx workspacesGenerators will generate your Storybook configuration files and your Stories using Controls args instead of knobsThe storybook configuration generator will install the storybook addon essentials package part of which is storybook addon controls This includes some more essential Storybook features such as docs To disable features you do not need anytime in your main js Cypress ee tests will be generated using the args URL to set args in the controls For existing Nx workspacesIf you nx migrate to the latest version your package json will be updated to include the storybook addon essentials package The storybook addon essentials addon will be added in your addons array in your root main js file You will need to run npm yarn install to have it installed If you install manually the latest version of nrwl storybook nrwl workspace and nrwl angular or nrwl react you will need to manually do yarn add D storybook addon essentials You will also need to add the addon manually in your addons array in your root main js file All the stories you generate from that moment on will be using controls argsYour existing stories will not be touched and will still work Dependency Graph Auto RefreshThe Nx dependency graph is the way to always get an instant view of the dependencies between projects in your Nx workspace We ve added the additional functionality of auto refresh to the dependency graph so you can see changes made to new and existing projects as they occur New Nx Docs websiteKeeping our documentation up to date is something we put a lot of work and effort into maintaining We have revamped our Nx website which is now built with Next js This has also given us the ability to see new documentation change previews in pull requests making the contribution process easier for our community of contributors Other HighlightsJest supportWebpack support for React Next js and other non Angular applications Added utility methods for CSS purging with TailwindAuto sorting of common configuration files including nx json workspace json and tsconfig base json How to Update NxUpdating Nx is done with the following command and will update your Nx workspace dependencies and code to the latest version nx migrate latestAfter updating your dependencies run any necessary migrations nx migrate run migrations Explore MoreGet our free basic Nx workspaces course on YouTube Purchase our premium video course on advanced practices for Nx workspaces here As always if you are looking for enterprise consulting training and support you can find out more about how we work with our clients here 2021-06-28 18:16:40
海外TECH DEV Community Never ask for consent ever again https://dev.to/sbelzile/never-ask-for-consent-ever-again-1200 Never ask for consent ever againDangerous operations often require a user input For example your UI might have a delete button that will destroy some resource perform an irreversible operation or launch a missile In such cases it is preferable to prompt the application user for consent before performing the dangerous operation This article implements a React abstraction that will prevent you from asking for consent ever again The valid approach that we want to stop usingIn your view Render a modal component that is controlled by a boolean state This state controls whether the modal is opened or not The modal component either calls a callback when the user clicks Confirm or implements the logic to perform the operation that requires confirmation In React pseudo code const opened setOpened useState false const operation useLaunchMissile return lt div gt lt button onClick gt setOpened true gt Launch missile lt button gt lt ConfirmationModal opened opened onConfirm operation onClose gt setOpened false gt lt div gt The problem with this approach is that you have to add code in your UI for each user confirmation A better approachIt is possible to create an abstraction around prompts and to inject a method that calls this abstraction First we will create an abstraction around our prompts in React we can create this with a context and a custom hook context DialogProvider import useState createContext useMemo from react export const DialogContext createContext export function DialogProvider children const Dialog setDialog useState Dialog has type ReactNode const context useMemo gt setDialog return lt gt lt DialogContext Provider value context gt children lt DialogContext Provider gt Dialog lt gt hooks use dialog js import useContext useCallback useEffect from react import DialogContext from context DialogProvider export function useDialog const setDialog useContext DialogContext const close useCallback gt setDialog amp amp setDialog null setDialog const add useCallback node gt setDialog amp amp setDialog node setDialog useEffect gt return close close return add close The code above allows us to render a dialog modal prompt component from anywhere in the code Second we will use the abstraction above to render our prompt from a React hook hooks use user consent jsximport useDialog from use dialog import ConfirmationDialog from components ConfirmationDialog export function useUserConsent const add close useDialog return gt new Promise resolve gt const onClose accepted gt close resolve accepted add lt ConfirmationDialog onAccept gt onClose true onDismiss gt onClose false gt The code above returns a function that returns a Promise This promise will resolve to true if the user clicked confirm and resolve to false otherwise If you wish to test the code here is a dumb implementation of the ConfirmationDialog component components ConfirmationDialog jsx export function ConfirmationDialog onDismiss onAccept return lt div gt lt div gt Are you sure lt div gt lt button onClick onAccept gt OK lt button gt lt button onClick onDismiss gt Close lt button gt lt div gt Ask for consent with our abstraction App jsimport DialogProvider from context DialogProvider import ConsentTest from components ConsentTest function App return lt DialogProvider gt lt ConsentTest gt lt DialogProvider gt export default App components components ConsentTest jsximport useCallback from react import useUserConsent from hooks use user consent export function ConsentTest const hasApproval useUserConsent const callback useCallback async gt const userConfirmed await hasApproval alert userConfirmed hasApproval return lt button onClick callback gt Test lt button gt ConclusionWe have just seen a way of abstracting asking for user consent This can easily be extended by adding properties to the hasApproval method to have a configurable prompt message 2021-06-28 18:16:21
海外TECH DEV Community Everything you need to know about template strings https://dev.to/thatanjan/everything-you-need-to-know-about-template-strings-11md Everything you need to know about template strings Why does template strings exist Simply to add multiple strings into a single string For example If I ask you to add the string a and b How would you do this const a My is Anjan Shomodder const b I am a software engineer You might do this const combinedString a bconsole log combinedString This will work But what if you want to add number to it How would you write I am years old const age const c I am const d years old You might do this const combinedString a age dconsole log combinedString This will work But it is not that readable What if you can write all the substring javascript expressions like variables function calls in a single string That would be great It would be readable and easy to do That s why we have Es template strings or template literals whatever you say Template literals are string literals allowing embedded expressions You can use multi line strings and string interpolation features with them The way you write is instead of normal quotation mark you use backticks Inside backticks you put normal javascript string const a My is Anjan Shomodder If you want to use variables then you do this const a My is Anjan Shomodder const b I am a software engineer const c I am const d years old const age const combinedString a b c age d I always write good code ha ha ha So instead of writing the variables directly You add a dollar sign and then you wrap them by curly brackets output My is Anjan Shomodder I am a software engineer You can put whatever expressions you like add two numberconst a const b const resultString a and b adds up to a b Ternary operator Single line if statement console log My name is gt Anjan Mark output My name is AnjanAnd you get the point You can also write multiline strings console log string text line string text line And that s all you need to know about template strings Shameless PlugI am creating a video series on my youtube channel about how to build a static blogging site using JAMstack What are you going to learn from this video series ReactJS NextJsStatic Site GenerationDynamic RoutingMaterial uiMongoDBhow to build a real time view countera small search engine with mongodb and so on Project DemoYou can demo the project from here View the Project code So like share and subscribe to Cules Coding It takes a lot of effort to build those videos If you have any question put them on the comment section And also you can connect to me on any social media as thatanjan I post content there So stay safe and good bye About me Who am I My name is Anjan I am a full stack web developer from Dhaka Bangladesh What problems do I solve I can create complex full stack web applications like social media application blogging e commerce website and many more Why do I do what I do I love to solve problems and develop new ideas I also enjoy sharing my knowledge to other people who are wiling to learn That s why I write blog posts and run a youtube channel called Cules Coding Think we should work together Feel free to contact meEmail anjancules gmail comlinkedin thatanjanportofolio anjanGithub thatanjanInstagram personal thatanjanInstagram youtube channel thatanjantwitter thatanjan About My channel Why would you subscribe to Cules Coding Cules Coding will teach you full stack development I will teach you not only the basic concepts but also the advanced concepts that other youtube channels don t cover I will also teach you Data Structures and Algorithms with abstraction and without Math You will also find many tutorials about developer tools and technologies I also explain advanced concepts and technologies with simplicity So what are you waiting for Subscribe to Cules Codingso that my friend you don t miss any of these cool stuffs 2021-06-28 18:15:24
海外TECH DEV Community The Complete Beginner's Guide to Transition and Animation in CSS https://dev.to/drumstickz64/the-complete-beginner-s-guide-to-transition-and-animation-in-css-2087 The Complete Beginner x s Guide to Transition and Animation in CSSAnimation is a great way to bring your websites to life but animation in CSS can be a bit confusing This is where this guide comes in So without further a do let s dive in A Primer on AnimationDisclaimer I m no expert on animation so take this section with a grain of salt and if you find any errors in my explanation feel free to correct me Wikipedia defines animation as a method in which figures are manipulated to appear as moving Animation is done by showing images sequentially as such high speeds that they appear to be moving to the human eye this can be done in a number of ways one of the most well known ways is frame by frame animation where every frame is drawn by hand Animation in CSSIn CSS things are a little bit different We don t draw the frames rather we tell the browser how to draw the frames for us this is done by two properties transition and animation TransitionThe transition property allows to define a well transition for a CSS property this transition starts at the initial value or state of that property and ends at the final value The transition is triggered as soon as the value of that property changes How It WorksThe transition property is made of required values and optional value Required values Transition PropertyDurationTiming FunctionOptional values DelaySo defining a transition would look like this div transition transition property duration timing function delay You can also set each property on its own You might be wondering why are we using transform instead of height that s a good question The reason for that is that there are performance concerns when using properties like height And the reason for that comes down to layout Properties like height cause layout shifting and therefore layout recalculations which can be very expensive transform and opacity are the safest bet you have when it comes to animation performance in CSS If you would like to learn more about performant animations you can read this article Transition PropertyThe transition property is the property you would like to transition For example color width or transform It can also be all to encompass all possible properties but I would generally advise against this for the sake of predictability clarity and performance DurationThe amount of time the transition will last for Expressed in seconds s or milliseconds ms Note s ms Timing FunctionTiming is an extremely important part of animation It defines how things move from one state to another In the real world things don t move at perfectly linear pace things ease in ease out and move in all sorts of wacky ways Timing functions allow us to create lively realistic and expressive animations What are Timing Functions Timing functions are expressed as a cubic bezier A thing I know very little about thankfully there are tools online that allow you to make and visualize these functions CSS also includes five ones out of the box they re linear ease ease in ease out and ease in out and they should enough for of your animation needs DelayDelay is the amount of time before the transition occurs Expressed in seconds s or milliseconds ms Transition Example NavbarIf we have navbar that is hidden on small screens And we want it to expand when the user clicks on a button We would attach an active class to our navbar when the user clicks on the button Like so navbar transform scaleY navbar active transform scaleY this causes our navbar to instantly appear as soon as our user clicks our button But we may want to animate our navbar expanding in this case we would define a transition But how do we do that If we want to animate our navbar we would do something like this navbar transform scaleY transition transform s ease in out navbar active transform scaleY This would cause the navbar to gracefully expand when activated Making it more visually appealing Animationanimation defines a you guessed it animation And it works largely in the same way as transition But there a few key differences Unlike transition which triggers when a property updates animation is active from the moment it s applied Also instead of taking a transition property animation takes something called keyframes and we will discuss those soon How It WorksThe animation property is made of required values and optional valusRequired values Animation Name or Keyframes DurationTiming FunctionOptional values DelayIteration countDirectionFill ModePlay StateSo defining an animation would look like this div animation animation name duration timing function delay iteration count direction fill mode play state You can also set each property on its own KeyframesWikipedia defines keyframes as A key frame or keyframe in animation and film making is a drawing or shot that defines the starting and ending points of any smooth transition These are called frames because their position in time is measured in frames on a strip of film or on a digital video editing timeline A sequence of key frames defines which movement the viewer will see whereas the position of the key frames on the film video or animation defines the timing of the movement In CSS keyframes are defined using the keyframes at rule and is a collection of CSS properties associated with specific points in the animation timeline like from or to from is the equivalent of to is the equivalent of If a set of keyframes does not have a starting state or from whatever state they were in before the animation starts will be their starting state Therefore keyframes define a general sequence of states but does not define their duration flow or direction So defining keyframes looks like keyframes spin from transform rotate to transform rotate deg The spin keyframes dictates that the element will start at degrees of rotation of rotation and end at a full degrees Iteration CountHow many times the animation repeats It can be a number or infinite to make it repeat indefinitely DirectionWhat direction the animation animation flows in normal means that the animation moves normally from start to end reverse means that the animation moves backwards from end to start alternate means that the animation moves forwards one time and backwards the other time keep in mind this needs an iteration count higher than and alternate reverse is like alternate but starts as reverse Fill Modesets how a CSS animation applies styles to its target before and after its execution This property is outside the scope of this article Play Statesets whether an animation is running or paused It has two values running and paused pretty self explanatory This property is can be useful for manipulating animations with JavaScript Animation Example Loading SpinnerUsing the spin keyframes we made earlier we can make a loading spinner like so keyframes spin from transform rotate to transform rotate deg spinner animation spin s infinite The animation we defined would make the spinner rotate a full degrees in second and repeat an infinite number of times effectively creating a spinning animation Closing NotesBe careful when adding your animations You may think that super flashy second long animation is cool but your users might disagree Make sure your animations are smooth on all of your target devices Even the lower end ones Read this article for more infoMake sure that animations are reduced or even removed when a user has prefers reduced motion reduce Animations that change visual aspects of an element but don t alter it s layout can still cause performance issues on a large scale But small effects should be fine like a hover effect on a button Further ReadingUsing css transitions from mdnUsing css animations from mdn Useful Toolscubic bezier generator OutroAnd that concludes this article Man this was a doosey to write Also I m sure I made a few mistakes somewhere in there so any comments and suggestions are welcome Footnote I plan on adding codepens to my examples when I get the time 2021-06-28 18:15:18
Apple AppleInsider - Frontpage News YouTube TV '4K Plus' tier brings 4K streaming, offline downloads for $19.99 https://appleinsider.com/articles/21/06/28/youtube-tv-4k-plus-tier-brings-4k-streaming-offline-downloads-for-1999?utm_medium=rss YouTube TV x K Plus x tier brings K streaming offline downloads for YouTube TV is introducing a new add on that introduces K quality downloads and unlimited simultaneous streaming on a home network to the Google live TV subscription service Credit YouTubeThe K Plus add on which costs a month extra will allow viewers to stream K content on YouTube TV for the first time That s assuming that they have a compatible TV and streaming device such as an Apple TV K Read more 2021-06-28 18:17:56
海外TECH Engadget Senator proposes law to safeguard journalists’ data from the government https://www.engadget.com/senator-proposes-federal-shield-law-183325202.html?src=rss_b2c federal 2021-06-28 18:33:25
海外TECH Engadget Get up to 25 courses on how to code in different languages https://www.engadget.com/2021-ultimate-learn-to-code-training-bundle-182052503.html?src=rss_b2c courses 2021-06-28 18:20:52
海外科学 NYT > Science Peering Under Vermeers Without Peeling Off the Paint https://www.nytimes.com/2021/06/28/science/vermeer-paintings-fakes-scans.html Peering Under Vermeers Without Peeling Off the PaintHigh tech scanning techniques used by geologists planetary scientists drug companies and the military are revealing secrets of how artists created their masterpieces 2021-06-28 18:18:40
海外科学 NYT > Science The Hills Are Alive With the Flows of Physics https://www.nytimes.com/2021/06/24/science/hills-creep-lasers.html steady 2021-06-28 18:06:25
ニュース BBC News - Home Covid-19: End of England's Covid rules still set for 19 July https://www.bbc.co.uk/news/uk-57643694 confirms 2021-06-28 18:49:12
ニュース BBC News - Home Croatia 3-5 Spain: Spain win after extra time in eight-goal thriller https://www.bbc.co.uk/sport/football/51198542 thriller 2021-06-28 18:55:11
ニュース BBC News - Home Third seed Tsitsipas beaten by unseeded Tiafoe - highlights & report https://www.bbc.co.uk/sport/tennis/57638801 wimbledon 2021-06-28 18:41:12
ニュース BBC News - Home World number one Djokovic sees off spirited GB teenager Draper - highlights & report https://www.bbc.co.uk/sport/tennis/57633074 World number one Djokovic sees off spirited GB teenager Draper highlights amp reportBritish teenager Jack Draper takes the opening set off Novak Djokovic but the defending champion fights back to reach the Wimbledon second round 2021-06-28 18:41:56
ニュース BBC News - Home Euro 2020: 'A terrible mistake!' - Keeper Unai Simon's howler as own goal puts Croatia ahead against Spain https://www.bbc.co.uk/sport/av/football/57642773 Euro x A terrible mistake x Keeper Unai Simon x s howler as own goal puts Croatia ahead against SpainA dreadful error from Unai Simon allows a backpass to roll past him and into the net to give Croatia the lead against Spain in their last Euro fixture in Copenhagen 2021-06-28 18:10:49
ニュース BBC News - Home Euro 2020: 'What a strike!' Morata stunner gives Spain the lead once again https://www.bbc.co.uk/sport/av/football/57645895 Euro x What a strike x Morata stunner gives Spain the lead once againStriker Alvaro Morata produces an unstoppable finish from a tight angle to give Spain the lead in the first half of extra time against Croatia 2021-06-28 18:34:23
ビジネス ダイヤモンド・オンライン - 新着記事 企業ツイッター炎上を避ける5Sの掟、鎮火に役立つ3つの指針 - 共感で広がる公式ツイッターの世界 https://diamond.jp/articles/-/274751 東急ハンズ 2021-06-29 03:55:00
ビジネス ダイヤモンド・オンライン - 新着記事 コロナワクチンが証明した製薬業界の可能性 - WSJ PickUp https://diamond.jp/articles/-/275245 wsjpickup 2021-06-29 03:50:00
ビジネス ダイヤモンド・オンライン - 新着記事 演繹法人材の育成のヒントになる「キャリアの大三角形」 - シリコンバレーの流儀 https://diamond.jp/articles/-/275119 大三角形 2021-06-29 03:45:00
ビジネス ダイヤモンド・オンライン - 新着記事 その会社、本当にグリーンか 投資熱で拡大解釈 - WSJ PickUp https://diamond.jp/articles/-/275246 wsjpickup 2021-06-29 03:40:00
ビジネス ダイヤモンド・オンライン - 新着記事 ウィンドウズ11にヒットの予感、PCに大きな変化 - WSJ PickUp https://diamond.jp/articles/-/275247 wsjpickup 2021-06-29 03:35:00
ビジネス ダイヤモンド・オンライン - 新着記事 ひろゆきが語る「太っている人がやめられない悪習・ワースト1」 - 1%の努力 https://diamond.jp/articles/-/275205 youtube 2021-06-29 03:30:00
ビジネス ダイヤモンド・オンライン - 新着記事 首都圏「私立中高一貫校」のICT教育の現状、全121校をリサーチ - 中学受験への道 https://diamond.jp/articles/-/275179 中学受験 2021-06-29 03:30:00
ビジネス ダイヤモンド・オンライン - 新着記事 独学の達人が答える「本は紙と電子、どちらで読むべきか?」への納得回答 - 独学大全 https://diamond.jp/articles/-/270213 電子 2021-06-29 03:25:00
ビジネス ダイヤモンド・オンライン - 新着記事 「外食ばかりでも太らない人と太る人」決定的な差 - 医者が教えるダイエット 最強の教科書 https://diamond.jp/articles/-/275022 思い込み 2021-06-29 03:20:00
ビジネス ダイヤモンド・オンライン - 新着記事 圧倒的に“できる人”になる1つの考え方 - グロービス流「あの人、頭がいい!」と思われる「考え方」のコツ33 https://diamond.jp/articles/-/275012 圧倒的に“できる人になるつの考え方グロービス流「あの人、頭がいい」と思われる「考え方」のコツ効率よく仕事を進めたい、アイデアがパッとひらめくようになりたい、うまい受け答えができるようになりたい…。 2021-06-29 03:15:00
ビジネス ダイヤモンド・オンライン - 新着記事 ネットで死にかけ、ネットで復活した「奇跡のビジネス」とは? - ROCKONOMICS 経済はロックに学べ! https://diamond.jp/articles/-/275077 2021-06-29 03:10:00
ビジネス ダイヤモンド・オンライン - 新着記事 お金の流通速度を計る スピードメーター、 CCCとは何か? - たった10日で決算書がプロ並みに読めるようになる!会計の教室 https://diamond.jp/articles/-/275260 2021-06-29 03:05:00

コメント

このブログの人気の投稿

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