IT |
ITmedia 総合記事一覧 |
[ITmedia News] アドビ、PhotoshopとIllustrator教材を無償配布 角川ドワンゴ学園と共同開発 |
https://www.itmedia.co.jp/news/articles/2202/21/news176.html
|
illustrator |
2022-02-21 20:30:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia Mobile] KDDIが「5G SA」商用化、AbemaTVの中継で活用 個人向けは22年夏以降 |
https://www.itmedia.co.jp/mobile/articles/2202/21/news177.html
|
abematv |
2022-02-21 20:25:00 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
JupyerのnotebookをnbconvertでPDFに変換する |
https://qiita.com/Q-Lazy/items/8539f9c4ff77d3036b8f
|
PDFに変換するためには、MinicondaとTeXliveのランタイムがPATHに追加されていなければなりません。 |
2022-02-21 20:57:15 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
LSTMで東京都のコロナ感染者数を予測する |
https://qiita.com/hidenaka824/items/24871f2cb9ceb45c0a76
|
今回やってみて、意外と感染者数だけで予測がある程度できるものなのだなと思った。 |
2022-02-21 20:45:34 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
【AtCoder解説】PythonでABC240のA,B,C,D,E問題を制する! |
https://qiita.com/u2dayo/items/c0e0fa0c1a6dbf901dc6
|
コードNintinputAlistmapintinputsplitprintlensetAC問題『JumpingTakahashi』問題ページCJumpingTakahashi灰コーダー正解率茶コーダー正解率緑コーダー正解率入力Nジャンプの回数X目的の座標Xleaibii回目のジャンプでは、aiかbi正の方向に移動する考察動的計画法DPで解きます。 |
2022-02-21 20:37:43 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
ゼロから始めるPython開発環境構築 |
https://qiita.com/kotattsu3/items/30af03266a61ece4740e
|
概要この記事では「昨日新しいPC買って何も触ってない」という前提からPythonのインストールvenvによる仮想環境の構築VSCodeのインストール環境構築Blackの導入という流れで書いていきます。 |
2022-02-21 20:22:43 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
Node.js Expressの例を通じて、WebアプリにおけるCookieについて理解する |
https://qiita.com/yuta-katayama-23/items/068900da9271c4d1be1c
|
今回は、そんなCookieが何をしてくれているものなのかについて理解しつつ、実際にNodejsのExpressでCookieの実装をやってみたいと思う。 |
2022-02-21 20:40:57 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
【受験記録】AWS Solutions Architect - Professional (SAP-C01) |
https://qiita.com/kei1-dev/items/0d1a432718d677270977
|
Google翻訳はうまく当たるのですが、クイズモードがなく、全てを解き切らないといけないので、時間がしっかり確保できる時に使用していました。 |
2022-02-21 20:23:00 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
EC2インスタンスのメタデータをPowerShellで一括出力してみる |
https://qiita.com/SAITO_Keita/items/bbfae778f9d075d01da5
|
exsamplelatestmetadatainstanceidでインスタンスIDlatestmetadatainstancetypeでインスタンスタイプが参照できる。 |
2022-02-21 20:16:46 |
技術ブログ |
Developers.IO |
AWS Tools for PowerShellのリリースサイクルがより高速になりました |
https://dev.classmethod.jp/articles/release-cycle-of-aws-tools-for-powershell-is-more-faster/
|
supportinawsisareality |
2022-02-21 11:24:15 |
海外TECH |
MakeUseOf |
What Is Adobe Portfolio and Why Should Every Artist Use It? |
https://www.makeuseof.com/what-is-adobe-portfolio/
|
effort |
2022-02-21 11:30:13 |
海外TECH |
MakeUseOf |
Is Shein Legit and Safe to Shop At? |
https://www.makeuseof.com/is-shein-safe/
|
trustworthy |
2022-02-21 11:30:13 |
海外TECH |
DEV Community |
Animate a frame by using a transition between main image colors |
https://dev.to/bornfightcompany/animate-a-frame-by-using-a-transition-between-main-image-colors-1p2j
|
Animate a frame by using a transition between main image colorsA disclaimer right away this is not really about animating image frames it s just animating the background behind the image and adding some padding I wanted to draw more attention to some images in a grid of uploaded images in one of my projects Instead of having a plain card design or having to tweak borders and shadows around those images I came up with this technique The idea is to extract the main image colors and compose a gradient with transitions between them This gradient will circle around the image making it look more lively and vibrant At the same time each image will have its own unique animated gradient which in my opinion will make the transition between the image image frame and container background color more seamless To achieve that main image colors are extracted for each image This palette of colors is used in composing the aforementioned gradient A couple of examples The code was mainly influenced by this script by Kepler Gelotte Image Color ExtractInput parameters are path to the image number of colors to extract and delta the amount of gap when quantizing color values The smaller the delta the more accurate the color but also number of similar colors increases lt phpdeclare strict types namespace App Service class ColorPaletteExtractor private const PREVIEW WIDTH private const PREVIEW HEIGHT public function extractMainImgColors string imagePath int colorsCount int delta array halfDelta if delta gt halfDelta delta size getimagesize imagePath scale if size gt scale min self PREVIEW WIDTH size self PREVIEW HEIGHT size width int size height int size if scale lt width int floor scale size height int floor scale size imageResized imagecreatetruecolor width height imageType size imageOriginal null if IMG JPEG imageType imageOriginal imagecreatefromjpeg imagePath if IMG GIF imageType imageOriginal imagecreatefromgif imagePath if IMG PNG imageType imageOriginal imagecreatefrompng imagePath imagecopyresampled imageResized imageOriginal width height size size img imageResized imgWidth imagesx img imgHeight imagesy img totalPixelCount hexArray for y y lt imgHeight y for x x lt imgWidth x totalPixelCount index imagecolorat img x y colors imagecolorsforindex img index if delta gt colors red intval colors red halfDelta delta delta colors green intval colors green halfDelta delta delta colors blue intval colors blue halfDelta delta delta if colors red gt colors red if colors green gt colors green if colors blue gt colors blue hex substr dechex colors red substr dechex colors green substr dechex colors blue if isset hexArray hex hexArray hex hexArray hex Reduce gradient colors arsort hexArray SORT NUMERIC gradients foreach hexArray as hex gt num if isset gradients hex newHexValue this gt findAdjacent string hex gradients delta gradients hex newHexValue else newHexValue gradients hex if hex newHexValue hexArray hex hexArray newHexValue num Reduce brightness variations arsort hexArray SORT NUMERIC brightness foreach hexArray as hex gt num if isset brightness hex newHexValue this gt normalize string hex brightness delta brightness hex newHexValue else newHexValue brightness hex if hex newHexValue hexArray hex hexArray newHexValue num arsort hexArray SORT NUMERIC convert counts to percentages foreach hexArray as key gt value hexArray key float value totalPixelCount if colorsCount gt return array slice hexArray colorsCount true else return hexArray private function normalize string hex array hexArray int delta string lowest highest colors red hexdec substr hex colors green hexdec substr hex colors blue hexdec substr hex if colors red lt lowest lowest colors red if colors green lt lowest lowest colors green if colors blue lt lowest lowest colors blue if colors red gt highest highest colors red if colors green gt highest highest colors green if colors blue gt highest highest colors blue Do not normalize white black or shades of grey unless low delta if lowest highest if delta gt return hex if lowest highest gt delta return hex for highest lt lowest delta highest delta newHexValue substr dechex colors red lowest substr dechex colors green lowest substr dechex colors blue lowest if isset hexArray newHexValue same color different brightness use it instead return newHexValue return hex private function findAdjacent string hex array gradients int delta red hexdec substr hex green hexdec substr hex blue hexdec substr hex if red gt delta newHexValue substr dechex red delta substr dechex green substr dechex blue if isset gradients newHexValue return gradients newHexValue if green gt delta newHexValue substr dechex red substr dechex green delta substr dechex blue if isset gradients newHexValue return gradients newHexValue if blue gt delta newHexValue substr dechex red substr dechex green substr dechex blue delta if isset gradients newHexValue return gradients newHexValue if red lt delta newHexValue substr dechex red delta substr dechex green substr dechex blue if isset gradients newHexValue return gradients newHexValue if green lt delta newHexValue substr dechex red substr dechex green delta substr dechex blue if isset gradients newHexValue return gradients newHexValue if blue lt delta newHexValue substr dechex red substr dechex green substr dechex blue delta if isset gradients newHexValue return gradients newHexValue return hex I was getting the best results when working with colors and delta between and CSS is pretty simple gradient background animation background size important animation BackgroundGradient s ease infinite card picture container padding rem This value determines how big the frame will be card picture container img object fit contain max width keyframes BackgroundGradient background position background position background position You can adjust the layout and the rest of the styling per your liking HTML lt div class container gt lt div class card picture container gradient background animation style background image linear gradient deg a ac cae bbb eee ddf gt lt picture gt lt img src images source image jpeg alt gt lt picture gt lt div gt lt div gt As you can notice background is added as inline CSS Final result size decreased for preview purposes I ve created a Twig extension filter and included it in my Symfony project lt phpdeclare strict types namespace App Twig use App Service ColorPaletteExtractor use Twig Extension AbstractExtension use Twig TwigFilter class GradientExtractorExtension extends AbstractExtension public function construct private ColorPaletteExtractor gradientExtractor public function getFilters array return new TwigFilter get gradient this getGradient public function getGradient string imagePath int colorsCount int delta string colors this gt gradientExtractor gt extractMainImgColors imagePath colorsCount delta filteredColors array filter colors fn float percentage gt percentage gt return join array map fn string color gt color array keys filteredColors image grid html twig lt div class container gt for image in images lt div class card picture container gradient background animation style background image linear gradient deg asset image get gradient animation duration s gt lt picture gt lt img src asset image alt gt lt picture gt lt div gt endfor lt div gt Photos for testing purposes downloaded from |
2022-02-21 11:34:49 |
海外TECH |
DEV Community |
HP Latest Exam Questions PDF |
https://dev.to/jamesbarns/hp-latest-exam-questions-pdf-44o5
|
HP Latest Exam Questions PDFStructure of HPE Certification ProgramAs of now this vendor issues various designations based on a particular technology and so you can find validations in the category of Sales Technical including such paths as Networking Hybrid IT Servers Software and Storage and finally Workload Solutions Then each of these categories subcategories is further divided into several certifications on offer Note that Technical certificates can be accessed by all applicants who are interested in this field however the Sales qualifications were designed for those individuals who are employed by HPE or HPE Partners Now that you re aware of how HPE certificates are grouped let us know some peculiar details of some of them HPE Sales Certified Aruba Products and SolutionsThis certification validates the candidates solid understanding of the latest network industry trends and the strategy integrated in Aruba Edge Services Platform ESP Also it is suitable for those specialists who want to learn about Aruba consumption and financial flexibility as well as those who want to become experts at managing Aruba AIOps Zero Trust Security or Cloud solutions Another topic included in the certification process is describing and installing Aruba SMB solutions and the Unified Infrastructure in the branch data center and campus The HPE Sales Certified Aruba Products and Solutions designation is achievable by those professionals who can get the passing score in the HPE W exam |
2022-02-21 11:26:16 |
海外TECH |
DEV Community |
AWS open source news and updates, #101 |
https://dev.to/aws/aws-open-source-news-and-updates-101-4lhh
|
AWS open source news and updates Feb st Instalment Newsletter There is nothing basic and fundamental about edition of the AWS open source newsletter with another great round up of new open source projects including eks creation engine from the folks at Lightspin helping you all to stay safer with this handy tool you should check out idp scim sync to help users of AWS SSO who want to synchronise with their Google Workspace Directory typecart an analysis tool for proof evolution and many other great projects and sample code If reading is more your thing then catch up on the latest posts covering topics such as Apache LogJ Formik AWS CDK QUIC Apache Airflow AWS Amplify Syne Tune Apollo Server Amazon EKS PostgreSQL Apache Hudi Terraform CloudQuery RabbitMQ MariaDB and many more We have a nice video presented from the lovely folk at Weaveworks and of course the latest events and meet ups to attend Celebrating open source contributorsThe articles posted in this series are only possible thanks to contributors and project maintainers and so I would like to shout out and thank those folks who really do power open source and enable us all to build on top of what they have created So thank you to the following open source heroes Panos Kampanakis Tim Shear Matt Auerbach Danilo Poccia Olivier Cruchant David Salinas Andrew Guthrie Matthias Seeger Markus Ziller David Boldt Adam McQuistan Kevin Rivera Mark Carlson Shruti Arora Britney Tong Balaji Varadarajan Yevgeny Pats Jonathan Rau and Matt Badger Make sure you find and follow these builders and keep up to date with their open source projects and contributions Latest open source projects Communityidp scim syncidp scim sync this open source tool from SlashDevOps will help you keep your AWS Single Sign On SSO groups and users in sync with your Google Workspace directory eks creation engineeks creation engine The Amazon Elastic Kubernetes Service EKS Creation Engine ECE is a Python command line program created by the Lightspin Office of the CISO to facilitate the creation and enablement of secure EKS Clusters Jonathan Rau has put together this post Why Create an EKS Creation Tool that provides a great outline of not just the rational and motivation for putting this tool together but also provides some good examples of how to use the tool and shares what the future holds As Jonathan likes to say Stay Dangerous reading this post is your first step terraform aws ecr publicterraform aws ecr public this is a Terraform Module to manage Public Docker Container Registries on AWS ECR Toolstypecarttypecart typeCart is an analysis tool for proof evolution to facilitate proof maintenance for continuously integrated software typeCart is constructed in F and it reads two Dafny files into Dafny AST analyses the ASTs to identify syntactically equivalent types between them andgenerates mapping functions between equivalent types Dafny is a programming language with built in specification constructs and the Dafny static program verifier can be used to verify the functional correctness of programs If you are interested in reading more about formal reasoning and how it is used within AWS may I be bold enough to suggest this great paper from Byron Cook Formal reasoning about the security of Amazon Web Servicesaws cloudwatch monitoringaws cloudwatch monitoring this repository provides a time series monitoring and visualisation for PrivateLink connections using CloudWatch Contributor Insights automation The provided CloudFormation templates sets up custom Amazon CloudWatch dashboards Amazon CloudWatch metrics and Amazon CloudWatch alarms based on Contributor Insights rules These rules monitor several aspects of PrivateLink connections such as bytes transferred by source and destination IP address traffic by source address and action or top sources for rejected TCP connections You can modify the solution to add additional custom rules amazon chime sdk meetings load testamazon chime sdk meetings load test this open source project will be handy for customers using Amazon Chime This tool simulates real attendees by launching Amazon Chime SDK for Javascript Amazon Chime SDK for JS clients and enabling them to join meetings and control the features of the meeting The tool can be helpful if you wish to simulate attendees in a meeting and or test multiple scenarios to see how the app built on Amazon Chime SDK for JS behaves for larger loads green boostgreen boost Build Full Stack Serverless Web Apps on AWS quickly with this repo Green Boost is a framework for boosting development of greenfield web apps on AWS and you can view the detailed docs here Demos and Samplesreact formik on awsreact formik on aws Formik is a popular open source form library for React and React Native and this repo will show you how you can deploy this on AWS using AWS CDK To help you get going read the post Deploying Sample UI Forms using React Formik and AWS CDK from Kevin Rivera Mark Carlson Shruti Arora and Britney Tongaws legal entity extractionaws legal entity extraction this repository is used to demonstrate how users can use AWS Comprehend to automate processing of Insurance Claims Legal Letters scanned documents to speechscanned documents to speech This project provides an end to end solution that converts scanned documents images to speech and reads back to user AWS and Community blog postsCloudQueryCloudQuery is an open source project that enables you to extract transform and load your cloud assets into normalised PostgreSQL tables With this you can then assess audit and monitor the configurations of your cloud assets In his post Our Open Source Journey Building CloudQuery Yevgeny Pats shares why they started CloudQuery as an open source cloud asset inventory and then takes a look at some of their products and they technical decisions they made along the way QUICQUIC is an encrypted transport protocol designed for performance and is the foundation of HTTP In the postIntroducing sn quic a new open source QUIC protocol implementation in Rust Panos Kampanakis announces the availability of sn quic an open source Rust implementation of the QUIC protocol added to our set of AWS encryption open source libraries Make sure you check it out this weeks must read post Apache LogJIn his post New for Amazon CodeGuru Reviewer Detector Library and Security Detectors for Log Injection Flaws Danilo Poccia shares some nice new capabilities within Amazon CodeGuru that allows you to set up detectors that can help you detect if you re logging anything that is not sanitised and possibly executable These detectors work with Java and Python code and for Java are not limited to the Logj library Nice post and a must read this week Apache AirflowThis is a really nice post from Tim Shear that takes a look at how you can migrate from mainframe CA job schedules to Apache Airflow CA is a job scheduling and workflow automation solution that is popular in this space The post covers everything you need to think about if this is a use case that fits your situation Find out more by reading the full post Migrate from mainframe CA job schedules to Apache Airflow in AWSTerraformWe had another Apache Airflow related post this time from Matt Badger who shares how they use the Snowflake Terraform provider to automate the process of creating S bucket notifications and Snowflake stages pipes and tables for automatically loading data into Snowflake orchestrated via Apache Airflow Find out more by reading his post Terraforming SnowpipeApache HudiReally loved this post Fresher Data Lake on AWS S from Balaji Varadarajan over in the Robinhood engineering team In this post he shares their journey in building a Change Data Capture solution using various open source tools to reduce the data freshness latency for our core datasets from one day to under minutes Another must read post this week PostgreSQLAdam McQuistan explores some of the advantages you might see building observability into your AWS Aurora PostgreSQL environments in his post Aurora PostgreSQL Slow Query Logging and CloudWatch Alarms via AWS CDK Adam provides source code in his repo so you can follow along hands on Syne TuneSyne Tune is a parameter search and optimisation library that I shared news about this project a few weeks ago and we now have a nice blog post that dives deeper into how you can use this project in Learn Amazon Simple Storage Service transfer configuration with Syne Tune Olivier Cruchant David Salinas Andrew Guthrie and Matthias Seeger provide an example of how you can use this open source library to in this example search and learn a configuration for S Transfer that is optimised for a specific use case hands on Apollo ServerMarkus Ziller and David Boldt share how you can use Apollo Server on AWS Lambda in an event driven architecture in their blost post Using Apollo Server on AWS Lambda with Amazon EventBridge for real time event driven streaming hands on AWS AmplifyThe AWS Amplify have been focused on making it easier to contribute to their open source project Earlier this year theu launched the Amplify Contributor Bash an initiative to drive more awareness to Amplify s open source program Find out more by reading Matt Auerbach s post Amplify Bash Get Started Contributing to AWS Amplify Open SourceOther posts worth checking outNEW in AWS Amplify Flutter version provides a high level breakdown of the features we are announcing with Amplify Flutter version Introducing Amazon CloudWatch Container Insights for Amazon EKS Fargate using AWS Distro for OpenTelemetry looks at the design of components in an ADOT Collector pipeline that enables the collection of Container Insights metrics from EKS Fargate workloadsRunning WDL workflows at scale with Amazon Genomics CLI and MiniWDL announces the addition of miniWDL as a workflow engine in Amazon Genomics CLI an open source tool that makes it easier to run genomics workflows at scale by automating the deployment of workflow engines and compute clustersMigration options for MySQL to Amazon RDS for MySQL or Amazon Aurora MySQL helps you understand the different options to migrate data from a self managed MySQL database to AWS managed Amazon RDS for MySQL or Aurora MySQLHow To Expose Multiple Applications on Amazon EKS Using a Single Application Load Balancer shows the different ways to approach a microservices architecture within AWS demonstrating hands on how to implement using Amazon EKS with a single Application Load Balancer Quick updatesAWS SDKsThe default configuration in the AWS SDK for Java v just got smarter We are pleased to announce a new SDK feature ーsmart configuration defaults in the AWS SDK for Java v version or later which vends a set of predefined sensible default values tailored to common usage patterns With this new opt in feature you will get an optimized SDK client out of box with configuration already tuned to adhere to AWS SDK best practices This feature is also available in the AWS SDK for NET JavaScript v Ruby v Go v Python and PHP In this post we will explain the feature and show you how to leverage it in the AWS SDK for Java v Read more in the detailed post Introducing Smart Configuration Defaults in the AWS SDK for Java vMariaDBAmazon Relational Database Service Amazon RDS for MariaDB now supports delayed replication allowing you to set a configurable time period by which a read replica lags behind the source database In a standard MariaDB replication configuration there is minimal replication delay between the source and the replica With delayed replication you can introduce an intentional delay as a strategy for disaster recovery A delay can be helpful when you want to recover from a manual error For example if someone accidentally drops a table from your primary database you can stop the replication just before the point at which the table was dropped and promote the replica to become a standalone instance To assist with this process Amazon RDS for MariaDB now includes a stored procedure that will stop replication once a specified point in the binary log is reached RabbitMQAmazon MQ now provides support for RabbitMQ version This update to RabbitMQ contains several fixes and enhancements compared to the previously supported version RabbitMQ Videos of the weekGitOps with Amazon EKS Anywhere FluxAmazon EKS Anywhere is an open source tool which helps you create and manage Kubernetes clusters on premises EKS Anywhere allows you to manage your Kubernetes clusters in a scalable and declarative manner with the help of GitOps powered under the hood with CNCF Flux Introduced by Stacey Potter Community Manager at Weaveworks Dan Budris shares how EKS Anywhere integrates with Flux and uses GitOps workflows to manage the cluster lifecycle Events for your diaryIf you have an event you want me to publish here please contact me and I will include it in this listing AWS Databricks ML Dev Day Workshop February am am GMTIn this workshop you will get to learn about the current good practices for enterprises to use with powerful open source technologies to simplify and scale your data and ML efforts Covering Delta Lake Apache Spark TensorFlow XGBoost scikit learn and MLFlow a lot of stuff is going to be covered so read the full details and register at AWS Databricks ML Dev Day WorkshopOpenSearchEvery Tuesday pm GMTThis regular meet up is for anyone interested in OpenSearch amp Open Distro All skill levels are welcome and they cover and welcome talks on topics including search logging log analytics and data visualisation Sign up to the next session OpenSearch Community Meeting FebGitOpsCon EuropeMay th Valencia SpainGitOpsCon Europe is designed to foster collaboration discussion and knowledge sharing on GitOps This event is aimed at audiences that are new to GitOps as well as those currently using GitOps within their organisation Get connected with others that are passionate about GitOps Learn from practitioners about pitfalls to avoid hurdles to jump and how to adopt GitOps in your cloud native environment The event is vendor neutral and is being organised by the CNCF GitOps Working Group Topics include getting started with GitOps scaling and managing GitOps lessons learned from production deployments technical sessions and thought leadership Read more about this from the official page here CFPApache AirflowCFP closes March thA heads up to folks who are interested in all things Apache Airflow Apache Airflow Summit has been announced and the call for papers cfp is now open The bar for sessions is always very high so looking forward to this event already If you have an idea for a talk why not submit one via the cfp process Check out the event Apache Airflow Summit If you maybe have wanted to do a session then I am very happy to help with feedback or coaching to help you feel more comfortable in creating and or delivering your session If this something that has been on your mind but you just needed a little support PLEASE get in touch Stay in touch with open source at AWSI hope this summary has been useful Remember to check out the Open Source homepage to keep up to date with all our activity in open source by following us on AWSOpen |
2022-02-21 11:07:20 |
海外TECH |
DEV Community |
Mock Service Worker adopts a brand-new request interception algorithm for Node.js. |
https://dev.to/kettanaito/mock-service-worker-adopts-a-brand-new-request-interception-algorithm-for-nodejs-3hj9
|
Mock Service Worker adopts a brand new request interception algorithm for Node js PrefaceOne of the most prominent features of Mock Service Worker has always been the way it establishes the boundaries between what is mocked and what is not Conventional API mocking solutions turn any fetch or axios call into a black hole through the substitution of the entire client with a mocked re implementation In contrast MSW brings Service Workers to the table which allows request clients to execute in their entirety bringing more confidence to your tests and prototypes The reason why it increases confidence is simpleーyour system underneath your test resembles your actual production system Allow me to elaborate with a quick example Imagine you are writing an abstract test for a bank branchーone with a physical location where people come to open accounts withdraw funds and deposit their earnings and investments Let s say you want to test that your bank can handle deposits You model a situation where a customer walks in goes to the cash stand and hands their money to the teller The teller then puts the deposit into the bank system which updates the customer s account balance Since this is a test of an interaction spending actual money to put into accounts isn t the best idea what an expensive test that would be Instead you decide to mock certain parts of your bank during the test so they don t actually happen You do remember however that the point of any test is still to test a system of its subpart so you ought to introduce mocking carefully understanding which parts of the customer →bank interactions can be replaced without sacrificing the actual functionality you wish to testーthat your bank can handle deposits Ideally it s only that last cashierーbank system procedure you should mock The cashier would receive fake money mocked and interact with the bank systems that are already pre configured mocked to respond with a Okay we ve got the funds state Walking into the bank finding the cash stand and speaking to a cashier are all crucial aspects for our customer which should remain authentic and real At this point it should be clear I m hinting at the HTTP communication with this story where the customer is a request and the bank is your request client that processes it The final partーthe cashier →bank system ーis where you should employ API mocking So let s see what happens when you bring a common API mocking library to do the job Due to the implementation details of such libraries what happens is that you end up with your entire bank being replaced Yes not just the cashier or a cash stand the entire bank Because a conventional interception of request can be roughly represented as follows node modules api mocking library index jsconst mockRequestClient global requestClient mockRequestClientFor many tools the lowest level of operation becomes the request client In other words they replace window fetch axios react query and other clients during your tests so your code no longer executes them Basically your customer no longer walks into your actual bank Instead they walk into a fake building constructed to look and resemble the bank Since the scope of the mock has grown from a single interaction to the entire building the surface area where potential issues can happen increases drastically This is precisely where Mock Service Worker introduces interception of requests via the Service Worker API This allows you to keep the bank the cash stand and the cashier as real as they are in production Oh but there s more Even the cashier →bank system communication becomes real because the worker would intercept the deposit request after it s left the bank This keeps the mocked surface to a ridiculous minimum This has been our algorithm to intercept requests that occur in a browser for years now Unfortunately this hasn t been the case for Node js Request interception in Node jsNode js is an entirely different environment and as one would expect it has its own rules and limitations It s like an alternative universe where you can still have your bank but all its doors are now made of blue wood and all the communication is conducted via woolen envelopes that s just how banks work in this world There s simply no intermediate network layer like Service Workers in Node js Once requests happen they happen and nothing can intercept them past that point This design choice is why request clients become the lowest point of interception available in a Node js environment Due to this limitation request interception in Node js is implemented by stubbing request modules node modules api mocking library index jsconst https require https My custom function replaces the bank the https module and becomes responsible for handling any issued requests https function args Modules in Node js share the same scope so modifying a standard API like https in one module will affect its references in all other modules Module stubbing is a reasonable strategy within the circumstances and that is also how MSW intercepts requests in Node js Or rather how it used to until we tried something unusual Brand new interception algorithmStarting from the latest version of Mock Service Worker the library will employ a request interception algorithm that has been rewritten from the ground up There s no more module stubbing no more replacing the entire bank Instead we are introducing a way to extend the request modules allowing them to execute in their entirety and intercept the outgoing requests at the last possible moment wait we ve heard this somewhere haven t we We achieve this through module extension Technically both http and https modules are just wrappers around the ClientRequest class That is actually the request that is being constructed and sent to a server That is also a lower surface where we could move our logic in order to be even closer to the constructed requests Still we do not wish to tread same water by hijacking the ClientRequest class and forcing it to do our bidding Both http and https use the same http ClientRequest configured accordingly for HTTP and HTTPS connections const ClientRequest require http That is NOT what we want ClientRequest class MyClientRequest end data Now suddenly resolve with a mocked response Unfortunately this is no different than stubbing http https modules directly What we ve decided to do is to extend the ClientRequest class effectively creating a child class that is much like its parent albeit with a few deviations class NodeClientRequest extends ClientRequest end data Respond with a mocked response This may look similar at first but there is a fundamental difference between the choice of replacing or extending the ClientRequest class When you replace that class you re removing it from existence swapping it with a seemingly compatible class that you ve written by yourself This means you the API mocking library in this context become responsible for respecting and handling all the internals of that class And those are many establishing the socket connection writing request response body handling headers etc In our previous implementation that s exactly what we were doing handling all those moving parts by ourselves But what happens when you extend the class is an entirely different story Class extension preserves the behavior of the parent class producing a child class that augments it So while we were previously forced to re implement the response handling logic just to be able to intercept an original response we can now hook into the ClientRequest prototype end method and simply use super whenever we need to bypass a request class NodeRequestClient extends ClientRequest end data if mockedResponse this respondWith mockedResponse return Calling super end will perform the intercepted request in the identical way it s perform without mocks return super end data The ability to execute the parent class logic through super is what allows us to keep the default behavior of request modules intact We just call out to it whenever it s needed It s been a rather challenging implementation as allowing ClientRequest to execute normally imposes a certain behavior difference when constructing requests Let s look at one of these challenges that we ve faced during this rewrite Handling refused connectionsExtending the ClientRequest class means that all requests begin to establish actual HTTP connection This quickly becomes problematic When you re prototyping against a non existing endpoint in Node js such connections would be refused In addition when you re testing the code that hits actual production servers connecting to those is not what you want your tests to do Presently we ve landed on the decision to always establish the connection no matter if the request is supposed to be mocked or not While this sounds unconventional the cost of establishing an actual socket connection is rather small Note that we are still preventing any data from being sent or received through that connection You can think of it as a HEAD request to your endpoint What about the scenarios when the connection fails What about requesting non existing endpoints It comes down to proper error handling in ClientRequest The connection itself happens right away while first constructing the request instance At that time it s impossible for the library to know if there s a request handler created to intercept this particular request However it s not too early to handle connection errors So what ends up happening is Request instance attempts to connect to the server This connection is either established the server exists or refused the server does not exist or couldn t otherwise establish the connection In either case no data is being transferred yet If the connection is refused MSW catches the respective error and silences it until it knows there are no matching request handlers Once this is known the library replays the errors propagating it to the process If the connection is established MSW prevents any data from being written or received until it s certain there are no matching request handlers We are convinced that keeping the connection logic is crucial to maintain the integrity of the ClientRequest instances This does not mean that you must request actual endpoints from now on or even that you must be connected to the internet while testing It only means that request instances execute more of its internal logic including the logic that s responsible for establishing the connection What should I expect as MSW user Expect to update msw in your projects npm install msw latest save dev oryarn add msw latest save devThe new algorithm is an internal change so there are no breaking changes to the public API or behaviors of MSW in Node js That being said this is quite a shift from our previous implementation so we expect issues to be reported occasionally We highly encourage you to do so whenever you encounter an unexpected behavior or a regression in your Node js tests Submit an issue here Our motivation behind this change is to reduce the mocked surface in Node js bringing you a similar level of confidence that you get when using MSW in a browser AfterwordI hope you re as excited about these changes as I am There s a long road for us ahead but it s a road we wish to spend on making your developer experience not just better but unmatched We ve got a history of using unconventional approaches to API mocking in the browser and we re thrilled to expand our vision to Node js Follow MSW on Twitter to stay updated on the awesome features we re working on Make sure to check out the mswjs interceptorsーthe low level interception library that powers Node js support in MSW mswjs interceptors Low level HTTP HTTPS XHR fetch request interception library mswjs interceptorsLow level HTTP HTTPS XHR fetch request interception library Intercepts any requests issued by http get http requesthttps get https requestXMLHttpRequestfetchAny third party libraries that use the modules above i e request node fetch supertest etc MotivationWhile there are a lot of network communication mocking libraries they tend to use request interception as an implementation detail giving you a high level API that includes request matching timeouts retries and so forth This library is a strip to bone implementation that provides as little abstraction as possible to execute arbitrary logic upon any request It s primarily designed as an underlying component for high level API mocking solutions such as Mock Service Worker How is this library different A traditional API mocking implementation in Node js looks roughly like this import http from http function applyMock Store the original request module const originalHttpRequest http request Rewrite the request module… View on GitHubThank you |
2022-02-21 11:02:06 |
Apple |
AppleInsider - Frontpage News |
Donald Trump's 'Truth Social' launches app on Apple's App Store |
https://appleinsider.com/articles/22/02/21/donald-trumps-truth-social-launches-app?utm_medium=rss
|
Donald Trump x s x Truth Social x launches app on Apple x s App StoreIntended to rival Twitter Donald Trump s Truth Social platform is now available in the App Store though users report errors and problems creating accounts Following Twitter Facebook and Instagram banning the former president from their platforms Trump is launching his own Despite Truth Social reportedly being delayed until March however the new service launched its app on the App Store on Sunday February According to CNET early users have complained about error messages while trying to create their accounts Forbes magazine says some users successfully created an account but were then told they are on a waitlist due to massive demand Read more |
2022-02-21 11:43:32 |
海外TECH |
Engadget |
Lenovo's new Smart Clock Essential with Alexa is 29 percent off at Amazon |
https://www.engadget.com/lenovos-new-smart-clock-is-29-percent-off-at-amazon-112316214.html?src=rss
|
Lenovo x s new Smart Clock Essential with Alexa is percent off at AmazonSmart clocks are ideal devices for the bedroom as they give key information like the time and temperature but often have no intrusive cameras If you re looking for a deal on a good one Lenovo s Smart Clock Essential with Alexa is on sale right now at Amazon for or percent off the regular price nbsp Buy Lenovo Smart Clock Essential with Alexa The Smart Clock Essential with Alexa came out early this year to replace the previous model with the main additions being a new pogo docking pin on the bottom and well support for Alexa instead of Google Assistant It features an attractive fabric covered design in colors quot Mistry Blue quot and quot Clay Red quot both of which are on sale On the top edge there are four buttons volume buttons a button for activating the assistant and another for setting an alarm There s also a USB port for charging It neither streams video nor has a camera though it of course has a mic and speakers so that you can listen to music podcasts or make voice calls The entire front face is a dedicated inch LED display displaying the time weather real time decibel levels and more in white text on a deep black background nbsp The docking accessories still aren t available but once they arrive you ll have two options One is a basic pad with room for both the clock and another wireless charging like a phone while the other is what Lenovo calls the Ambient Light Dock which doubles as a nightlight It ll be available for in two whimsical designs with either a sea lion and a squid along with eight different lighting modes and a rainbow of colors ーso it could work great in a kid s room nbsp |
2022-02-21 11:23:16 |
ニュース |
BBC News - Home |
Covid: Living with Covid plan will restore freedom, says Boris Johnson |
https://www.bbc.co.uk/news/uk-60455943?at_medium=RSS&at_campaign=KARANGA
|
commons |
2022-02-21 11:52:45 |
ニュース |
BBC News - Home |
Ukraine tensions: Biden agrees in principle to summit with Putin |
https://www.bbc.co.uk/news/world-europe-60454818?at_medium=RSS&at_campaign=KARANGA
|
ukraine |
2022-02-21 11:02:55 |
ニュース |
BBC News - Home |
Storm Franklin hits UK with flooding and high winds |
https://www.bbc.co.uk/news/uk-60452334?at_medium=RSS&at_campaign=KARANGA
|
warnings |
2022-02-21 11:39:48 |
ニュース |
BBC News - Home |
Solihull: Arthur Labinjo-Hughes report uncovers help delay |
https://www.bbc.co.uk/news/uk-england-birmingham-60462072?at_medium=RSS&at_campaign=KARANGA
|
delayvulnerable |
2022-02-21 11:41:46 |
ニュース |
BBC News - Home |
PFA says concussion protocols 'failing to prioritise player safety' after Koch injury |
https://www.bbc.co.uk/sport/football/60461233?at_medium=RSS&at_campaign=KARANGA
|
PFA says concussion protocols x failing to prioritise player safety x after Koch injuryThe Professional Footballers Association says concussion protocols are failing to prioritise player safety following the head injury sustained by Leeds United s Robin Koch |
2022-02-21 11:48:02 |
ニュース |
BBC News - Home |
Jimmy 'the Fist' First: Meet the oldest boxing prospect in Britain |
https://www.bbc.co.uk/sport/boxing/60115823?at_medium=RSS&at_campaign=KARANGA
|
Jimmy x the Fist x First Meet the oldest boxing prospect in BritainJimmy the Fist First calls himself the oldest prospect in British boxing as he prepares to challenge for his first title at the age of |
2022-02-21 11:22:42 |
ニュース |
BBC News - Home |
Ukraine: What is Nato and why doesn't Russia trust it? |
https://www.bbc.co.uk/news/world-europe-18023383?at_medium=RSS&at_campaign=KARANGA
|
invasion |
2022-02-21 11:38:05 |
北海道 |
北海道新聞 |
北ガス、初の賃貸マンションを公開 |
https://www.hokkaido-np.co.jp/article/648376/
|
札幌市中央区 |
2022-02-21 20:16:00 |
北海道 |
北海道新聞 |
予算案22日衆院通過 国民が異例の賛成 首相答弁を評価 |
https://www.hokkaido-np.co.jp/article/648372/
|
一般会計総額 |
2022-02-21 20:06:00 |
北海道 |
北海道新聞 |
宗谷管内4人感染 新型コロナ |
https://www.hokkaido-np.co.jp/article/648371/
|
宗谷管内 |
2022-02-21 20:04:00 |
IT |
週刊アスキー |
コーエーテクモゲームス初のオフィシャルショップ「KOEI TECMO SPOT」が渋谷パルコ6階でオープン決定! |
https://weekly.ascii.jp/elem/000/004/084/4084135/
|
koeitecmospot |
2022-02-21 20:20:00 |
IT |
週刊アスキー |
ゲーム内容をシンプルに紹介!『ELDEN RING(エルデンリング)』の最新トレーラーが公開 |
https://weekly.ascii.jp/elem/000/004/084/4084134/
|
eldenring |
2022-02-21 20:10:00 |
マーケティング |
AdverTimes |
日産、行動データ基に旅行先提案 ナビタイムと実証実験 |
https://www.advertimes.com/20220221/article377468/
|
実証実験 |
2022-02-21 11:42:42 |
マーケティング |
AdverTimes |
あえてラベル付きの天然水 アスクル、法人向けにPB発売 |
https://www.advertimes.com/20220221/article377461/
|
法人向け |
2022-02-21 11:15:00 |
コメント
コメントを投稿