投稿時間:2021-12-16 23:36:30 RSSフィード2021-12-16 23:00 分まとめ(44件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
AWS AWS Database Blog How Near reduced latency by four times and achieved 99.9% uptime by migrating to Amazon ElastiCache https://aws.amazon.com/blogs/database/how-near-reduced-latency-by-four-times-and-achieved-99-9-uptime-by-migrating-to-amazon-elasticache/ How Near reduced latency by four times and achieved uptime by migrating to Amazon ElastiCacheThis is a guest post by Ashwin Nair Director Product Engineering at Near in partnership with AWS Senior Solutions Architect Kayalvizhi Kandasamy For several years Near operated multiple Kyoto Tycoon clusters for its real time bidding RTB platform To improve availability and reduce latency Near migrated to Amazon ElastiCache a fully managed in memory caching service In … 2021-12-16 13:56:32
python Pythonタグが付けられた新着投稿 - Qiita 単純なカウンターのインクリメントの並行処理がアトミックでないことの確認 https://qiita.com/takkeybook/items/34d518dd713989b7214d オリジナルのコードにtypesWrapperDescriptorTypeを追加しています。 2021-12-16 22:50:50
python Pythonタグが付けられた新着投稿 - Qiita Pythonエンジニア認定基礎試験を受けてきました。 https://qiita.com/nozomu_tk/items/d3a055a7f0e40f5f3e59 公式チュートリアル模擬試験PRIMESTUDYDIVEINTOEXAMTRAINOCAMP学習方法Pythonに興味があったので業務の簡単ツールをPythonで作ったりしていたので本当に基礎の構文は知っていました。 2021-12-16 22:11:02
js JavaScriptタグが付けられた新着投稿 - Qiita モダンな(ES6以降の)Node.jsでJestを実行する ESLintの設定も https://qiita.com/yuta-katayama-23/items/cd0a6ddff909b21b3b40 JestでES以降のコードをテストするにはテスト対象のコードがES以降の書き方で実装されている場合、どうやってJestを実行すればいいのかだが、これはNodejsをES以降の書き方で実装するにはと全く同じで、Babelを使ってトランスパイルをしてあげればいい。 2021-12-16 22:42:28
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) WordPress(ローカル環境) のカスタムフィールド(ACF)の画像を読み込む処理が終わらない問題について皆様の知恵をお借りしたいです! https://teratail.com/questions/374201?rss=all WordPressローカル環境のカスタムフィールドACFの画像を読み込む処理が終わらない問題について皆様の知恵をお借りしたいですWordPressローカル環境でオリジナルテーマを開発しているのですが、この画像にある画像を追加するをクリックするとすべての日付の右にある読み込みマークがずっと出続けて画像を読み込んでくれません。 2021-12-16 22:56:47
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) DockerでDB接続失敗によりコンテナの起動に失敗する https://teratail.com/questions/374200?rss=all DockerでDB接続失敗によりコンテナの起動に失敗するDockerの勉強をしているものです。 2021-12-16 22:50:40
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) patternfileを使ったShift-JISファイルを対象としたGrep検索 https://teratail.com/questions/374199?rss=all patternfileを使ったShiftJISファイルを対象としたGrep検索実現したいことpatternfileを使ったShiftJISファイルを対象としたGrep検索発生している問題下記のコマンドでGrep検索を実行しました。 2021-12-16 22:43:48
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) スクレイピングしたいのですが要素が見つからない。「検証」では出るがソースでは出ない https://teratail.com/questions/374198?rss=all 「検証」では出るがソースでは出ない前提・実現したいことあるサイトをスクレイピングしたいのですが、要素が見つからないと出ます。 2021-12-16 22:39:59
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) option内のonclickが反応しない https://teratail.com/questions/374197?rss=all option内のonclickが反応しないPHPを使って、optionにonclickでつの要素を持たせたまま今のページに飛びたいのですが、onclickが反応しません。 2021-12-16 22:36:12
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) 深層学習 学習が進むということはデータに法則性がある? https://teratail.com/questions/374196?rss=all 2021-12-16 22:36:08
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) <Laravel>コマンドプロントを使ってデータベースを作りたい https://teratail.com/questions/374195?rss=all ltLaravelgtコマンドプロントを使ってデータベースを作りたいLaravelとコマンドプロントでデータベースを作りたいのですがコマンドプロントでphpnbspartisannbspmigrateを実行すると下記のエラーがでて作成することができません、どうしたらエラーを解消できるか教えていただけますと幸いです。 2021-12-16 22:21:05
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) カスタム投稿の月別一覧の翌月の一覧を表示させたい https://teratail.com/questions/374194?rss=all カスタム投稿の月別一覧の翌月の一覧を表示させたい下記を参考に、今月、前月の月別一覧を表示することはできたのですが、翌月の一覧を出す方法がわかりません。 2021-12-16 22:10:25
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) VScode Remote Developmentについて https://teratail.com/questions/374193?rss=all 2021-12-16 22:04:02
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) no new line at end of file の表示を消すことができない https://teratail.com/questions/374192?rss=all nonewlineatendoffileの表示を消すことができないDockerを使ってrailsアプリの開発を行っているのですが、gitにpushを行った際に、gitihub上にnonbspnewnbsplinenbspatnbspendnbspofnbspfileマークが表示されてしまい、これを消したいと思っています。 2021-12-16 22:03:15
AWS AWSタグが付けられた新着投稿 - Qiita 【Rails×AWS】capistranoでデプロイ時のNoMethodError: Cannot load database configuration https://qiita.com/Yuya-hs/items/49898d9f1a4227cdec9a 【Rails×AWS】capistranoでデプロイ時のNoMethodErrorCannotloaddatabaseconfiguration初めてcapistranoでECにデプロイするときにハマったエラーがあったので解決方法ともに共有しようと思います。 2021-12-16 22:30:08
Ruby Railsタグが付けられた新着投稿 - Qiita 【Rails×AWS】capistranoでデプロイ時のNoMethodError: Cannot load database configuration https://qiita.com/Yuya-hs/items/49898d9f1a4227cdec9a 【Rails×AWS】capistranoでデプロイ時のNoMethodErrorCannotloaddatabaseconfiguration初めてcapistranoでECにデプロイするときにハマったエラーがあったので解決方法ともに共有しようと思います。 2021-12-16 22:30:08
技術ブログ Mercari Engineering Blog QAチーム設立21年目のサイボウズ×3年目のメルペイに聞くQAエンジニアの役割とは?#cybozu_merpay https://engineering.mercari.com/blog/entry/20211215-8e20e5a371/ hellip 2021-12-16 13:00:50
技術ブログ Developers.IO ブログネタ、どうやって考えてますか? – DevelopersIO 著者のみんなに色々聞いてみた Advent Calendar 2021 https://dev.classmethod.jp/articles/interviews-with-classmethod-developersio-bloggers-day16/ adventcalend 2021-12-16 13:30:18
海外TECH Ars Technica Rigetti announces 80 qubit processor, experiments with “qutrits” https://arstechnica.com/?p=1821077 qubit 2021-12-16 13:25:16
海外TECH MakeUseOf How to Share Google Drive Files With Non-Gmail Accounts https://www.makeuseof.com/how-to-share-google-drive-non-gmail-accounts/ gmail 2021-12-16 13:30:12
海外TECH DEV Community 🔥🤯 Amazing Portfolio website using HTML, CSS and JS. https://dev.to/kunaal438/amazing-portfolio-website-using-html-css-and-js-l8f Amazing Portfolio website using HTML CSS and JS If you are a beginner or a pro This blog is for everyone who want to make his her portfolio an outstanding one In this tutorial you ll learn to create your own modern looking portfolio website using HTML CSS and JS In the article you ll learn to create smooth transition on navigations you ll create CSS timeline to showcase your education and experience you ll make a separate section for your project with a cool hover effect You must make this portfolio to impress your recruiter So without wasting more time let s start To see project demo or for better understanding of code you can watch the tutorial below Video TutorialI appreciate if you can support me by subscribing my youtube channel Source Code CodeSo let s start by making navbar for the site But before that you should know our files and folders You can download the images here NavbarSo let s start to create navbar first write the HTML basic template and link style css and app js file to index html file After done with all of this Create navbar lt navbar gt lt nav class navbar gt lt ul class link group gt lt li class link active gt lt a href gt home lt a gt lt li gt lt li class link gt lt a href gt projects lt a gt lt li gt lt li class link gt lt a href gt about lt a gt lt li gt lt li class link gt lt a href gt contact lt a gt lt li gt lt ul gt lt nav gt Okay we are done with HTMl so add some style to it also margin padding box sizing border box body width max width px display block margin auto min height vh background font family sans serif navbar width position fixed top left display flex justify content center align items center z index background aaa link group list style none display flex link a color fff opacity text decoration none text transform capitalize padding px px margin px line height px transition s font size px link a hover link active a opacity After done with this you ll probably see something like this Okay so with that we are done with navbar So let s move on to our home section home sectionTo create home section code this HTML structure after navbar element lt home section gt lt section class home section active gt lt h class hero heading gt hello i am lt br gt kunaal lt h gt lt img src img home png class home img alt gt lt section gt And give it some styles home section width height vh padding px display flex align items center position relative top opacity transition s hero heading color fff font size px text transform capitalize font weight home img position absolute top right height vh width object fit cover opacity If you see the above code you ll see position relative and top under home section These properties are important while navigation cause how will our navigation work is little complex All of our sections home project about contact all of these will have position fixed because of this all sections will be on top of each other And we ll use active class to indicate the active section Using active class we ll set section s position s to relative along with its opacity to This is how our navigation will work Isn t is complicated OutputSo once you are done with home section make sure you change its position to fixed from relative home section previous styles position fixed Then make active class styles home section active project section active about section active contact section active position relative opacity z index You can see I have added each and every section here in order to make smooth navigation Project sectionNow let s make project section For that code this HTML lt project section gt lt section class project section gt lt h class project heading gt some of my projects lt h gt lt div class project container gt lt div class project card gt lt img src img project png class project img alt gt lt div class project content gt lt h class project title gt project lt h gt lt p class project info gt Lorem ipsum dolor sit amet consectetur adipisicing elit Impedit vitae delectus cumque repudiandae aliquam optio accusamus natus nobis Nam sunt lt p gt lt div class project btn grp gt lt button class project btn github gt github repo lt button gt lt button class project btn live gt see live lt button gt lt div gt lt div gt lt div gt more cards lt div gt lt section gt Also style it project section project section width min height vh padding px px px position fixed top transition s opacity project heading font size px background text transform capitalize text align center margin bottom px color aaa background clip text webkit background clip text webkit text stroke px transparent project container display grid grid template columns repeat fr grid gap px project card height px position relative project img width height position absolute top left object fit cover transition s project content position relative padding px color fff transition s opacity project title font size px text transform capitalize text align center font weight project info margin px font size px line height px text align center project btn grp display grid grid template columns repeat fr grid gap px project btn height px text transform capitalize font size px border none background color fff cursor pointer project btn live background none border px solid fff project card hover project img filter blur px project card hover project content opacity In the above code I have already added fixed position to project section and defined its opacity to But for you in order to see the output make sure you add active class in project section like this lt section class project section active gt Output With hover effect NavigationBefore going forward let s make the navigation system first For that code this inside app js file const links document querySelectorAll link const sections document querySelectorAll section let activeLink links forEach link i gt link addEventListener click gt if activeLink i links activeLink classList remove active link classList add active sections activeLink classList remove active setTimeout gt activeLink i sections i classList add active In the above code first I am selecting all the links and sections After that I defined activeLink this variable will track the current active section or link After that I used forEach method to loop through all the links Inside that I am access individual link and its index Inside it first I am adding click event to link using addEventListener Then I used a simple condition to make sure user is not clicking on the active link After that I am removing the active class from the current active link using classList remove and adding active class to the clicked link using classList add I am doing the same to remove the active class from the active section Once done with that I am using setTimeout to add a s delay in executing the below codes Inside the timeout it is just simply adding the active class again You might see the navigation as a very easy one but it was the second hardest thing to make in this project About section Now let s create the about section Honestly my favourite section in this entire website is this about section Our about section has everything it has skills section and also a education timeline To create about section code this after project section lt about section gt lt section class about section gt lt div class about gt lt div class about img container gt lt img src img home png class about img alt gt lt button class download cv btn gt downlaod cv lt button gt lt div gt lt p class about info gt Lorem ipsum lt p gt lt div gt lt section gt And style it about section about section width min height vh padding px px position fixed top opacity transition s about width display grid grid template columns grid gap px about img container position relative about info color fff opacity font size px line height px about img width height object fit cover border radius px download cv btn position absolute bottom px left transform translateX padding px px color fff border none font size px text transform capitalize cursor pointer transition s background rgba download cv btn hover background Again you might not see anything make sure to add active class to about section and remove it from all other sections OutputSo now shall we create the skills section Well in our skills section I do not have any skill progress bar which is I think is most used thing in the portfolio But I think its the worst thing to have I somewhere read on internet that the progress bar might look awesome to you but let say it know python and you add it to your website saying you know of python There is a change that your client think you know python so maybe you don t know the advance topic although you know the advance topics too So its create a confusion Well its just a preference Anyway let s make the skills section lt skills gt lt div class skill section gt lt h class heading gt skills lt h gt lt div class skills container gt lt div class skill card gt lt img src img html png class skill img alt gt lt div class skill level gt lt div gt lt h class skill name gt HTML lt h gt lt p class skill info gt Lorem ipsum dolor sit amet consectetur adipisicing elit Consequatur delectus lt p gt lt div gt more cards lt div gt lt div gt Code the above code under about section element and style them skills skill section position relative margin px heading text align center font size px color fff text transform capitalize font weight margin bottom px skills container width margin auto display grid grid template columns repeat fr grid gap px color fff skill card position relative skill img display block margin auto height px skill name font size px font weight text align center text transform capitalize margin px px skill info text align center opacity font size px line height px skill level position absolute top px right width px height px display flex justify content center align items center font size px border radius border px solid skill card nth child skill level background ffff border color ffff color ffff skill card nth child skill level background faff border color faff color faff skill card nth child skill level background ffedf border color ffedf color ffedf skill card nth child skill level background fff border color fff color fff skill card nth child skill level background fdfff border color fdfff color fdfff OutputAnd now the hardest thing CSS timeline It was little hard for me to make at first but I tried my best not to use lot of code to achieve the goal lt timeline gt lt div class timeline gt lt h class heading gt education and experience lt h gt lt div class card gt lt div class card body gt lt h class card title gt lt h gt lt p class card detail gt Lorem ipsum dolor sit amet consectetur adipisicing elit Architecto sequi recusandae laborum ipsam dignissimos nostrum vitae provident officia consectetur ab accusantium corrupti exercitationem temporibus repellat non magni cupiditate ea reprehenderit lt p gt lt div gt lt div gt more cards lt div gt Make sure to add these codes inside about section also timeline timeline display block width margin px auto timeline heading margin bottom px card width padding px border radius px color fff display block margin px position relative background f card nth child even margin left auto card nth child even before content position absolute left top transform translateY width px height px border px solid border radius card nth child even after content position absolute left top transform translateY width height px background fff z index card nth child odd before content position absolute right top transform translateY width px height px border px solid border radius card nth child odd after content position absolute right top transform translateY width height px background fff z index card nth child card nth child before background ffff card nth child card nth child before background ffbf card nth child card nth child before background dcac card nth child card nth child before background card nth child card nth child before background faff card nth child even card body before content position absolute left top width px height border px dashed fff z index card title font size px font weight margin bottom px Output Contact sectionAnddddddd the last part contact section Let s create this also lt contact section gt lt section class contact section gt lt form class contact form gt lt input type text name name id name autocomplete off placeholder name gt lt input type text name email id email autocomplete off placeholder email gt lt textarea name msg id msg placeholder message autocomplete off gt lt textarea gt lt button type submit class form submit btn gt contact lt button gt lt form gt lt map gt lt div class map gt lt iframe src m m m d d d m f f f m i i f m m sxcfdbebd Axb sDelhi e m sen sin v m sen sin width height style border allowfullscreen loading lazy gt lt iframe gt lt div gt lt section gt By the way the above iframe code is the google map embed link You can get it using google map contact section position absolute top opacity transition s padding px px height vh display grid grid template columns repeat fr grid gap px contact form input contact form textarea width height px background rgba border px solid fff margin bottom px border radius px text transform capitalize color fff padding px px placeholder color fff msg height px resize none font family sans serif form submit btn background ffff color fff text transform capitalize padding px px display block margin auto border none border radius px cursor pointer map width height padding px border px solid fff background rgba border radius px map iframe width height border radius px OutputSo that s it Great work guys We are done with the portfolio I hope you understood each and everything If you have doubt or I missed something let me know in the comments Articles you may find UsefulBest CSS EffectInfinte CSS loaderDisney CloneYoutube API Youtube CloneTMDB Netflix CloneI really appreciate if you can subscribe my youtube channel I create awesome web contents Source CodeThanks for reading 2021-12-16 13:44:31
海外TECH DEV Community Next SEO: A better way to Manage SEO for Next.js 🔍 https://dev.to/avneesh0612/next-seo-a-better-way-to-manage-seo-for-nextjs-4nc Next SEO A better way to Manage SEO for Next js The Next js head tags are a good way to add the meta tags title description open graph image etc but you might not remember all the meta tags and it can also look messy so we are going to see how to simplify this process using a package called next seo Installing the packageAs it is an external library we need to install it npm i next seo Using next SEOI like to add all the properties in app js so it automatically works on all pages and to modify some data for pages I add it to that page Now let s see how to use it Inside app js in the return block add this lt NextSeo title Avneesh Agarwal titleTemplate Avneesh Agarwal defaultTitle Avneesh Agarwal description A full stack web developer who loves to design and develop beautiful websites I have been coding for over a year now One of my hobbies is writing I love to document my journey by writing blog posts and also teach others through them canonical openGraph url title Avneesh Agarwal description A full stack web developer who loves to design and develop beautiful websites I have been coding for over a year now One of my hobbies is writing I love to document my journey by writing blog posts and also teach others through them images url og image png width height alt Avneesh Agarwal twitter handle avneesh site avneesh cardType summary large image gt If you didn t have a wrapper fragment then you need to wrap this and lt Component pageProps gt like lt gt lt NextSeo title Avneesh Agarwal titleTemplate Avneesh Agarwal defaultTitle Avneesh Agarwal description A full stack web developer who loves to design and develop beautiful websites I have been coding for over a year now One of my hobbies is writing I love to document my journey by writing blog posts and also teach others through them canonical openGraph url title Avneesh Agarwal description A full stack web developer who loves to design and develop beautiful websites I have been coding for over a year now One of my hobbies is writing I love to document my journey by writing blog posts and also teach others through them images url og image png width height alt Avneesh Agarwal twitter handle avneesh site avneesh cardType summary large image gt lt Component pageProps gt lt gt You will also need to import it import NextSeo from next seo What each of the props doestitle This is the title of the webpage that you can see in the browser and when you share it as a linktitleTemplate title template is the same as the titledefaultTitle If you don t provide any title on some page then this will be used there description This is the description of the site which helps search engines find the websites and is also shown when you share the URL canonical This should be the domain of your website in most cases but suppose you are republishing a post then this would link to the original post openGraph This takes in an object of data like title description image This data will be used to show when you share these links on discord Twitter Facebook WhatsApp Slack etc Twitter Here you can define your username site and how the card should look In most cases summary large image works fine Changing data based on pagesSuppose you want to change the title or description of a page you can add in the NextSeo with the tags you want to change For example I want to change the title to About Me I will add this to the about js page lt NextSeo title About Me gt You can pass in as many props depending on what you need to change D ConclusionHope you found this article useful See ya next time ️ Useful linksNext SEO packageNext js SEO courseConnect with me 2021-12-16 13:38:16
海外TECH DEV Community All About Validators in Angular + Creating Custom Sync & Async Validators https://dev.to/angular/all-about-validators-in-angular-creating-custom-sync-async-validators-275e All About Validators in Angular Creating Custom Sync amp Async ValidatorsValidators in angular are just simple functions that check our form values and return an error if some things are not the way its meant to be Angular ships with a bunch of Validators out of the box These can be used directly without the need for any configuration Using validators in angular formsValidators can be set up in different ways to validate user inputs in form elements Angular provides a lot of validators that are commonly needed for any form If we special validation requirements or if we are dealing with custom components the default validators might not just cut it We can always create custom validators for these cases In built validators of angularAngular ships with different validators out of the box both for use with Template forms as well as Reactive forms In built Validator Directives A set of validator functions exported via the Validators class Both the directives and Validators class use the same function under the hood We can provide multiple validators for an element What Angular does is stack up the validators in an array and call them one by one Validator DirectivesNative HTML form has inbuilt validation attributes like required min max etc Angular has created directives to match each of these native validation attributes So when we place these attributes on an input Angular can get access to the element and call a validation function whenever the value changes Here s how you would use a validator directive lt input type email required minlength ngModel email gt The attributes required and minlength are selectors for the RequiredValidator ref and MinLengthValidator ref directives respectively These can be used with both Template drive forms and Reactive Forms Here s how the requireddirective looks like Directive providers provide NG VALIDATORS useExisting forwardRef gt RequiredValidator multi true export class RequiredValidator implements Validator validate control AbstractControl ValidationErrors null return this required requiredValidator control null Let s break down the code The class RequiredValidator implements an interface called Validator The Validator interface forces the class to implement a validate method The method will be called for validation of the value The validation logic can be performed in the method and just have to return an object if there is an error or null if there is no error Now we need to let Angular know about this custom validation that we ve set up We use the NG VALIDATORS Injection token for this We ask Angular to use our same RequiredValidator class by using the useExisitng property So when the user places required on a form control the RequiredValidator directive gets instantiated and the validator also gets attached to the element Take a look into the source code for Required Validator ref Validators classValidators class exposes a set of static methods that can be used when dealing with Reactive Forms like so import FormControl Validators from angular forms export class AppComponent email new FormControl Validators required Validators minLength Here s the list of all the function inside the class class Validators static min min number ValidatorFn static max max number ValidatorFn static required control AbstractControl ValidationErrors null static requiredTrue control AbstractControl ValidationErrors null static email control AbstractControl ValidationErrors null static minLength minLength number ValidatorFn static maxLength maxLength number ValidatorFn static pattern pattern string RegExp ValidatorFn static nullValidator control AbstractControl ValidationErrors null static compose validators ValidatorFn ValidatorFn null static composeAsync validators AsyncValidatorFn AsyncValidatorFn null Custom Sync ValidatorsWe can also create custom validators in Angular which are tailored to our particular use case You can t just always rely on the built in capabilities of Angular Validators are just functions of the below type export interface ValidatorFn control AbstractControl ValidationErrors null Let s create a custom validator function that checks if a domain is secure https or not export const ProtocolValidator ValidatorFn control gt const value control const isSecure value as string startsWith https return isSecure null protocol Should be https URI Custom validator with parametersIf we want our custom validator to be more configurable and re use in multiple places we can pass parameters to our validator function to create a validator based on the provided parameters For example if the Secure validator needs to validate Websocket URIs also we can modify the ProtocolValidator to accommodate this change export const ProtocolValidator protocol string ValidatorFn gt control gt const value control const isSecure value as string startsWith protocol return isSecure null protocol Should be protocol URI Use custom validators in Reactive FormsWe can directly use the function in the reactive forms like so const urlControl new FormControl Validators required ProtocolValidator https and the template will be something like this lt input type text formControl urlControl gt Use custom validator in Template driven FormsIf we want to use these validators with Template drive forms we need to create a directive Directive selector protocol providers provide NG VALIDATORS useExisting forwardRef gt ProtocolValidatorDirective multi true export class ProtocolValidatorDirective implements Validator Input protocol string validate control AbstractControl ValidationErrors null return ProtocolValidator this protocol control and we use it like this lt input type text protocol wss ngModel url gt Note For the directive selector it s always a good idea to also look for whether there is a valid form connector added to the element Directive selector protocol formControlName protocol formControl protocol ngModel What this translates to is that the element where our protocol directive is placed should also have either of these attributes formControlNameformControlngModelThis makes sure that the directive is not activated on non form elements and you won t get any unwanted errors Custom async validatorsThe process of creating async validators in angular is exactly the same except this time we are doing our validation in an async way by calling an API for example Here is the type of async validator function interface AsyncValidatorFn control AbstractControl Promise lt ValidationErrors null gt Observable lt ValidationErrors null gt The only thing that is different here is that the method now returns either an Observable or a Promise Let s create an async validator by modifying the above validator that we wrote Ideally we will be using async validation for meaningful validations like Check username availabilityWhether a user is blockedIf the user s phone number is part of a blocklist Let s create an async validator to check if a username is available We are gonna be creating things Username Service which makes the API call to see if the username is availableValidator Service which contains the validation logicValidator Directive for using template driven forms Username ServiceWe ll mock the logic for this Injectable providedIn root export class UsernameService constructor private http HttpClient isUsernameAvailable username string return this http get pipe map users any gt users map user gt user username toLowerCase map existingUsernames string gt existingUsernames includes username startWith true delay Async Validator ServiceThis is the main part of our validation process Injectable providedIn root export class UsernameValidatorService implements Validator constructor private usernameService UsernameService validatorFunction AsyncValidatorFn control gt control value this usernameService isUsernameAvailable control value pipe map isUsernameAvailable gt isUsernameAvailable null username Username not available of null validate control AbstractControl return this validatorFunction control Why did we create a separate validatorFunction Why can t the logic be placed inside the validate method itself This is done so that we can use the validatorFunction when we are using Reactive Forms export class AppComponent constructor private usernameValidator UsernameValidatorService username new FormControl asyncValidators this usernameValidator validatorFunction Now to use the validator with Template driven forms we need to create a Directive to bind the validator to the element Async Validator Directive Directive selector username ngModel providers provide NG ASYNC VALIDATORS useExisting UsernameValidatorService multi true export class UsernameValidatorDirective We provide NG ASYNC VALIDATORS instead of NG VALIDATORS in this case And since we already have the UsernameValidatorService which implements the Validator interface Note UsernameValidatorService is providedIn root which means the Injector has the service instance with it So we just say use that same instance of UsernameValidatorService by using the useExisitng property Angular takes care of subscriptions of these validators so we don t have to worry about cleaning the subscriptions later Code and DemoCode Note Open in a new window to see the demo properly Make sure to not just use the code as is For the scope of this post things are kept simple and straightforward Take some time to see if you can improve something in the code before you use it Connect with meTwitterGithubLinkedinCardify Dynamic SVG Images for Github ReadmesDo add your thoughts in the comments section Stay Safe ️ 2021-12-16 13:18:25
海外TECH DEV Community How Flutter 2.8 Enhance Mobile App Performance? https://dev.to/pankajdas0909/how-flutter-28-enhance-mobile-app-performance-575l How Flutter Enhance Mobile App Performance Google released Flutter with multiple improvements amp updates So lets have a look at how Flutter enhance mobile performance We will focus on the key factors which are improved in the latest release of Flutter How Flutter improves mobile performance Flutter includes the update of the Dart programming language The update was presented at the same time Also higher performance is an important factor in this update The Flutter team has announced that this update should also benefit existing mobile apps The update will reduce the startup time and lower the storage requirements Below we have explained the other features of this update in detail Low latency in app startupThe Flutter team has been working on various aspects to reduce the latency when starting apps This includes the interaction of the standard font manager with Dart VM s garbage collection GC There was always a bottleneck in the setup of Dart when setting the font manager Now developers can use Isolate so that both processes will run concurrently the next time In addition Flutter avoids unnecessary GC cycles in DartVM during the app launch sequence Let us understand this though the example In Android the framework will only notify DartVM before the first frame is rendered if a message about a memory bottleneck comes from TRIM LEVEL RUNNING CRITICAL or later Fast loading of Dart VM AOT code will isolates services This can be a problem for devices with low memory resources For Android Flutter allows you to load services on more need based way It is now available in a separate bundle Also very soon platform threads will no longer have to wait for the platform view to be created The purpose of all these measures is to reduce the boot time by half on weak Android hardware But you ll also get to see an improvement of on more powerful devices Concurrency Model with IsolateIn addition Dart has made a significant contribution by revising the concurrency model Dart is built on the separation of independent execution units This is to avoid common shared storage issues such as race conditions In the new version the darts team also introduced Isolate Groups In such group releases isolation includes various internal data structures of the current program It allows individual elements to be leaner This reduces the start time and reduces the memory requirements of individual execution units According to blog posts it s up to times higher in each case The Dart syntax also allows you to dismantle the constructor Previously developers could only use function pointers when working with Dart s core libraries For example when creating the Flutter UI there was no useful feature In the future constructor tearoffs will make it easier to create column widgets in particular as shown in the following TextWidgets example class FruitWidget extends StatelessWidget override Widget build BuildContext context return Column children Apple Orange map Text new toList Memory Flutter enthusiastically loads Dart VM s “Service Isolate and the AOT code is bundled with the app so Flutter developers targeting memory constrained devices struggle to create performance traces This was because Flutter was reading both things into memory simultaneously For Android version the Dart VM service isolation is split into separate bundles that can be loaded individually This saves upto MB of memory until service isolate is required Dart VM further reduced memory requirements by up to by notifying the operating system that the memory pages used by the AOT program are supported for files that probably do not need to be read again Therefore you can reuse and redirect pages that contain copies of file based data FirebaseAnother big part of the Flutter ecosystem is the FlutterFire It is used in two thirds of the Flutter app This version adds many new features that make it easier to build applications with Flutter and Firebase All FlutterFire plugins can be switched from beta to stable New support for DartPad for many Firebase services New libraries that will facilitate the creation of user interfaces for authentication and live Firestore queries Last but not least the new Firestore object document mapping for Flutter available in alpha Conclusion So in this article we discussed about how Flutter enhance mobile performance Flutter will keep getting new updates and improvements To know more you can read the official documentation of Flutter Also Do let us know your feedback comments for further improvements Flutter Agency is the leading Flutter app development company with a highly experienced team of Flutter developers You can hire Flutter developers on hourly basis or for fixed budget We promise to deliver the best application developed in Flutter which will excel in the market Also Flutter Agency is a portal full of excellent resources like Flutter Widget Guide Flutter Projects Code libs etc So contact us for your next project 2021-12-16 13:10:54
海外TECH DEV Community React - Introduction to react router v6 https://dev.to/josec/rect-introduction-to-react-router-v6-2560 React Introduction to react router v InstallationAfter creating our react app we have to install the react router v library to our project using npm npm install react router dom And import the BrowserRouter to our index js import React from react import ReactDOM from react dom import index css import App from App import BrowserRouter from react router dom ReactDOM render lt BrowserRouter gt lt App gt lt BrowserRouter gt document getElementById root Now our react application can now response to different urls Creating linksTo create links on react we could try sing the regular html links and that would lets us navigate to different urls defined in our application but if you try you will realize that each time you click on a link you are reloading the whole page and that s something we don t do on react as react works as single page application Instead we use Link from the react router dom package we installed earlier import Link from react router dom import App css const App gt return lt Link to hotels gt Hotels lt Link gt It s discrete but there s a link at the top left of our page but when clicking the page it doesn t get reloaded but it s not showing nothing new thou it changes the current url Defining routesOn my react example app I ve created pages Hotels list Form to add new hotels to the list So I need two routes One for each page follow me for more design tips To create a those new routes that matches I will make use of Routes and Route from the react router package import useState from react import Route Routes from react router import classes from app module css import Nav from components Nav import Form from pages Form import Hotels from pages Hotels const App gt const hotelsArray name Hotel Barcelona rooms rating name Hotel Paris rooms rating name Hotel Munich rooms rating const hotels setHotels useState hotelsArray const newHotelHandler hotel gt setHotels prevState gt prevState hotel return lt gt lt Nav gt lt div className classes container gt lt Routes gt lt Route path hotels element lt Hotels hotels hotels gt gt lt Routes gt lt Routes gt lt Route path new element lt Form onSubmit newHotelHandler gt gt lt Routes gt lt div gt lt gt export default App On the app I have the hardcoded list of initial hotels to set is as default state and the functions that adds new hotels and updates the state To navigate through the pages I ve created a new component called nav that contains all the Links import classes from Nav module css import Link from react router dom const Nav gt return lt div className classes nav gt lt div className classes nav container gt lt Link style textDecoration none color white to hotels gt Hotels lt Link gt lt Link style textDecoration none color white to new gt Add new lt Link gt lt div gt lt div gt export default Nav This way now I have a set of urls to navigate on my hotels app Params on urlNow I have a list of nice hotels and a form to add new ones but what if I want to check one hotel details To do that It would be nice to have a parameterized url where to pass the hotel id so my react app can retrieve the hotel details To do it we have to define a new route in our app js I want that url to be hotels hotelID so my new route will be defined like this lt Routes gt lt Route path hotels hotelId element lt Details hotels hotels gt gt lt Routes gt And on a new page I will Read the hotel id from url Get the hotel details actually what I will do is get the hotel position on the hotels list Reading the hotel id from the urlTo do that we need to import the useParams hook from the react router dompackage and read the params import useParams from react router dom const Details gt const params useParams return lt h gt params hotelId lt h gt export default Details The params are the ones we ve defined in the route path Getting the hotel detailsimport classes from Details module css import Link useParams from react router dom const Details hotels gt const params useParams const hotel hotels params hotelId return lt div className classes container gt lt h gt Hotel hotel name lt h gt lt h gt Rooms hotel rooms lt h gt lt h gt Rating hotel rating lt h gt lt Link to hotels gt lt button className classes container save gt Hotels lt button gt lt Link gt lt div gt export default Details To access to this url I ve updated the hotels list component so each hotel now has a Link import Link from react router dom import classes from Hotels module css const Hotels hotels gt return lt div className classes container gt hotels map hotel key gt return lt Link to hotels key style textDecoration none color black gt lt div key key className classes element gt lt h gt hotel name lt h gt lt h gt Rooms hotel rooms lt h gt lt h gt Rating hotel rating lt h gt lt div gt lt Link gt lt div gt export default Hotels javascript Navigate programmaticallySometimes we may need to navigate our users programmatically If you try the form to add new hotels to the list you will realize that after creating a new hotel you have to manually navigate to the hotels list with the top nav It works but we can do it better At the Form js component we have to import the useNavigate hook from the react router dom package import useState from react import useNavigate from react router dom import classes from Form module css const Form onSubmit gt const navigate useNavigate const name setName useState const rooms setRooms useState const rating setRating useState const nameHandler event gt setName event target value const roomsHandler event gt setRooms event target value const ratingHandler event gt setRating event target value const onSubmitHandler gt onSubmit name name rooms rooms rating rating After saving the hotel redirect the user to the hotels list navigate hotels return lt div className classes container gt lt div className classes container field gt lt label gt Hotel Name lt label gt lt input onChange nameHandler type text gt lt div gt lt div className classes container field gt lt label gt Rooms lt label gt lt input onChange roomsHandler type number min max gt lt div gt lt div className classes container field gt lt label gt Rating lt label gt lt input onChange ratingHandler type number min max gt lt div gt lt button onClick onSubmitHandler className classes container save gt Save lt button gt lt div gt export default Form Nested routesOur hotels app now works better but theres another thing we could improve There s two routes where one is child of another hotels and hotels hotelId On this example they are just two routes but on larger apps this can be annoying so let s nested instead using relative paths import useState from react import Route Routes from react router import classes from app module css import Nav from components Nav import Details from pages Details import Form from pages Form import Hotels from pages Hotels const App gt const hotelsArray name Hotel Barcelona rooms rating name Hotel Paris rooms rating name Hotel Munich rooms rating const hotels setHotels useState hotelsArray const newHotelHandler hotel gt setHotels prevState gt prevState hotel return lt gt lt Nav gt lt div className classes container gt lt Routes gt lt Route path hotels gt lt Route path element lt Hotels hotels hotels gt gt lt Route path hotelId element lt Details hotels hotels gt gt lt Route gt lt Routes gt lt Routes gt lt Route path new element lt Form onSubmit newHotelHandler gt gt lt Routes gt lt div gt lt gt export default App Here s link to github where you can download the project and try it and there s a demo 2021-12-16 13:02:37
海外TECH DEV Community Build a p2p server and release your cryptocurrency https://dev.to/freakcdev297/build-a-p2p-server-and-release-your-cryptocurrency-2l0f Build a pp server and release your cryptocurrencyHi all in the previous article I have covered how to create a simple transaction system for our blockchain So today I will build the core component of our cryptocurrency the peer to peer pp server It s not only required for a blockchain to work but after building it we can really release our coins Yes we are at that stage already I have also created a tutorial on Youtube check it our for better understanding What is a pp server First we have to understand what is a peer to peer server In the last parts I have talked about it a few times but it s not really ideal yet so I will dig deeper about it in this article Before we get on to that we need to understand the client server model first In our life pretty much everything we use currently follows the client server model The network works by having a server and every machines will connect to that server You can send requests to the server and the server can send back responses Think of the system as a company and the boss is the server The boss is the one who makes decisions and controls every action of the application But in a distributed peer to peer model machines called nodes can send messages to each other without having any rd party system involved Think of it as a group of friends working together People can work independently and decisions will be made by the majority In a cryptocurrency s network people should be able to at least send transactions and suggest new blocks Without futher ado let s code What and how we are trying to achieveWe would need a server where nodes can connect with and send messages to each other in a peer to peer fashion After that we will add functionalities like broadcasting transactions suggesting new blocks send the chain and chain s information I will be using WebSocket a TCP based protocol please learn about it to have a better understanding with what I will be doing Also please read the comments in the code I use them to explain individual functionalities SetupI will use a light package called ws just to stay simple in this article Simply install it using npm npm install ws Basic concepts of ws Import the packageconst WS require ws Create a serverconst server new WS Server port SOME PORT Listens for connectionsserver on connection async socket req gt This event handler will be triggered every time somebody send us connections Get the socket from an addressconst socket new WS SOME ADDRESS Open a connectionsocket on open gt This event handler will be triggered when a connection is opened Close a connectionsocket on close gt This event handler will be triggered when the connection is closed Listens for messagessocket on message message gt message is message yes A basic serverCreate a new file call it anything you want Basically we will have the basic variables for PORT the list of peers we are connecting PEERS our address MY ADDRESS I use process env abcxyz so that you can configure the server easily through command line BTW I will import the required stuff tooconst crypto require crypto SHA message gt crypto createHash sha update message digest hex const Block Transaction JeChain require jechain const EC require elliptic ec ec new EC secpk const MINT PRIVATE ADDRESS aadaebacdeadbfdceeeede const MINT KEY PAIR ec keyFromPrivate MINT PRIVATE ADDRESS hex const MINT PUBLIC ADDRESS MINT KEY PAIR getPublic hex Your key pairconst privateKey process env PRIVATE KEY dcacaeeafedeccabed const keyPair ec keyFromPrivate privateKey hex const publicKey keyPair getPublic hex The real new codeconst WS require ws const PORT process env PORT const PEERS process env PEERS process env PEERS split const MY ADDRESS process env MY ADDRESS ws localhost const server new WS Server port PORT console log Listening on PORT PORT I will add this one line for error handling process on uncaughtException err gt console log err The MINTING address should never be changed and we are going to change the old genesis block too const initalCoinRelease new Transaction MINT PUBLIC ADDRESS afeceebfbfdcbcafbacdaaeacddbcdacffdefcfffddbbddccd We are releasing coins and send it to a guy with the address above which is basically just from this private key dcacaeeafedeccabedRemember to replace the old mint key pair with the new one too Now let s have a way to connect to other nodes as well as listen to other nodes connections To implement this system we need a function to connect and use server on connection for listening to connections The connect function should be able to connect to an address then send it our address then the connection handler of that address will connect to our address using the message given A message is a string in this case a JSON which have a form like this type data What we need in this case is type TYPE HANDSHAKE data Our address and our connected nodes address address x address y I will create a function to generate messages for convenience function produceMessage type data return type data Now let s implement the main system THE CONNECTION LISTENERserver on connection async socket req gt Listens for messages socket on message message gt Parse the message from a JSON into an object const message JSON parse message switch message type case TYPE HANDSHAKE const nodes message data nodes forEach node gt connect node We will need to handle more types of messages in the future so I have used a switch case THE CONNECT FUNCTIONasync function connect address Get the socket from address const socket new WS address Connect to the socket using the open event socket on open gt Send our address to the target socket send JSON stringify produceMessage TYPE HANDSHAKE MY ADDRESS To actually do stuff in the future we would want to store connected sockets and addresses into one array Also by doing this we can send other nodes the address of the node that has just been connected to us let opened connected I will use opened for holding both sockets and addresses connected is for addresses only async function connect address We will only connect to the node if we haven t and we should not be able to connect to ourself if connected find peerAddress gt peerAddress address amp amp address MY ADDRESS const socket new WS address socket on open gt I will use the spread operator to include our connected nodes addresses into the message s body and send it socket send JSON stringify produceMessage TYPE HANDSHAKE MY ADDRESS connected We should give other nodes this one s address and ask them to connect opened forEach node gt node socket send JSON stringify produceMessage TYPE HANDSHAKE address If opened already contained the address we will not push if opened find peer gt peer address address amp amp address MY ADDRESS opened push socket address If connected already contained the address we will not push if connected find peerAddress gt peerAddress address amp amp address MY ADDRESS connected push address Two upper if statements exist because of the problem of asynchronous codes Since they are running concurrently the first if statement can be passed easily so there will be duplications When they disconnect we must remove them from our connected list socket on close gt opened splice connected indexOf address connected splice connected indexOf address To connect to all prefixed peers you can add this line in PEERS forEach peer gt connect peer Integrate our blockchain into the server What do we need to do Alright now that we have our server running let s start diving into the real deal part of the article cryptocurrency To create a cryptocurrency we would need to be able to broadcast transactions suggest newly mined blocks New nodes should be able to ask other nodes for their chains too Adding necessary stuffBecause when we send messages we are effectively parsing objects to JSON meaning that the methods of an object in this case they are the transactions blocks blockchains will disappear We can solve this problem by making our methods static so we can re use them without having to touch the real objects themselves And in the previous article the validation methods of blocks and transactions are not really ideal so let s update them while we are turning everything static static hasValidTransactions block chain let gas reward block data forEach transaction gt if transaction from MINT PUBLIC ADDRESS gas transaction gas else reward transaction amount return reward gas chain reward amp amp block data every transaction gt Transaction isValid transaction chain amp amp block data filter transaction gt transaction from MINT PUBLIC ADDRESS length static isValid blockchain for let i i lt blockchain chain length i const currentBlock blockchain chain i const prevBlock blockchain chain i if currentBlock hash Block getHash currentBlock prevBlock hash currentBlock prevHash Block hasValidTransactions currentBlock blockchain return false return true static isValid tx chain return tx from amp amp tx to amp amp tx amount amp amp chain getBalance tx from gt tx amount tx gas tx from MINT PUBLIC ADDRESS amp amp ec keyFromPublic tx from hex verify SHA tx from tx to tx amount tx gas tx signature static getHash block return SHA block prevHash block timestamp JSON stringify block data block nonce Related methods constructor timestamp Date now toString data this timestamp timestamp this data data this prevHash this hash Block getHash this this nonce mine difficulty while this hash startsWith Array difficulty join this nonce this hash Block getHash this addBlock block block prevHash this getLastBlock hash block hash Block getHash block block mine this difficulty this chain push Object freeze block this difficulty Date now parseInt this getLastBlock timestamp lt this blockTime addTransaction transaction if Transaction isValid transaction this this transactions push transaction TransactionsFirst I will create a handy dandy sendMessage function to send messages to nodes easier function sendMessage message opened forEach node gt node socket send JSON stringify message Now let s handle the messages A message for broadcasting transactions will look like this type TYPE CREATE TRANSACTION data the transaction object goes here In our message handler we will create a new case which simply uses the handy dandy addTransactions method we have created in the last part switch message type case TYPE CREATE TRANSACTION const transaction message data JeChain addTransaction transaction break And you can send a transaction like this sendMessage produceMessage TYPE CREATE TRANSACTION someTransaction You must also add the transaction to your pool JeChain addTransaction someTransaction Mining and sending new blocksNow let s handle the new block s suggestion messages This is by far the hardest most bulky part to implement so let s get going shall we The message will look like this type TYPE REPLACE CHAIN data new block new difficulty How would we handle this message The simplest thing we would do first is to check if the block is valid or not then we will add it to the chain and update the difficulty The block is valid when It has valid transactions the transactions are in our transaction pool the transactions are valid according to our old methods It has a valid hash matches with the block s information also called block header It has a valid difficulty it can t be greater or less than difficulty plus minus It has a valid timestamp must not be greater than the time they sent us and less than the previous block s timestamp This is not really a fulfill way to adjust difficulty but at least it shouldn t create too much damage switch message type case TYPE REPLACE CHAIN const newBlock newDiff message data We are checking if the transactions exist in the pool by removing elements from transactions of the block if they exist in the pool Then we simply use theirTx length to check if the all elements are removed meaning all transactions are in the pool const ourTx JeChain transactions map tx gt JSON stringify tx const theirTx newBlock data filter tx gt tx from MINT PUBLIC ADDRESS map tx gt JSON stringify tx const n theirTx length if newBlock prevHash JeChain getLastBlock prevHash for let i i lt n i const index ourTx indexOf theirTx if index break ourTx splice index theirTx splice if theirTx length amp amp SHA JeChain getLastBlock hash newBlock timestamp JSON stringify newBlock data newBlock nonce newBlock hash amp amp newBlock hash startsWith Array JeChain difficulty join amp amp Block hasValidTransactions newBlock JeChain amp amp parseInt newBlock timestamp gt parseInt JeChain getLastBlock timestamp JeChain getLastBlock timestamp amp amp parseInt newBlock timestamp lt Date now amp amp JeChain getLastBlock hash newBlock prevHash amp amp newDiff JeChain difficulty newDiff JeChain difficulty JeChain chain push newBlock JeChain difficulty newDiff JeChain transactions ourTx map tx gt JSON parse tx break But turns out there s one really dangerous problem If one miner mines a block he wouldn t really know if his block came first or the other one sent to him came first Yes this does happen due to many impacts one of them is internet problem Imagine if someone mined a block before you and he had sent the block to other nodes already but due to some internet problem you can manage to finish mining the block after the message is received so the block sent will be invalid but it s in fact valid and you will be left behind There are many approaches to this but I have coined out a really simple system which leverages the use of majority s support We can affectively implement this functionality using a boolean variable called checking and setTimeout Basically the idea is that if the block s prevHash is equal to the latest block s prevHash then it s probably a block that needs checking for replacement We will set checking to true to indicates that we are checking then we will request other nodes for their latest block We will wait for a period of time which I have set to s using setTimeout then we will set checking to false cancelling the process and the block that appeared the most is likely the block we need I will also implement a system to skip on all similar blocks after we have had the correct answer let check let checked let checking false if newBlock prevHash JeChain getLastBlock prevHash If this case was found once simply just dismiss it else if checked includes JSON stringify newBlock prevHash JeChain chain JeChain chain length timestamp checked push JSON stringify JeChain getLastBlock prevHash JeChain chain JeChain chain length timestamp const position JeChain chain length checking true sendMessage produceMessage TYPE REQUEST CHECK MY ADDRESS setTimeout gt checking false let mostAppeared check check forEach group gt if check filter group gt group group length gt check filter group gt group mostAppeared length mostAppeared group const group JSON parse mostAppeared JeChain chain position group JeChain transactions group JeChain difficulty group check splice check length Note that the upper code is more of a proof of concept we often would like to check if the block is valid or not just to be safer There are faster cleaner more secure ways than this but this should do our job Let s create a way to handle TYPE REQUEST CHECK We will send back TYPE SEND CHECK so let s make one for that as well The message will look like this type TYPE REQUEST CHECK data address to send back type TYPE SEND CHECK data block transaction pool difficulty The handler case TYPE REQUEST CHECK Find the address and send back necessary data opened filter node gt node address message data socket send JSON stringify produceMessage TYPE SEND CHECK JSON stringify JeChain getLastBlock JeChain transactions JeChain difficulty break case TYPE SEND CHECK Only push to check if checking is enabled if checking check push message data break So the handler is finally done You can mine blocks like this if JeChain transactions length Note that technically you can choose your own transactions to mine but I would like to mine all transactions at once JeChain mineTransactions publicKey sendMessage produceMessage TYPE REPLACE CHAIN JeChain getLastBlock JeChain difficulty Sending chainsFor new nodes that have just joined the network there are ways to get the latest chain You can either get a chain from a trust worthy source or you can ask for the chain in the network Note that the size of a message is limited so we won t be able to send the whole chain we will send its blocks and information one by one We can implement the second solution like this let tempChain new Blockchain case TYPE SEND CHAIN const block finished message data if finished tempChain chain push block else if Blockchain isValid tempChain JeChain chain tempChain chain tempChain new Blockchain break case TYPE REQUEST CHAIN const socket opened filter node gt node address message data socket We will send the blocks continously for let i i lt JeChain chain length i socket send JSON stringify produceMessage TYPE SEND CHAIN block JeChain chain i finished i JeChain chain length break case TYPE REQUEST INFO opened filter node gt node address message data socket send TYPE SEND INFO JeChain difficulty JeChain transactions break case TYPE SEND INFO JeChain difficulty JeChain transactions message data break Note that you can send request chain to a trust worthy node or base on the majority Testing in localhostTo test I will start new consoles with different PORT MY ADDRESS and PRIVATE KEY For the first one I will set our peers to be empty and the key to be what the initial coin release points to For the other one I will set the peer list to be the first node to test if our handshake functionality work Then I m going to create a transaction in the first node and mine in the second node After seconds we will print out the opened array and the chain First node setTimeout gt const transaction new Transaction publicKey ecaecbdcdaefededdeedbbcdfffdbedfcaecfacbbcbbbaeacacdef transaction sign keyPair sendMessage produceMessage TYPE CREATE TRANSACTION transaction JeChain addTransaction transaction setTimeout gt console log opened console log JeChain Second node setTimeout gt if JeChain transactions length JeChain mineTransactions publicKey sendMessage produceMessage TYPE REPLACE CHAIN JeChain getLastBlock JeChain difficulty setTimeout gt console log opened console log JeChain It should look like this Nodes have connected to each others the block is mined the chain is synced Releasing our coin testing publicly Simply host a node publicly by using port forwarding also for each router you would have a different way to do port forwarding just simply look up online to see what suits your model using your PC or a VPS hosting service I have tested with my friend here My node which is the first node His node which is the second node We have did some port forwarding and we connected to each others public IP address Note that this network is not meant to be production ready but this network should be fine for now Source codeThe full source code used in this article can be found in this Github repo ShoutoutsI want to give appreciation to my friend Apple who have contributed to the code used in the article and Trey a really cool guy who enlightens me in constructing the network Check out Apple s Github account Check out Trey s website ContactsMy Twitter My Github My Youtube channel I have also created a tutorial on Youtube check it our for better understanding 2021-12-16 13:01:50
海外TECH Engadget The Mac Mini M1 with 16GB of RAM is $100 off right now https://www.engadget.com/apple-mac-mini-m1-with-16gb-of-ram-is-100-off-right-now-135015213.html?src=rss The Mac Mini M with GB of RAM is off right nowWhile the Mac Mini M on sale at Amazon continues to come in and out of stock you can grab a version of the desktop with extra RAM for less at Adorama The online retailer has the Mac Mini M with GB of RAM and GB of storage for or off its normal price That s double the RAM in the base model and a configuration that s not as readily available at third party retailers Buy Mac Mini M GB RAM at Adorama You can still get the desktop with GB of storage for at Amazon if you prefer to bulk up on storage But extra RAM can be quite useful as it ll help make multitasking smoother Base on our experience testing out other M machines like the MacBook Air the Mac Mini M should already feel speedy and smooth thanks to the performance gains brought by Apple s updated chipset It has an eight core CPU and an eight core GPU plus a Neural Engine for handling machine leaning tasks Adding extra RAM into the mix will only improve the experience especially when doing things like video editing running dozens of browser tabs and more The latest Mac Mini is all about the performance enhancements which is to say that it doesn t look all that different from previous models It s designed to be compact so it should fit in even the most cramped work from home spaces and it has a number of ports including two USB A ports two Thunderbolt ports an HDMI port an Ethernet port and a headphone jack It s a good option for those who don t have a lot of space but want to invest in an upgraded all purpose machine for their home Follow EngadgetDeals on Twitter for the latest tech deals and buying advice 2021-12-16 13:50:15
海外TECH Engadget Apple's newest AirPods fall back to an all-time low of $140 https://www.engadget.com/apple-third-gen-airpods-fall-back-all-time-low-130225195.html?src=rss Apple x s newest AirPods fall back to an all time low of You now have another chance to grab Apple s third gen AirPods for on Amazon if you missed the sale last week That s the lowest price we ve seen for the wireless earbuds which originally retailed for and which Apple has been selling for over the past few days While the model is currently in stock make sure to check your estimated delivery dates before you decide to buy it as a Christmas gift because it may arrive after the holidays even if you purchase it right now Buy New Apple AirPods rd Generation at Amazon If you don t mind the possibility that your order might arrive after the holidays and have been looking to buy a pair of AirPods in the first place the third gen model is a great buy While it still doesn t come with the Pro s silicone buds it represents a complete redesign for the product line In our review where we gave it a score of we found it more comfortable than its predecessors due to its new quot contoured design quot It s shorter than previous models and can direct sounds better into your ear leading to massive improvements to its audio quality nbsp Apple also paired a custom driver with a high dynamic range amplifier to produce quot rich consistent bass quot and quot crisp clean quot sounds that improve audio quality even further making it more immersive than before And thanks to the H chip the third gen AirPods feature Adaptive EQ spatial audio one touch fast pairing and always on Siri Finally we praised the model for its battery life The earbuds themselves can last for six hours and the case can extend your listening time for up to hours total nbsp Follow EngadgetDeals on Twitter for the latest tech deals and buying advice All products recommended by Engadget are selected by our editorial team independent of our parent company Some of our stories include affiliate links If you buy something through one of these links we may earn an affiliate commission 2021-12-16 13:02:25
ニュース BBC News - Home Bank of England raises interest rates to 0.25% https://www.bbc.co.uk/news/business-59682521?at_medium=RSS&at_campaign=KARANGA omicron 2021-12-16 13:43:14
ニュース BBC News - Home Queen cancels pre-Christmas family lunch as Omicron surges https://www.bbc.co.uk/news/uk-59683343?at_medium=RSS&at_campaign=KARANGA christmas 2021-12-16 13:23:12
ニュース BBC News - Home We're not locking the country down, says Boris Johnson amid rising Covid cases https://www.bbc.co.uk/news/uk-politics-59686090?at_medium=RSS&at_campaign=KARANGA covid 2021-12-16 13:37:16
ニュース BBC News - Home Boris and Carrie Johnson announce name of new daughter https://www.bbc.co.uk/news/uk-politics-59686354?at_medium=RSS&at_campaign=KARANGA charlotte 2021-12-16 13:45:39
ニュース BBC News - Home Covid: France to drastically restrict travel from UK https://www.bbc.co.uk/news/world-europe-59679861?at_medium=RSS&at_campaign=KARANGA omicron 2021-12-16 13:51:35
ニュース BBC News - Home Omicron: Schools prepared if Covid forces online move next term https://www.bbc.co.uk/news/education-59673271?at_medium=RSS&at_campaign=KARANGA christmas 2021-12-16 13:25:30
ニュース BBC News - Home Star Hobson murder: Brockhill and Smith to have sentences reviewed https://www.bbc.co.uk/news/uk-england-leeds-59683996?at_medium=RSS&at_campaign=KARANGA mother 2021-12-16 13:24:42
ニュース BBC News - Home Strictly finalists: 'We all represent something' https://www.bbc.co.uk/news/newsbeat-59675877?at_medium=RSS&at_campaign=KARANGA feeling 2021-12-16 13:11:40
ニュース BBC News - Home Leicester v Tottenham postponed because of coronavirus cases https://www.bbc.co.uk/sport/football/59683741?at_medium=RSS&at_campaign=KARANGA covid 2021-12-16 13:45:23
LifeHuck ライフハッカー[日本版] ビル・ゲイツの成功を支えてきた、シンプルな2つの「夜の習慣」 https://www.lifehacker.jp/2021/12/247860biil-gates-evening-routines.html 解消 2021-12-16 22:05:00
北海道 北海道新聞 道産米「生産の目安」は46万3千トン 過去最大12%の大幅減 https://www.hokkaido-np.co.jp/article/623995/ 北海道中央 2021-12-16 22:06:00
北海道 北海道新聞 風力発電計画撤回を要請 日本野鳥の会など3団体 厚真、苫小牧 https://www.hokkaido-np.co.jp/article/623994/ 大阪ガス 2021-12-16 22:03:00
仮想通貨 BITPRESS(ビットプレス) [日経] SBIが暗号資産ファンド、国内初の個人向け https://bitpress.jp/count2/3_9_12954 個人向け 2021-12-16 22:59:47
仮想通貨 BITPRESS(ビットプレス) メルカリ、パ・リーグ6球団およびパシフィックリーグマーケティングと共同でNFT事業に参入 https://bitpress.jp/count2/3_79_12953 球団 2021-12-16 22:50:26
仮想通貨 BITPRESS(ビットプレス) LINE、グローバルNFTエコシステム拡大のため「LINE NEXT」を設立 https://bitpress.jp/count2/3_79_12952 拡大 2021-12-16 22:48:30
仮想通貨 BITPRESS(ビットプレス) bitFlyer、12/16付でWEBサイトを刷新しブランドロゴもブラッシュアップ https://bitpress.jp/count2/3_11_12951 bitflyer 2021-12-16 22:24:20

コメント

このブログの人気の投稿

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

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

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)