AWS |
AWS Compute Blog |
Coming soon: Expansion of AWS Lambda states to all functions |
https://aws.amazon.com/blogs/compute/coming-soon-expansion-of-aws-lambda-states-to-all-functions/
|
Coming soon Expansion of AWS Lambda states to all functionsIn November of we announced AWS Lambda function state attributes a capability to track the current “state of a function throughout its lifecycle Since launch states have been used in two primary use cases First to move the blocking setup of VPC resources out of the path of function invocation Second to allow the Lambda … |
2021-07-12 15:42:54 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
不等ピッチデータを想定した周波数変換手法の実装及びその評価[Python] |
https://qiita.com/CAYK/items/7dde8602ca41a1fd5790
|
interpolate関数を使うことで周波数の変換ができる不等ピッチデータに対してもinterpolate関数は有効ただし、補間の設定は理論式をもとに理論的に実施したほうが良い信号に含まれる周波数がナイキスト周波数に近いとリサンプリング精度が悪化する可能性もちろん、欠損しているデータが多ければ多いほどリサンプリングは困難になるおまけ周波数変換をする関数の紹介 これまで周波数変換をする過程でローパスフィルタを随所で適用したり、周波数変換のための補間関数を作ってきました。 |
2021-07-13 00:41:00 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
cv2やmatplotlibのマウスイベントのコールバック関数でグローバル変数を使わないで引数argと返り値returnを使う |
https://qiita.com/ryo_ryo/items/973007667c528ef23abb
|
cvやmatplotlibのマウスイベントのコールバック関数でグローバル変数を使わないで引数argと返り値returnを使う要約cvかmatplotlibで画像を表示して、点クリックするごとに線を引いて、その結果の線分のリストを得たかった。 |
2021-07-13 00:12:30 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
MW WP FORM 確認画面から「送信」ボタンを押すと入力画面に戻ってしまう。 |
https://teratail.com/questions/349132?rss=all
|
MWWPFORM確認画面から「送信」ボタンを押すと入力画面に戻ってしまう。 |
2021-07-13 00:53:54 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
ラズベリーパイ同士で動画をUDPストリーミング(送信raspivid、受信omxplayer)。受信したストリーミングをOPENCVで編集したい。 |
https://teratail.com/questions/349131?rss=all
|
ラズベリーパイ同士で動画をUDPストリーミング送信raspivid、受信omxplayer。 |
2021-07-13 00:51:34 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
C言語 '&'、'*' ポインタ関連の疑問あれこれ |
https://teratail.com/questions/349130?rss=all
|
C言語xampx、xxポインタ関連の疑問あれこれはじめにC言語のポインタを学習している際にふと気になった点があったので質問いたします。 |
2021-07-13 00:29:35 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
OpenGLでのテクスチャマッピング |
https://teratail.com/questions/349129?rss=all
|
ここにjpgファイルの画像をテクスチャマッピングしたいのですが、PTBのデモなどを調べてみてもよくわかりません。 |
2021-07-13 00:24:30 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
xcodeをアンインストール、インストールできない。 |
https://teratail.com/questions/349128?rss=all
|
xcode を アンインストール 、 インストール でき ない 。 |
2021-07-13 00:22:56 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
pythonでsoxを使用したいのですが、認識してくれません。 |
https://teratail.com/questions/349127?rss=all
|
pythonでsoxを使用したいのですが、認識してくれません。 |
2021-07-13 00:19:37 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
R studioにDESeq2のインストールができない |
https://teratail.com/questions/349126?rss=all
|
RstudioにDESeqのインストールができない前提・実現したいことここに質問の内容を詳しく書いてください。 |
2021-07-13 00:18:21 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
2つのdateframeの複数の行を比較して一致する行を取り出す |
https://teratail.com/questions/349125?rss=all
|
つのdateframeの複数の行を比較して一致する行を取り出す前提・実現したいことpythonでpandasを使って生徒の抽選を行うシステムを作っています。 |
2021-07-13 00:16:21 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
NuxtからLaravel apiへファイルのアップデートでcall to a member function getclientoriginalname() on null |
https://teratail.com/questions/349124?rss=all
|
|
2021-07-13 00:13:59 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
【Mac OS】pyinstallerで作成した.appが、配布先Macで動かない |
https://teratail.com/questions/349123?rss=all
|
【MacOS】pyinstallerで作成したappが、配布先Macで動かない前提・実現したいことpyinstallerで作成したmainappが配布先Macで動きません。 |
2021-07-13 00:11:14 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
batファイルのクラスパスを通したい |
https://teratail.com/questions/349122?rss=all
|
batファイルのクラスパスを通したい前提・実現したいことプログラミング初心者ですあるゲームのbatファイルを起動したいのですがnetbeansで作成したjarファイルを読み込んでくれません。 |
2021-07-13 00:06:58 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
【重要語句整理】AWS認定試験(ソリューションアーキテクト/アソシエイト) |
https://qiita.com/garlic_emperor/items/3ae5018eba6bcab7f687
|
認定試験 |
2021-07-13 00:33:44 |
Git |
Gitタグが付けられた新着投稿 - Qiita |
GitHubでやること |
https://qiita.com/jimaup/items/e7ce0cf10a5b6936d4a7
|
GitのインストールGitのwebサイトからgitforwindowsをダウンロードするダウンロードしたファイルのインストールを進める上記のコマンドでgitのバージョンが表示されたらインストール完了ですGitの設定まず下記urlからGitHubアカウントを作成しますGitHubサインアップページ作成したらアカウントのユーザー名とメールアドレスを設定しますterminalgitconfiglocalusernameユーザー名gitconfiglocaluseremailメールアドレスコミットなどのGitコマンドを使用する際にはこの情報を使用するため忘れずに設定しましょう。 |
2021-07-13 00:08:34 |
海外TECH |
DEV Community |
6 Topics Developers Should Prepare for Coding Interviews |
https://dev.to/javinpaul/6-topics-developers-should-prepare-for-coding-interviews-2fim
|
Topics Developers Should Prepare for Coding Interviewsimage credit Educative ioDisclosure This post includes affiliate links I may receive compensation if you purchase products or services from the different links provided in this article There is no doubt cracking the Coding interviews of top tech companies like Google Microsoft and Amazon is very hard but you can still crack it by carefully planning and preparing the essential skills which matter most like Data structures and Algorithms System Design Multithreading and Concurrency SQL and Database design and of course problem solving skills Being an author of Java and a programming blog I often receive queries about how to prepare for coding interviews How to pass Google or Microsoft Software Developer interviews Or how can I get a software development job on Amazon or Facebook After answering many of my readers one by one on Facebook and LinkedIn I thought to put together a list of essential topics for coding interviews This list will give a good head start for your preparation for any tech company interview like Google and Amazon However even if you are not targeting Google and just want a Software developer job you can still prepare these topics In fact preparing for tech giants like Google Amazon Apple and Facebook means you are miles ahead of other candidates and you will most likely secure many job offers from smaller firms startups and investment banks That s why I suggest aiming higher because even if you don t get what you want you will still get job offers that are desirable by many programmers Another critical thing to note is that different interviews need different skills For example when you go for a Java developer interview you are bound to know Java Similarly for a Python developer interview it s expected you to know Python and some popular Python frameworks like Django and Flask For a Web developer HTML CSS and JavaScript are core skills and you will be grilled on those apart from modern web development frameworks like Angular React and Vue js with a bit of node js as well I ll not touch that topic but I ll share essential skills that are required to pass all of those interviews They are also known as core programming skills and it s expected from every Software developer to know that Essential Topics for Coding and Programming InterviewsAnyway without wasting any more of your time here is my list of topics you can prepare to boost your chances on Google Amazon and Microsoft Programming Job Interviews Data StructureAs a programmer it s Ok if you cannot write web apps using Django or React but it s Not Ok if you don t know how a hash table works and when to use a list over an array And what advantages B Tree offers over an array Data Structure and Algorithms are the core of computer science and programming and it s expected for every software developer to have a solid knowledge of fundamental data structure It s imperative to have a good understanding of data structure for writing a robust performant application that your users will appreciate Imagine if Facebook or Google taking minute to log you in you will never go there forget how important they are Performance is critical and unless you understand how your program is working and how your data is stored you will not go anywhere In technical interviews you will be asked to optimize your solution for time and space You can t do that unless you have a solid understanding of how your code works and how data is stored and accessed This is probably the most important topic for coding interviews and you should prepare it well At a bare minimum you should know about the array linked list binary trees binary search tree self balanced trees like AVL tree hash table or map or dictionaries as known in Java and Python stack queue and graph You should understand how to store and access elements from these data structures and the computing cost involved You should also have a comparative analysis of when to use a particular data structure like for a faster search array and the hash table is better Still for faster addition and deletion a linked list will outperform an array If you need a resource to get up to speed I suggest you pick a data structure course where examples are shown in the language you are most comfortable with For Java developers I recommendData Structure and Algorithms Deep Dive in Java and for Python Programmers I recommend Algorithms and Data Structure in Python course on Udemy You can check out that course here AlgorithmsWhile it s important to know the essential data structure like an array linked list and trees it s equally important to learn how to work with those data structures If you don t know the difference between linear search and binary search algorithms and what it means to run in O log n as opposed to O n you need to spend some time learning algorithms This can often be the difference between a fine tuned application and a slow crappy process that hangs more than it works At a bare minimum you should know about sorting algorithms like quicksort mergesort heapsort etc searching algorithms like binary search and some graph algorithms like fastest route finding algorithms which are the base of many deliveries and taxi hailing apps like Uber Grab and Ola You should also understand how the library methods you are using for sorting an array work which algorithm it uses internally and when a different algorithm would do a better job I strongly suggest you prepare for this topic in depth If you need a resource Thomas H Cormen s Introduction to Algorithms is the most recommended resource but it s not for the faint hearted For a less intimidating entry I would recommend the Grokking Algorithms book by Aditya Bhargava and Algorithms course on Coursera System DesignThis is another crucial topic you need to prepare well for your programming job interviews especially at big tech companies like Google Microsoft Amazon and Facebook You need to have some ideas about how to design your solution from architecture to coding System design is actually very vast At a high level it covers things like software architecture I mean the advantage between monolithic and microservice architecture and choosing between a NoSQL and SQL database It covers things like how we will design an application that can handle concurrent users And includes things like scalability At a low level it covers Object Oriented Programming and Design which talk about designing your classes and their relationships following good coding practices and software design principles like SOLID Because of this many candidates struggle to answer system design questions and if you want to succeed you must put particular emphasis on this skill If you need a resource I recommend you to checking about the Grokking System Design Interview course on Educative which is prepared by people who served as hiring managers on those tech companies and it also walks you through common system design interview questions For Object Oriented design and analysis I recommend the Head First Object Oriented design book to learn fundamentals and Grokking the Object Oriented Interviews course on Educative for some practice Multithreading and ConcurrencyConcurrency is one of the most desired skills by employers and also one of the most advanced topics brought up in interviews Because it shows your ability to design a program that efficiently uses resources but at the same time it s a very tricky topic to master and that s why interviewers love it Concurrency can also be used to gauge your expertise and technical depth and is often uses as a key deciding factor in your overall hiring level Whether you are just entering your career or are looking to switch jobs it never hurts to dedicate some time to mastering concurrency At a bare minimum you should know about threads processes shared memory monitors locks critical section and deferred callbacks Having a good knowledge of how to avoid race conditions and deadlock can be even better Practicing classical concurrency interview questions like Producer Consumer Dining Philosopher and others can also teach you a lot about concurrency and multithreading and give you the confidence to visualize how code and data work when multiple threads run in parallel If you have an interviewing coming up then I highly suggest you double down on concurrency This is because I know it can be one of the most challenging topics brought up during most of the interviews even for experienced developers However gaining a mastering concurrency will put you at a considerable advantage over other candidates If you need resources I strongly suggest you check out Multithreading and Concurrency Interview Questions by C H Afzal on Educative This course contains the most common concurrency interview questions solved in Python Java C and Ruby Going through those questions will give you a good background on Concurrency and Multithreading SQL and Database DesignAs a software developer working with a relational database is a critical skill that you ll need and it will stick with you no matter where you are in your career Every company from small to large uses a DBMS so it s likely that you will come across different data models type so databases NoSQL and SQL and dependencies on various companies Knowing how to structure your data within a DBMS is critical Should you use an entity relationship ER model A hierarchical model A three schema architecture The choices can be intimidating but it s good to know about the different ways to structure your data as that when you switch database vendors like from Oracle to SQL Server or PostgreSQL you can plugin with minimal hand coding As a programmer you should also know about SQL not just the syntax but also how the database actually runs your query and how joins are executed how to index are used and the difference between table scan index scan and index seek These details are not just important from the coding interview perspective but also from day to day jobs If you need resources I suggest you go through with Database Design Fundamentals for Software Engineers where you will learn about the different concepts and techniques you can use to structure your data and explore why you should use particular approaches for certain problems You will also be exposed to technique likes normalization help to increase the efficiency o the database and avoid duplication I also suggest you go through an SQL focused course like The Complete SQL BootCamp by Jose Portilla on Udemy as SQL queries are also an essential part of coding interviews along with database design I also suggest Use The Index Luke book to better understand how SQL query works in general AWS Docker and KubernetesWhile these five are definitely must have skills for coding interviews employers are nowadays also looking for modern tech skills like AWS Docker and Kubernetes which makes them important topics for technical interviews Since cloud computing is the next big thing and this decade of software development will be cloud native it s better for a software developer to know about Cloud and modern deployment tools like Docker and Kubernetes This is also important if you want to stay ahead of the curve and give a reason to your employer to hire you than the next candidate in line For AWS and Cloud one more thing you can do is to get a certification not that because you can t get a job without certification but to learn better and get recognition for your skill For AWS I suggest you at least have an AWS Cloud Practitioner certification to showcase necessary cloud skills and if you prefer Microsoft Azure then Azure Fundamentals AZ is an excellent certification to start with Docker is a container which allows you to run your application as a whole along with all the dependencies This makes both development and deployment easier particularly for Microservices Since the container makes cloud deployment more manageable and they are also easier for the manager to scaling up and down Kubernetes is a container orchestration tool which means it can use manager containers at scale It s easy to deploy and manage a few boxes but when you have to deploy s of container for your application for a promotion event like Amazon prime Sale and then need to take it down once traffic return to normalcy is not easy Kubernetes can do that for you and provide automation and peace of mind While both Docker and Kubernetes are not mandatory skills for a programmer but definitely essential from the Job perspective I recommend every Software developer or aspiring programmer to learn Docker and Kubernetes and if you need a resource Stephen Grider s online course Docker and Kubernetes The Complete Guide on Udemy is a great starting point That s all about some of the most important skills and topics you can prepare to crack the coding interview of companies like Google Microsoft Apple Facebook and Amazon Along with sills I have also listed some of the best books and courses you can take to learn those skills and better prepared for your next coding interview Other Programming and Java Articles you May like courses to crack Coding Interviews in Websites to Practice Coding Problems Books to Prepare Technical Programming Coding Job Interviews Algorithm Books Every Programmer Should Read Top Data Structure and Algorithm Books for Java Developers My favorite free courses to learn Algorithms in depth Free Data Structure Courses for Java Developers Top Free Courses to learn AWS in Free Courses to learn Docker for Programmers Tips and Coding Problems to Crack Programming Interview Best System Design courses for Coding interviews Best Dynamic Programming Courses for Interviews Data Structure and Coding Problems for InterviewsThanks for reading this article so far If you find these Coding interview skills and topics useful then please share them with your friends and colleagues If you have any questions or feedback then please drop a note P S If you are aiming for FAANG Facebook Amazon Apple NetFlix and Google companies then I also suggest you join the Master the Coding Interview Big Tech FAANG Interviews course by Andrei Negaoie on ZTM Academy FAANG interviews are toughest to crack and this course is a valuable resource to crack FAANG interviews |
2021-07-12 15:51:32 |
海外TECH |
DEV Community |
Make a Discord bot in just 30 lines of code. |
https://dev.to/basecampxd/make-a-discord-bot-in-just-30-lines-of-code-jbj
|
Make a Discord bot in just lines of code Hey everyone today we are going to make a discord bot which will send gifs according to the user in just lines of code The way this bot will work is if you write gif happy then the bot will send a random happy gif What are we going to use to build this mini project JavaScriptNPM Packages Discord jsDOTENVnode fetchOkay so let s get started Steps We have to go to the discord developer portal and create a new application Then you have to create a new application the blue button on top right corner Give a name to your application Then on the left hand side click on bot After clicking on bot now click on Add Bot on the right hand side and after this step you will have a screen like this Now the Token is something which you have to keep a secret and not reveal anywhere or to anyone If you reveal it by mistake no worries just regenerate it but make sure you don t or else someone can take over your bot Now we have to decide what permissions does our bot need and after deciding this just head to OAuth section on the right hand side of your screen You will have a screen when many check boxes and you have to click on the checkbox which says bot Then click on the permission you have to give to the bot After that click on the link and copy it after that paste it into a new tab and authorize it to add it to a new server Now we just have to code it Before explaining the code let me explain you the folder structure There is a folder called src in which we have a main file called bot js in which we are going to code our bot Okay so you can see that there are two files and a folder named as package lock json package json and node modules respectively they are basically of node packages and their information There is also a env file but we will discuss about it later in this blog Okay so we have to use packages to make a discord bot they are as follows discord js npm i discord js dotenv npm i dotenv node fetch npm i node fetch Now using this image as my reference I am going to explain the code As you can see there are only lines of code How amazing it that Your own discord bot in just lines of code Okay so the first and the third line of code are the import statements which can also be written as import discord from discord js The second line of code is basically us initializing the client user which in this case will be our bot and the users themselves and the fourth line is importing the env package and configuring it so basically env files stores all your secrets like your discord bot s token or your API Key these things will not be uploaded on GitHub using the git ignore file Okay so in JavaScript there is this thing called addEventListner which helps us to react to certain events like if a user clicks on something or double tap on something a particular function should run In the same way here in discord js addEventListner is more or less replaced by on function All of the on functions are called in regards to the client so we have to write client on event callBackFunction On line number you can see that I have written a function which is This basically means that whenever the user is ready and logged in the console should log lt Name of the Bot gt is up and ready and name of the bot is fetched by this inbuilt property known as user tag which is to be called in regards to the client Now we have to make our bot login to the server And for that we have another inbuilt method function called login So we can write client login process env TOKEN Now you might wonder what is this process env TOKEN this is the way we call variables from our env file So let me show what is stored inside env file Here in this file we have to put our bot token inside a pair of single or double quotes and our tenor API key you can generate it from here For example if you want to call the tenor api key inside your bot js file you just have to write process env TENOR And you can make a try catch block around the client login function so if any error occurs we can catch it and show it on the console So as of now we have our boiler plate code ready with us which is Let s code the main functionality of the bot now Now all the code discussed below will be in the reference to this image Now let s understand the above code step by step Creating an add event listener to react when the user sends message Here the parameter msg will contain the message which user has sent Let s add a prefix to our bot so it will only react if we write gif Just to be a little safe I am going to write the main functionality inside a try catch block msg content helps us to fetch the content inside the msg In leman s term it is like innerText in JavaScript Here when the user will write gif the code inside the if statement will be executed Now let s get user s queries Now if a user writes gif batman then this will be considered as a string and a problem arises here which is how do we separate the bot command and the user s query We do that by an inbuilt function called split which will help us to separate the whole string into two different values stored in an array for example if I write gif batman then split will make an array gif batman Let s see it s code We are going to compare the first index of query which will be gif to the string gif Let s discuss about the API and Fetching it I am using node fetch to fetch the API The base of the API is key API KEYAnd in order to take query from the user and give the key as your API Key we have to make this URL dynamic We can do that by using template literals query amp key process env TENOR And now the code looks like this And the query has to be the second value First Index in the array Let s fetch the API now We just have to put async in front of the callback function as you can see in the above image on line number async will make your function asynchronous and then we will use await to wait for the response from the API Now here we will have a problem which is we will only receive one GIF every time Now the API will return GIFs and we have to pick a random one on line So to do this we will make a random variable which will choose one GIF Now the final code looks like Let s run this Just open the terminal change the directory to the home directory and inside src folder then write node bot js Thank you for reading the whole blog If you liked it do share it with your developer friends and feel free to comment and give suggestions |
2021-07-12 15:31:00 |
海外TECH |
DEV Community |
Creating custom form controls using ControlValueAccessor in Angular |
https://dev.to/angular/creating-custom-form-controls-using-controlvalueaccessor-in-angular-202
|
Creating custom form controls using ControlValueAccessor in AngularHow to create custom form controls in Angular using ControlValueAccessor We can create custom form components and connect them to either template driven forms or reactive forms So when I say custom form controls I am talking about those elements that are not your typical controls like input fields radio buttons or checkboxes For example a star rating component or a knob These are not available out of the box We can also make sections in a form as child components which can be then used as custom form controls In this way larger forms can be broken down into manageable pieces For all the default form controls like input field radio button checkbox select dropdown etc custom control value accessors are already written and shipped with Angular Eg CheckboxControlValueAccessor We will be talking more about ControlValueAccessor it and how to use it to create really cool form Custom Form ElementsWhen we hear the term form we would be thinking of few input text fields and maybe some checkboxes and stuff But when it comes to really complex forms where we have a lot of custom buttons lists and selections the whole form will become very complex And managing such a complex form would be a problem When there are a lot of custom form elements or when the form starts to get big it s probably a good idea to break it into smaller sections Placing everything in a single template would make it really messy We can break down the form into multiple components and then connect it with the main form Custom form control in AngularControlValueAccessor is something that comes with Angular It acts as a bridge between DOM elements and the angular Form API So If you have a custom element that you would like to connect to your form you have to make use of ControlValueAccessor to make the element compatible with Angular Forms API Doing so will enable the element to be connected using ngModel Template Driven Forms or formControl Reactive Forms Let s take a look at how do we create a custom form control When I started with Angular I was not aware that something like this existed I remember when I wrote child components for forms and used Input and Output to receive and send form values to the parent form component I used to listen to the changes in the child component and then emit the values to the parent In the parent the values will be taken and used to patch the form This was until I came across the magical ControlValueAccessor No more inputs and outputs everything just works Implement the ControlValueAccessor interface Step is to implement the interface in the custom component The interface would ask us to add few methods in our class interface ControlValueAccessor writeValue obj any void registerOnChange fn any void registerOnTouched fn any void setDisabledState isDisabled boolean void Let us see what each of the methods is doing Once we are clear on how things are we can dive into the implementation writeValue this function is called by the Forms API to update the value of the element When ngModel or formControl value changes this function gets called and the latest value is passed in as the argument to the function We can use the latest value and make changes in the component ref registerOnChange we get access to a function in the argument that can be saved to a local variable Then this function can be called when there are any changes in the value of our custom form control ref registerOnTouched we get access to another function that can be used to update the state of the form to touched So when the user interacts with our custom form element we can call the saved function to let Angular know that the element has been interacted with ref setDisabledState this function will be called by the forms API when the disabled state is changed We can get the current state and update the state of the custom form control ref Once we implement these functions the next step is to provide the NG VALUE ACCESSOR token in the component s providers array like so const COUNTRY CONTROL VALUE ACCESSOR Provider provide NG VALUE ACCESSOR useExisting forwardRef gt CustomFormControlComponent multi true Component selector app country selector template providers COUNTRY CONTROL VALUE ACCESSOR lt provided here export class CustomFormControlComponent implements ControlValueAccessor Note Here I created a provider constant and then passed it into the providers Also you can see the use of forwardRef ref here It is needed because we are referring to the CountrySelectorComponent class which is not defined before its reference So now that we know what each of these functions does we can start implementing our custom form element Basic FormWe are going to take a look at the base form that we are gonna work with We just have some basic input fields and custom form elements name Adithya github website server IN communications label Marketing modes name Email enabled true name SMS enabled false label Product Updates modes name Email enabled true name SMS enabled true This is how we need the data to be Here the server and the communications fields are going to be connected to a custom form control We are using Reactive Forms in the example Here is how our form will look like const form this fb group name github website server communications and in the template lt form formGroup form gt lt div class form group gt lt label for name gt Name lt label gt lt input type text id name formControlName name gt lt div gt lt div class form group gt lt label for github gt Github lt label gt lt input type url id github formControlName github gt lt div gt lt div class form group gt lt label for website gt Website lt label gt lt input type url id website formControlName website gt lt div gt lt div class form group gt lt label gt Region lt label gt lt app country selector formControlName server gt lt app country selector gt lt div gt lt div class form group gt lt label gt Communication lt label gt lt app communication preference formControlName communications gt lt app communication preference gt lt div gt lt form gt Notice in the above template we are directly using formControlName on the app country selector and app communication preference components This will be only possible if those components are implementing the ControlValueAccessor interface This is how you make a component behave like a form control Country Selector custom form controlWe are going to see how to implement a cool country selector component as a custom form control that can be directly connected to a form In this example I ll be using Reactive Forms The component is pretty straightforward we will give the user to select one country from a given list The behavior is similar to a radio button The only difference here is that we are using our own custom component to implement this design As always I start by creating a new module and component for our country selector form control Here is how we implement the ControlValueAccessor for our country selector component const COUNTRY CONTROL VALUE ACCESSOR Provider provide NG VALUE ACCESSOR useExisting forwardRef gt CountrySelectorComponent multi true We provide it in the providers array inside the Component decorator Component selector app country selector template lt div gt lt ng container ngFor let country of countries gt lt button disabled disabled click selectCountry country code class selected disabled amp amp selected country code gt lt ng container ngIf disabled amp amp selected country code gt lt Checkmark Icon gt lt ng container gt lt img src flag src alt country name gt lt p gt country name lt p gt lt button gt lt ng container gt lt div gt providers COUNTRY CONTROL VALUE ACCESSOR export class CountrySelectorComponent implements ControlValueAccessor countries code IN name India code US name United States code GB ENG name England code NL name Netherlands selected string disabled false private onTouched Function private onChanged Function selectCountry code string this onTouched lt mark as touched this selected code this onChanged code lt call function to let know of a change writeValue value string void this selected value IN registerOnChange fn any void this onChanged fn lt save the function registerOnTouched fn any void this onTouched fn lt save the function setDisabledState isDisabled boolean this disabled isDisabled If the user has given an initial value to server in the form we will get the initial value in the writeValue method We get the value and assign it to our local variable selected which manages the state When the user clicks on a different country we mark the field as touched and then assign the value to the selected variable The main part is we also call the onChanged method and pass the newly selected country code This will set the new value as the form control s value By using the argument from setDisabledState method we can implement the disabled state for our component So If we trigger disable from the form using this form get server disable Doing the above will trigger a call to setDisabledState method where the state isDisabled is passed which is then assigned to a local variable disabled Now we can use this local variable to add a class or disable the button setDisabledState isDisabled boolean this disabled isDisabled That is all We have successfully created a custom form control Check the GitHub repo for full code Communication Preferences custom form controlNow let s see how to implement the second custom form control in our form which allows user to select their communication preferences This is also a very simple component that has a bunch of checkboxes We could have added this in the same parent component where the form is initialized But by creating a separate component we are making it more maintainable const COM PREFERENCE CONTROL VALUE ACCESSOR Provider provide NG VALUE ACCESSOR useExisting forwardRef gt CommunicationPreferenceComponent multi true Component selector app communication preference template lt div gt lt ul gt lt ng container ngFor let item of options index as i gt lt li gt lt p gt item label lt p gt lt div gt lt ng container ngFor let mode of item modes index as j gt lt div gt lt input type checkbox id item label mode name ngModel mode enabled ngModelChange handleChange i j event gt lt label for item label mode name gt mode name lt label gt lt div gt lt ng container gt lt div gt lt li gt lt ng container gt lt ul gt lt div gt providers COM PREFERENCE CONTROL VALUE ACCESSOR export class CommunicationPreferenceComponent implements ControlValueAccessor options CommunicationPreference private onTouched Function private onChanged Function handleChange itemIndex number modeIndex number change any this onTouched this options itemIndex modes modeIndex enabled change this onChanged this options writeValue value any void this options value registerOnChange fn any void this onChanged fn registerOnTouched fn any void this onTouched fn Again it s the same thing we are doing we have an options variable that manages the local state of the component When there is any value change triggered by the form we get the new value in the writeValue method we update the local state with the changed value When the user makes any change we update the local state and call the onChanged method and pass the updated state which updates the form as well Find the complete code for the component in the repo Final ThoughtsAngular makes it really easy to implement custom form control using ControlValueAccessor By implementing few methods we can directly hook our component to a Reactive or Template Driven form with ease We can write all sorts of crazy form elements and use them without writing logic to handle communication between parent and child Let the forms API do the magic for us We can also use this approach to break sections of the form into their own individual component This way if the form is big complex we can break then down into smaller components that can be easily managed Code and DemoGithub Demo Connect with meTwitterGithubDo add your thoughts in the comments section Stay Safe ️ |
2021-07-12 15:18:13 |
Apple |
AppleInsider - Frontpage News |
iPhone 13, iMac, 14-inch MacBook Pro and more: what's coming from Apple in late 2021 |
https://appleinsider.com/articles/21/07/12/iphone-13-imac-14-inch-macbook-pro-and-more-whats-coming-from-apple-in-late-2021?utm_medium=rss
|
iPhone iMac inch MacBook Pro and more what x s coming from Apple in late Apple is months away from its expected refresh to the iPhone but many other products may also be launched at the same time and in the months ahead Here s what you can expect to see being released by Apple to the end of and beyond Apple CEO Tim CookWhile Apple is the target of many rumors reports and speculation about its product launches the claims reach fever pitch during the summer In the months ahead of Apple s annual fall introduction of new iPhone models more leaks surface claiming to show what will be making an appearance down the line Read more |
2021-07-12 15:51:00 |
Apple |
AppleInsider - Frontpage News |
Blix antitrust lawsuit targeting 'Sign in with Apple' is dismissed |
https://appleinsider.com/articles/21/07/12/blix-antitrust-lawsuit-targeting-sign-in-with-apple-is-dismissed?utm_medium=rss
|
Blix antitrust lawsuit targeting x Sign in with Apple x is dismissedA federal court has now dismissed BlueMail developer Blix s antitrust case against Apple and the App Store following a previous decision to dismiss the firm s patent infringement claims BlueMail by developer BlixFollowing Apple s launch of Sign in with Apple BlueMail developer Blix had filed a lawsuit alleging both patent infringement and that Apple was using anticompetitive practices in the App Store The patent elements were dismissed in March leaving solely the accusation that Apple was profiting from operating an unfair monopoly Read more |
2021-07-12 15:49:06 |
Apple |
AppleInsider - Frontpage News |
IDC: Mac shipments grow slightly year-over-year in Q2 |
https://appleinsider.com/articles/21/07/12/idc-mac-shipments-grow-slightly-year-over-year-in-q2?utm_medium=rss
|
IDC Mac shipments grow slightly year over year in QApple continues to benefit from a PC demand surge but growth appears to be slowing down for the greater PC market a new report suggests Mac growth continues thanks to market demand and new device releasesDemand for PCs can be attributed to the ongoing pandemic and the shift to work from home Apple has also gained market attention from its transition to Apple Silicon processors in its Mac lineup Read more |
2021-07-12 15:55:17 |
Apple |
AppleInsider - Frontpage News |
Lowest price ever: Apple's M1 Mac mini (512GB SSD) drops to $749 at Amazon |
https://appleinsider.com/articles/21/07/12/lowest-price-ever-apples-m1-mac-mini-512gb-ssd-drops-to-749-at-amazon?utm_medium=rss
|
Lowest price ever Apple x s M Mac mini GB SSD drops to at AmazonAmazon s Monday deals see a steeper price drop on Apple s latest Mac mini Save instantly on the M model with a GB SSD delivering the lowest price ever just in time for back to school Mac mini price dropEquipped with the M chip GB of RAM and GB of storage this current Mac mini is a popular choice for those wanting to pair the compact desktop with a sizeable monitor or two for ample screen real estate Read more |
2021-07-12 15:08:34 |
Apple |
AppleInsider - Frontpage News |
Outage of iCloud Mail stops some users from getting their messages |
https://appleinsider.com/articles/21/07/12/outage-of-icloud-mail-stops-some-users-from-getting-their-messages?utm_medium=rss
|
Outage of iCloud Mail stops some users from getting their messagesA number of users are experiencing issues when using iCloud Mail with some customers unable to log in to their mail account via the Mail app or third party apps Starting from AM eastern time on Monday Apple s System Status page advises of an issue with iCloud Mail According to the notification the issue is ongoing and some users are unaffected The nature of the problem isn t disclosed other than Users may be unable to access iCloud mail It also appears to be a problem limited just to iCloud Mail with other iCloud online services appearing to be working with no reported faults Read more |
2021-07-12 15:52:30 |
海外TECH |
Engadget |
Elon Musk booked a trip to space with Virgin Galactic |
https://www.engadget.com/elon-musk-virgin-galactic-spaceflight-ticket-152514962.html?src=rss
|
Elon Musk booked a trip to space with Virgin GalacticYou d think that Elon Musk and Richard Branson would hold grudges against each other when they both have space tourism plans but that s not true ーif anything they re surprisingly buddy buddy Virgin Galactic told the Wall Street Journal in a statement that Musk bought a ticket aboard the company s air launched rockets It s not certain just where the SpaceX founder is in the queue but it s safe to say his ride will garner some attention The feeling is mutual In an interview with the Sunday Times Branson said Musk was a quot friend quot and suggested he might fly on a SpaceX ship quot one day quot He even went so far as to tweet a photo showing him and Musk together Just don t expect that kind of warmth and camaraderie from Jeff Bezos Blue Origin was more than a little eager to trash talk Virgin ahead of its first fully crewed spaceflight claiming that Branson and team were merely brushing the edge of space While the company later wished Branson a quot great flight quot we wouldn t expect Bezos and Branson to have heart to heart coffee chats any time soon It s not a complete shock that Branson and Musk would be so cozy However well their personalities mesh the two aren t quite direct competitors Virgin Galactic is aimed primarily at space tourists content with suborbital flights while Virgin Orbit is focused on launching satellites for outfits that can t justify expensive conventional rockets SpaceX meanwhile has focused its tourism efforts on lunar flybys and usually carries costlier payloads into space This isn t to say the two execs will start feuding if their businesses truly overlap ーjust don t count on the positive vibes lasting forever Big day ahead Great to start the morning with a friend Feeling good feeling excited feeling ready Watch Unity launch and livestream TODAY at am PT am ET pm BST virgingalactic elonmuskpic twitter com FRQqrQEbHーRichard Branson richardbranson July |
2021-07-12 15:25:14 |
金融 |
金融庁ホームページ |
九州財務局が令和3年7月1日からの大雨にかかる災害等に対する金融上の措置について要請しました。 |
https://www.fsa.go.jp/news/r3/ginkou/20210712.html
|
九州財務局 |
2021-07-12 16:34:00 |
金融 |
金融庁ホームページ |
「新型コロナウイルス感染症関連情報」特設ページを更新しました。 |
https://www.fsa.go.jp/ordinary/coronavirus202001/press.html
|
新型コロナウイルス |
2021-07-12 15:30:00 |
金融 |
金融庁ホームページ |
新型コロナウイルス感染症に関連する有価証券報告書等の提出期限について公表しました。 |
https://www.fsa.go.jp/news/r3/sonota/20210712.html
|
新型コロナウイルス |
2021-07-12 15:30:00 |
ニュース |
BBC News - Home |
Covid: England lockdown rules to end on 19 July, Sajid Javid says |
https://www.bbc.co.uk/news/uk-57809691
|
england |
2021-07-12 15:44:12 |
ニュース |
BBC News - Home |
Jacob Zuma: Military deployed to tackle unrest over jailed ex-president |
https://www.bbc.co.uk/news/world-africa-57803513
|
presidentshops |
2021-07-12 15:26:36 |
ニュース |
BBC News - Home |
Gareth Southgate: England boss hopes to lead team at 2022 Qatar World Cup |
https://www.bbc.co.uk/sport/football/57802291
|
world |
2021-07-12 15:44:42 |
ニュース |
BBC News - Home |
Euro 2020: Jubilant Italy fans celebrate victory over England |
https://www.bbc.co.uk/news/world-europe-57800151
|
england |
2021-07-12 15:30:51 |
ニュース |
BBC News - Home |
Covid: What's the roadmap for lifting lockdown? |
https://www.bbc.co.uk/news/explainers-52530518
|
england |
2021-07-12 15:13:47 |
ニュース |
BBC News - Home |
Should I still wear a face mask or covering and what are the rules? |
https://www.bbc.co.uk/news/health-51205344
|
indoor |
2021-07-12 15:20:03 |
北海道 |
北海道新聞 |
東京五輪、不安抱え準備最終段階 開幕まで10日、配置見直し急務 |
https://www.hokkaido-np.co.jp/article/566261/
|
新型コロナウイルス |
2021-07-13 00:02:48 |
北海道 |
北海道新聞 |
殺害された妻 死因は窒息死 札幌・西区 |
https://www.hokkaido-np.co.jp/article/566300/
|
札幌市西区 |
2021-07-13 00:09:00 |
Azure |
Azure の更新情報 |
General availability: HPC Cache for NVME-based Storage, Storage Target Management, and HIPAA Compliance |
https://azure.microsoft.com/ja-jp/updates/general-availability-hpc-cache-for-nvmebased-storage-storage-target-management-and-hipaa-compliance/
|
General availability HPC Cache for NVME based Storage Storage Target Management and HIPAA ComplianceThe latest release of HPC Cache adds support for high throughput VMs as well as enhancements to storage target operations |
2021-07-12 15:37:42 |
Azure |
Azure の更新情報 |
HPC Cache on E-Series VMs Support of Blob NFS 3.0 now generally available |
https://azure.microsoft.com/ja-jp/updates/hpc-cache-on-eseries-vms-support-of-blob-nfs-30-now-generally-available/
|
azure |
2021-07-12 15:37:03 |
コメント
コメントを投稿