IT |
ITmedia 総合記事一覧 |
[ITmedia Mobile] 銀行口座から電子マネーに直接チャージ ローソン銀行が「Suittoアプリ」の提供を開始 |
https://www.itmedia.co.jp/mobile/articles/2203/16/news169.html
|
itmediamobile |
2022-03-16 22:30:00 |
AWS |
AWS Compute Blog |
Implementing mutual TLS for Java-based AWS Lambda functions |
https://aws.amazon.com/blogs/compute/implementing-mutual-tls-for-java-based-aws-lambda-functions-2/
|
Implementing mutual TLS for Java based AWS Lambda functionsThis post is written by Dhiraj Mahapatro Senior Specialist SA Serverless and Christian Mueller Principal Solutions Architect Modern secure applications establish network connections to other services through HTTPS This ensures that the application connects to the right party and encrypts the data before sending it over the network You might not want unauthenticated users to … |
2022-03-16 13:57:07 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
きれいなPythonプログラミング(パイソニックなコードを書こう)を読んでみた |
https://qiita.com/inetcpl/items/af42b8221d9447637449
|
パイソニックでない例iffruitsbananaorfruitsappleorfruitsorangeltfruitsを複数記述する必要があり冗長そこで、以下のように比較対象の値をタプルにまとめ、そのタプル内に変数の値が存在するかどうかをin演算子でチェックするのがパイソニックです。 |
2022-03-16 22:43:40 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
【備忘録】Django Excelダウンロード |
https://qiita.com/hakomasu/items/dbda4da00165a429f8bc
|
【備忘録】DjangoExcelダウンロード経緯データアップロード処理記載後、txt形式は正常にダウンロードができたが、Excelのみダウンロード後、開いた際に「ExcelでファイルXXXxlsxを開くことができません。 |
2022-03-16 22:15:18 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
pd.SeriesでもGroupby集計はできる |
https://qiita.com/sayanotsu/items/1334a3b874ef117e223d
|
pdSeriesでもGroupby集計はできるTLDRグループ化用のリストgrouplistを用意する。 |
2022-03-16 22:09:17 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
【色変記事】AtCoder Beginner Contest 242で入緑しました。 |
https://qiita.com/meowmeowcats/items/8472bce149e792456208
|
ABCにてギリギリ入緑することができました所感まとめ文系出身者がなブログも多い中、理系で情報系出身なので、もともとのバックグラウンドからすると、入緑までに年以上かかるのは結構遅い方かと。 |
2022-03-16 22:08:37 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
【超基本】Dateオブジェクトについていろいろ確認してみた【JavaScript】 |
https://qiita.com/cokemaniaIIDX/items/48941f7695c8f1522e34
|
|
2022-03-16 22:53:41 |
Linux |
Ubuntuタグが付けられた新着投稿 - Qiita |
Ubuntu20.04に最新のNginxをインストール |
https://qiita.com/mocchimocchigogogo/items/2ad697a7db7cc5856046
|
Ubuntuに最新のNginxをインストールUbuntuにStable版の最新Nginxをインストールしたので備忘録です。 |
2022-03-16 22:18:21 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
AWSアカウント作成 |
https://qiita.com/mmaumtjgj/items/1db37045baa2059a7152
|
IAMユーザーIAMポリシーIAMロールIAMユーザーIAMユーザーとは人に与えられるIDのこと。 |
2022-03-16 22:25:31 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
そのsupervisord.serviceファイルちゃんと動きますか? |
https://qiita.com/wadakatu/items/cfd78a40027949545e3b
|
以下のような設定ファイルに変更したところエラーなく動きました。 |
2022-03-16 22:06:53 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
EC2からgithubにssh接続 |
https://qiita.com/youyonghua/items/5d7fb4c2a460eae4f2c0
|
公開鍵とプライベートキーを確認cdsshlsuthorizedkeysidrsaidrsapubidrsapubは公開鍵です。 |
2022-03-16 22:06:20 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
Portainerバージョンアップ手順 |
https://qiita.com/tojiko/items/f7d1470f2a96fe4c903f
|
Portainerバージョンアップ手順はじめにDockerデスクトップのダッシュボードのように、GUIでDocker環境管理を行うことができるPortainerのバージョンをアップデートしたかったのですが、意外と参考になる記事がQiitaになかったので、備忘録として残しておきます。 |
2022-03-16 22:08:49 |
技術ブログ |
Developers.IO |
[Swift] Delegate Protocol でメソッドを定義するときの書き方と考え方について |
https://dev.classmethod.jp/articles/delegate-protocol-writing-and-concepts/
|
delegate |
2022-03-16 13:37:07 |
海外TECH |
MakeUseOf |
10 Things To Do After You Have Installed Ubuntu 21.10 |
https://www.makeuseof.com/tag/5-things-right-installing-ubuntu/
|
ubuntu |
2022-03-16 13:45:13 |
海外TECH |
MakeUseOf |
6 Creative Ways to Use Emojis (and Reacjis) in Slack |
https://www.makeuseof.com/creative-ways-use-emojis-reacjis-slack/
|
creative |
2022-03-16 13:30:13 |
海外TECH |
MakeUseOf |
What Is A Decentralized App (DApp)? |
https://www.makeuseof.com/what-is-a-decentralized-app-dapp/
|
decentralized |
2022-03-16 13:15:13 |
海外TECH |
MakeUseOf |
How to Play Minecraft With Friends: 5 Different Ways |
https://www.makeuseof.com/how-to-play-minecraft-with-friends/
|
minecraft |
2022-03-16 13:15:14 |
海外TECH |
DEV Community |
Interview with Tom Granot - Developer Observability, KoolKits and Reliability |
https://dev.to/codenameone/interview-with-tom-granot-developer-observability-koolkits-and-reliability-nnj
|
Interview with Tom Granot Developer Observability KoolKits and ReliabilityIn preparation for the upcoming Developer Observability Masterclass we re hosting at Lightrun with Thoughtworks and RedMonk I sat down for a brief interview with Tom Granot the Director of Developer Relations at Lightrun Tom will MC the event as he did for the Developer Productivity Masterclass we ran back in December Shai Tell us a bit about yourself and your background Tom Before joining Lightrun I worked as an SRE at Actyx This drove home the importance of observability tools I got a sense of the potential problems and to some extent the blindness that developers face in production At Lightrun I run the Developer Relations group and the open source initiatives such as KoolKits Shai Observability isn t new Why even have this Masterclass Tom This isn t a Masterclass about observability it s about Developer Observability To explain why the differentiation is required note that over the past decade or so DevOps and SRE roles became commonplace in many software organizations This is great as it means developers can focus on building their applications and there are DevOps engineers that deal with building and maintaining systems that get this code into the hands of customers In addition SREs are there to build systems to operate maintain and observe the software as it is running in production and they have their own set of tools to do their job well The problem starts of course when something goes wrong in production that might relate to the actual application logic or performance and not the infrastructure that runs it Back in the day when production failed we could just connect to the server and see what s going on to understand why a specific path of our code is behaving in a weird way Now as application developers we rarely have access to the production machine ourselves as there are dedicated teams that are supposed to do that work instead of us This removes us from “the metal and this gap between the developer and the actual code running in production results in a difficulty to understand exactly how our application is behaving in production and how we should build the next set of features sot that they will behave well in the real world Observability tooling is there to fill that gap but most of the tools are designed for DevOps and SREs This makes sense as they usually handle the production workloads but it leaves application developers out of the picture Developer Observability revolves around tools and practices that were designed with application developers in mind They provide the value proposition developers need and “meet them in their own environments This fits cleanly into the “shift left paradigm that is all about re empowering developers Bringing tools to R amp D so we can be as productive as we were a decade ago when the machine running our code was closer to us both physically and metaphorically without sacrificing all the amazing gains we made in this field Shai Can you give examples Tom Sure A tool designed for the DevOps crowd like an APM will present you with performance information about a web service It won t tell you exactly the failure happened it will just tell you there was a failure This is fine for operators but not so great for a developer The obvious comment when I mention this to people is that when you have a failure you might have logs but in my experience might is key you usually either have no logs or way too many logs that raise your ingestion bill And even then combing through logs to find the right container in the right pod in the right node in a large ks cluster…that isn t fun Developer observability tools work at the source code level too fine grained for OPS but just right for R amp D Shai It sounds like you re describing debugging How is this different Tom There s a great deal of correlation between developer observability and debugging We use both with a similar intent of tracking a bug or failure The differentiating factor is the production environment In it we need stability security and scale We can t address any of those with regular debuggers Shai Why not Tom Critical mass Kubernetes and cloud native revolutionized our industry it s now possible to build applications at a scale that only FAANG companies could dream of a few years back Serverless and hosting made things even more complex and further diverged the production environment from local and staging With this much scale and diversity you re bringing a lot of complexity to the table As complexity in production rose quickly over the past decade we re now facing a dire need for better comprehension of our production environments in the past observability tools were optional As production complexity rises they become essential Shai Can you tell me how KoolKits fits into that Tom At Lightrun we keep our finger on the pulse of developer first innovation When kubectl debug went into beta we instantly started evaluating it and tried to understand how we can build on that For the unfamiliar Kubectl debug lets you run a new container in the same namespaces as a running pod for debugging purposes This is amazingly useful when tracking some production issues But one of the pain points in that approach has been the bare nature of the container images you get out of the box with kubectl debug There are no tools debuggers vim etc you have to bring your own tools That s when Leonid our CTO came up with the idea of KoolKits which is an opinionated set of pre installed tools for kubectl debug There s a variant for each language platform e g Java JVM NodeJS Python and even Go We re pretty excited about it and recently open sourced it as well see the project here Shai Thank you so much for this interview Tom Do you have any closing thoughts you wish to share Tom I hope everyone joins us for the Developer Observability Masterclass There will be some amazing industry leaders to talk to and I can t wait to pick their brains on this awesome new methodology The Thoughtworks team are the people who brought us knowledge on refactoring microservices progressive delivery etc well before those were “trends and common best practices and James from Redmonk is an industry legend I m sure we all have a lot to learn from them See you there |
2022-03-16 13:35:26 |
海外TECH |
DEV Community |
From AWS Lambda to AWS Step Function |
https://dev.to/aws-builders/from-aws-lambda-to-aws-step-function-3ook
|
From AWS Lambda to AWS Step FunctionServerless applications are becoming more common and more people migrate their container applications So I see a pattern emerging talking around with people in different countries and this post is just a summary of things that I have been blabbering about for a while MigrationsServerless applications at first could be seen as complex especially if you spent your entire life working on different setups So the first step is to understand how your system works and decompose it You can find a lot of this matter like decomposing by business capabilitysubdomaintransactionHopefully your application is already using this separation After this point you need to decide how to move to the serverless design effectively and you can opt for Completely replacing the system Shadowing allows you to run two separate versions of the application Both have pros and cons and you could mix them based on the needs A good solution is to incrementally replace specific pieces of functionality with new applications and services creating a façade proxy that intercepts requests and redirects requests either to the legacy application or the new services The fat LambdaIt has been written a lot on this matter but a fat Lambda is like shift and lifts all your code To make it easier a fat Lambda will do too many things What is too big I do not want to get into this discussion because it is the same as TDD or not TDD My angle is for increasing the application s maintainability observability and onboarding time A possible fat LambdaI will show a random code to give you an idea class WeekFactory public day input Day switch input day case Monday return new Monday input case Tuesday return new Tuesday input case Sunday return new Sunday input A factory creates an object but lets the subclass decide which class to instantiate Imagine that inside each subclass there is a logic based configuration and each Day returns a type of Day that varies independently context new Context input context doSomething interface Strategy doSomething input class StartegyA Strategy doSomething input class StartegyB Strategy doSomething input This code is very generic but imagines a use case like The Monday factory loads the StrategyX based on input and dynamic config conditions If it is Sunday factory loads the StrategyX based on input and dynamic config conditions and also check if it is the third Sunday of the month As you can see each Day object can be something different each time Is this is what we consider too fat There is nothing wrong with this code in one Lambda function but my angle is for increasing the application s maintainability observability and onboarding time Move it to Step FunctionI just added two days to keep the image clear for the explanation With the Step Function we can build a flow in multiple ways I can use the Parallel state sending the same request to all the Lambda functions and each of them will take care to discard the event So for example if the input contains Monday all the other Lambda like Tuesday will discard the request You can add Choice state and avoid triggering Lambda functions and have a clear path I have added both because it is up to you which one you want to use BenefitsIf you are thinking Too many Lambda functions you are not alone because now you moved from for example one Lambda function to seven Lambda functions plus all the strategies but what is the problem with this I gained much more Observability I can identify individual service responsibilities without understanding the details Maintainability I have removed boilerplate code like if switch and more Extensibility I can now extend a branch adding a specific logic or strategy without worrying about the base flow Reduce onboarding time I can use the Step Function flow that indicates business logic without worrying about going inside the code reading unit tests and explaining why or why not using a factory or a strategy pattern ConclusionIt took more configuration primarily Infrastructure as Code to setup the Step Function than just having a lambda Moving to this design is not without friction because you need to know the limitation of the Step Function service and test the application to see if some new behaviour exists Nevertheless it will force you to decouple your code reduce code ownership and reduce the complexity of your application benefiting from many built in features provided by AWS Step Function like error condition handling input and output processing try catch and so on |
2022-03-16 13:18:22 |
海外TECH |
DEV Community |
Import Maps Under the Hood in Rails 7 |
https://dev.to/appsignal/import-maps-under-the-hood-in-rails-7-4752
|
Import Maps Under the Hood in Rails Import maps is the new feature in Rails that allows us to say goodbye to Node js and tools like Webpack There s no need for bundling anymore With this new mechanism you can still manage your JavaScript libraries with a specific version Instead of one big file though your application serves many small JavaScript files It s essential you know how import maps work to benefit from the newest version of Rails but don t worry you can still use tools like Webpack instead However it s also worth discovering what is happening under the hood This way you can better understand the journey from installing a JavaScript library in your project to serving its content to your users This article will show you how to install serve and uninstall JavaScript libraries with import maps and what happens under the hood during each phase The Core of Import MapsThe feature itself is not complicated However before I show you what happens inside the library I would like to introduce the JSPM tool JSPM is a shortcut for JavaScript Package Management Thanks to this tool you can load any NPM package inside the browser without extra tooling and it will be fully optimized Rails uses JSPM to serve JavaScript libraries in your application You can either download the source files to the vendor directory or serve the code directly from the URL For example to access the jQuery library you can call URL in your browser and you will receive the URL to the minified source code in the JSON response Of course the service provides some more options for requests but this knowledge is enough to understand how Rails cooperates with JSPM in the import maps library Install Import Maps in Your Rails ProjectThe import maps feature is available in Rails as a Ruby gem If you generate a new project with Rails it s included in the Gemfile by default You can add it to existing projects by executing the following command bundle add importmap railsOnce you have the gem installed you have to generate the required files by using the following command bin rails importmap installWhat does this command do exactly First it calls the install rake task included in the importmap namespace The gem delivers the rake task Inside the task the standard rails rake task is executed system RbConfig ruby bin rails app template LOCATION File expand path install install rb dir The install rb file does a few things in the following order Adds helper to the layout in the head section if the application html erb layout exists in your project it adds the javascript importmap tags line before the closing lt head gt tag This helper includes JavaScript libraries pinned by import maps If your project does not include the standard layout file it will render the information about the helper so you can add it by yourself Creates app javascript application js file it adds the comment about import maps to let you know that there is a new place where you should define dependencies Creates vendor javascript directory this is where JavaScript libraries will be stored if they are not served directly via a URL Updates sprockets manifest if it exists sprockets needs to know about the JavaScript files placed inside the vendor javascript directory Creates config importmap rb file this will contain the list of libraries used by Rails something like package json file Copies bin importmap file and sets the correct permission to execute it this file is used to pin and unpin specific libraries As soon as this process finishes you are ready to install JavaScript libraries using the bin importmap file and Rails is prepared to serve those files to your visitors Adding Libraries to Your Rails ProjectWhen installing a library with import maps you have two options you can either use the code directly from the CDN URL or download the file and serve it directly from your server Let s explore the CDN option first Using NPM Packages via JavaScript CDN sIt all starts with the pin command and the library name bin importmap pin jqueryYou pass two arguments to the program located inside the bin importmap file importmap is an executable file that loads a config application rb file from your project and the import maps commands file Import maps use the Thor gem to handle command line programs gently The first argument pin is the command name When you invoke it the following things happen under the hood Request to JSPM API is executedAs I mentioned before the gem uses JSPM to get the contents of the package into our application Therefore the very first step is the request URL formation Without any extra parameters passed to the pin command the request URL is with the following parameters install jquery the param is an array because you can install multiple packages simultaneously flattenScope true with this param set to true the returned import map format will be more straightforward without scopes if possible env browser module production this is the list of environment condition strings provider jspm besides JSPM Skypack JSdelivr and Unpkg providers are available to use as well Try accessing flattenScope true in your browser and you will get a simple JSON response with some simple attributes Response from JSPM is parsedParsing is a very straightforward phase As you saw the response is simple and all we need is the library name and CDN URL The Packager class is responsible for parsing the response in the import map library Instead of returning the attributes it returns a complete line that you can use directly in the config pin package to url If you are not yet familiar with don t worry as it works almost the same as the following pin package to url The only difference is that the notation escapes the double quotes automatically The generated config line passes to another function that handles the config file update process Import map config is updatedThe last step is to update the config file with the pin definition Because the previous pin definition can be present the gem first verifies the config file and searches for the existing library definition It s simple to do with the regex pin package If the pin definition for the given package is present the gem replaces the line with the new definition If the previous definition is not present the gem adds a new line at the end of the config importmap rb file Note When you use this method keep in mind that this option is free but one person supported by the community manages the JSPM servers This situation could change in the future so I advise you to store libraries locally if you plan to use import maps with production ready applications Downloading NPM PackagesIf you don t want to use source code from a CDN URL you can download the library to the vendor directory inside your application In this case the process is very similar to the case with CDN URLs What s different is that the code is downloaded into a js file before the config line is returned for an update The download processThe download process consists of a few small steps The gem calls FileUtils mkdir p which creates the vendor directory if it does not already exist The gem calls FileUtils rm rf to remove the previous package file if it exists The gem saves JS code located under the JSPM provided URL into the js file and places it into the vendor directory If the gem cannot download the package s contents you will be notified by a proper error raised in your command line Config line generationIf the package is named the same as the file with the package source the config line is straightforward pin package version Otherwise the import map needs to map the package name to the file directly pin package to filename version When the config line is formatted and returned the config is updated with the package definition as described in the CDN URL version above Using Pinned Packages in Your Rails AppThe gem extensively uses the Rails engine mechanism to deliver features The Importmap Engine defines a bunch of initializers that perform the configuration Import Pinned Packages from config importmap rbThe configuration lines inside the config importmap rb file are replaced with references inside the application First the gem collects all definitions into a hash where the Struct object represents each definition to make it easier to access specific attributes You can call Rails application importmap packages to access the hash with all definitions inside the application Including References to Packages inside ViewsWhen pinned packages are imported you can include them in your views to provide the code The gem provides a javascript importmap tags helper which you can simply render in your layout It uses Rails application importmap to generate JSON output for all pinned libraries and with the usage of asset helper in Rails it provides the correct paths to the libraries After adding the following line to your head section of the layout lt javascript importmap tags gt You will get the following output assuming that you are only using jQuery lt script type importmap data turbo track reload gt imports application assets application fcbecffaafbfafccbcddbb js jquery jquery dist jquery js lt script gt Handling Import Maps by BrowserFrom that moment on the browser handles the rest If you are not familiar with the importmap script type let me explain it quickly Import map simply controls what is fetched when you use the following statement inside your JavaScript code import jquery Removing Pinned PackagesTo remove a pinned package you have to execute the unpin command bin importmap unpin reactYou don t have to pass the download parameter because the gem will automatically delete any files related to the package The removal process consists of three steps Request to the JSPM API the same request is executed when the package is added The gem does this to get up to date package information Removal of the existing package files the gem uses FileUtils rm rf to remove all related files even if they are placed in directories Remove the config lines related to the package with the usage of File readlines the gem loads all lines from the config file selects those that do not contain anything related to the removed package and saves them again in the config file Simple as that You can also unpin multiple packages at once just add their names after the unpin argument Wrap UpWe ve reached the end of this short yet valuable journey You now know that import maps is just a different way of loading JavaScript libraries in your web application Instead of one big bundled file you serve multiple smaller files that are easy to cache and control With the importmap rails gem it s easy to adapt import maps in your project The gem ships with a simple configuration file and command line interface to install and remove packages using the JSPM Should you use import maps in your next Rails project As always it depends The good thing is that you are not limited to import maps ーyou can always switch between it Webpack and similar more complex tools Thanks for reading and happy coding P S If you d like to read Ruby Magic posts as soon as they get off the press subscribe to our Ruby Magic newsletter and never miss a single post |
2022-03-16 13:15:12 |
海外TECH |
DEV Community |
What Every Good README Should Contain |
https://dev.to/thawkin3/what-every-good-readme-should-contain-1fj8
|
What Every Good README Should ContainI work in a large engineering organization that has thousands of repos actively in use The unique nature of my current role means that rather than working in just a few of these repos I am often working in several new repos each week That s a lot of new information to consume each week It s not realistic for me to become intimately familiar with the ins and outs of every repo I work with but there are certain core pieces of information that I almost always need to know Ideally this information should be contained in each repo s README So what information should be included in a README At the very least every good README should contain the following What this repo is or doesHow to run the project locallyHow to run the testsHow to get merged changes into the larger appAnything else that you think would be helpful to call out for your specific repoLinks to any additional resourcesLet s take a brief look at each of these items and why they re important What this repo is or doesThe README should establish some context for the developer What is this repo What does it do What purpose does this repo serve What are the problems that it solves or the functionality that it provides A couple paragraphs of high level overview can help set the stage for everything else that the developer may want to know How to run the project locallyNow that the developer knows what the repo is how do they run it Do they need to install any dependencies or run a setup script first For a frontend app this is hopefully as simple as just running yarn install or npm install Once the setup is done how do they start the app locally If the app can be run in an independent sandbox environment like Storybook include instructions for that This could be as simple as running yarn start storybook What about running the app in the context of a larger app For organizations that have many repos it s common for each smaller repo to be published as an npm package and then each package gets installed as a dependency in the larger parent app So how do you run this smaller app locally to see your new changes before publishing a new version Instructions could include linking the dependency with something like yarn link or yalc Or maybe you use a browser extension like Resource Override to override the bundled JS file in the browser Or maybe this app is a microfrontend and so you simply need to start the app with a command like yarn start and then override the url for that resource used How to run the testsThe developer knows what the app does and how to run it but what about tests Ideally running the test suite is as easy as running yarn test or some variant of that Sometimes there is some hidden setup required before you can run your tests so calling out that information is helpful For example maybe you run integration tests with Cypress but an implied prerequisite for running the Cypress tests is that the app needs to be running locally first If the test script doesn t start the app for you already you should be sure to document that expected test setup How to get merged changes into the larger appThe developer is able to run the app and the tests and they successfully made some changes to the code Now what How do they get those changes merged into the larger app You ll want to be sure to document your branching strategy and what the merge request process looks like After code is merged what happens next If this is an npm package does a new version of the package get published automatically in a post merge pipeline Or does the developer need to manually publish a new version If this is a microfrontend do the changes get deployed automatically after merging Or does the developer need to manually kick off a pipeline to do that Anything else that you think would be helpful to call out for your specific repoWith those four previous items we ve covered the basics that all developers need to know They have context for the project and are able to successfully run test and deploy the app Is there anything else that they should know This is harder to write generic guidance for but surely there is something special about your repo that may not be common knowledge Do you use any unique branching strategies or have any special branches besides a master or main branch Do you have any special linter or commit setup that people should be aware of Are there any gotchas to know about in regards to pipelines or deployments What about coupling with other repos Is this repo used closely with another repo These kinds of hidden gems are incredibly useful to document so that it doesn t remain as tribal knowledge Links to any additional resourcesFinally are there any other docs or wiki pages that a developer might be interested in reading Perhaps you use something like Notion or Confluence and you have additional information documented there Be sure to include links to anything else that for whatever reason isn t included in the README but that may be important to know ConclusionThe README is all about helping new developers work with your repo successfully When a developer has all the context and information they need they ll be more self reliant They ll be less likely to come to you with questions and you ll find yourself not having to repeat yourself as much It s a win for everyone involved |
2022-03-16 13:14:55 |
海外TECH |
DEV Community |
Code smell | Shotgun surgery |
https://dev.to/producthackers/code-smell-shotgun-surgery-2k30
|
Code smell Shotgun surgeryHello today we are back with the code smells refactoring series and in this case we are going to talk about code smell called Shotgun Surgery this smell can be detected if making a change have to replicate this change in different parts of our code CauseA single responsibility has been split up among a large number of sites This can happen after the overzealous application of Divergent Change ExampleWe can see that the minimum balance check is being duplicated in both methodsclass Account private amount number constructor amount number this amount amount debit debitAmount number void if this amount lt throw new Error Minimum balance should be over transfer from Account to Account transferAmount number void if from amount lt throw new Error Minimum balance should be over SolutionExtract minimum balance checks to method to be able to reuse it in the different methods of the classclass Account private amount number constructor amount number this amount amount assertMinimumBalance amount number void const MINIMUM AMOUNT if amount lt MINIMUM AMOUNT throw new Error Minimum balance should be over MINIMUM AMOUNT debit debitAmount number void this assertMinimumBalance this amount transfer from Account to Account transferAmount number void this assertMinimumBalance from amount Bonus track Shotgun surgery in CSS Yes see the next example button primary background color eca button secondary background color be navbar primary background color eca navbar secondary background color be If now they ask us to modify the primary color for another what is the solution Search globally in all our CSS and replace it NOOO ️ The solution is use CSS variables We can declare variables in CSS globally with the pseudo class root and thus use them in any part of our CSS in this way we centralize the possible changes in only the variables thus avoiding having to replace each color value root primary background eca secondary background be button primary background color var primary background button secondary background color var secondary background navbar primary background color var primary background navbar secondary background color var secondary background Thanks for reading me |
2022-03-16 13:10:40 |
海外TECH |
DEV Community |
Web Component Best Practices |
https://dev.to/markacianfrani/web-component-best-practices-3gnp
|
Web Component Best PracticesWriting Web Components is hard Writing good Web Components is really hard After spending the last year building out the AstroUXDS Web Components I ve learned a hard truth that a really good React Vue Angular FoobarJS component does not make a really good web component For those who are first jumping into the pool of Web Components here is the guide that I wish I had one year ago NOTE A lot of this deals mostly in the context of implementing design systems Why are you doing this The promise and allure of Web Components can be all too tempting Being able to write and maintain a single code base that can be used across any framework is something that speaks to everybody almost immediately However Web Components are not a panacea They require an entirely new discipline and frame of thinking A lot of people will tell you Web Components are great look at how easy it is to ship a button component fully encapsulated with your Design System s styles What they don t tell you is now you have to figure out how to get your button to interact with forms properly or handle accessibility When you choose to write a web component you re taking on the fully responsibility of having to think through every possible use case and scenario while simultaneously juggling developer experience user experience and maintainability Be prepared to think through every minute detail Failure to do so will result in angry users because the Shadow DOM is unforgiving Often times the developer will have no mechanism to solve the problem themselves Remember we are writing custom HTML elements These atoms need to be flexible enough to create the universe Anatomy of a Web ComponentTo write a good web component you need a solid understanding of all of the available APIs at your disposal You will be constantly juggling between extensibility vs ease of use For any given feature you should think carefully about which API to use If you re coming from a framework mindset you might already be familiar with slots props and events Web Components give us two additional unique APIs CSS Custom Properties and CSS Shadow Parts Your component s styling is now it s own API Use this to your advantage SlotsExtremely flexibleAdd complexity to component codeRequire developers to write more boilerplateSlots are probably the most powerful API for extendibility because they sit outside Shadow DOM and can contain any custom HTML Properties AttributesEasy to useFamiliar to usersNot very flexibleProperties and attributes are the most familiar concepts usually used for controling things like state However they are the least flexible when it comes to allowing custom content For example lt my component content This is my content gt lt my component gt This works great if all you need is to display a basic string But what if I wanted to pass in my own HTML Maybe I want to throw in an svg icon or a whole form I can t fit all of that in as just a string This component wouldn t be very useful to me MethodsProvide unique functionalityRequire JavaScriptPublic methods are great if your component has some kind of action that it can perform A good example would be a typical Modal component that might have show and hide methods Simply using an open prop in this case might not be enough for a developer looking to do something after the modal has been opened because it may not be available yet Instead they would need to use the modal s show method which could return a promise that would resolve once it has finished opening CSS Custom PropertiesFlexibleBad DX if used carelesslyCSS Custom Properties are one of two ways for allowing developers to pierce the Shadow DOM Remember doing my button background red won t do anything because of Shadow DOM encapsulation But if you used a CSS Custom Property to control your background color developers could do something like button bg color red In the early days CSS Custom Properties were the only way for developers to customize the styling of a Web Component This lead to a lot of early adopters adding an absurd amount of CSS Custom Properties button border radius button text color button font family etc etc Custom Properties for nearly every imaginable CSS property It was a hot mess Luckily we got a better way CSS Shadow Parts But CSS Custom Properties still have their place CSS variables are scoped to the host element and can be reused throughout the component A good example of a CSS variable would be border width which might get reused throughout a component to ensure borders share the same width for all internal elements Shoelace When To Use a CSS Custom Property CSS Shadow PartsExtremely flexibleMaintainability can suffer if used carelesslyRequire developers to write more boilerplateCSS Shadow Parts solve the problem of how do I style XYZ They allow you to define the parts that your custom element is composed of Channel your inner Zeldman Shadow parts should have some semantic meaning They should represent an abstract piece of your component Because these are part of your API you need to be careful in what you expose publicly Sometimes the answer to how do I style XYZ is you don t Maybe you don t want the background color to be allowed to be anything Instead you might expose a property that can only accept a few whitelisted options Part names should be consistent across all components wherever possible Shadow parts cannot be nested Shadow parts can only be single elements my componet part base gt svg display none won t work Avoid making every element a part if possible Once an element is a shadow part it will require a breaking change to alter the markup later See when to create CSS parts for much greater detail If your component is small enough atom level you may end up with every element having its own shadow part and that is totally okay The Right ToolNow let s take a very simple feature we need to write a button component that can show two different variants primary and secondary How might we implement this With Props lt my button type primary gt lt my button gt lt my button type secondary gt lt my button gt With a Methodconst el document querySelector my button el setType primary el setType secondary With CSS Custom Propertiesmy button button background color var color primary button border color var color primary button text color var color text all hover active focus states sheesh With CSS Shadow Partsmy button part container background color var color primary border color var color primary etc etc Here are four different ways we can expose a given feature A prop is clearly the winner in terms of ease of use But now imagine what if we wanted to allow more than just two colors What if we wanted to allow any color as long as it is defined in the design system We would need to add another prop options The point is there is no single best answer for which API to use when It s a matter of deciding what you want to allow and what the best DX would be Opinionated Best Practices Be Declarative Avoid arrays and object attributesRemember we are writing custom HTML elements Our components must be usable in the browser without a framework without JavaScript Think of this use case as your lowest common denominator My personal litmus test would a teenager be able to use this element on their MySpace page So let s consider a basic List component Your first pass might look something like lt my list data id text Item id text Item gt lt my list gt This works nicely if you re using a js framework to do the heavy lifting for your data binding But if you re using plain HTML you re now forced to write some javascript const data const el document querySelector my list el data dataNow what if you wanted the list items to be links Or include an icon What if you wanted every third item to open a modal and every tenth item to navigate to a page Back to the drawing board lt my list gt lt my list item gt Item lt my list item gt lt my list item gt lt my icon gt Item lt my list item gt lt my list item gt By creating a new my list item component suddenly we are much more flexible and can avoid the unending series of what if questions If you must use arrays or objects make sure to accept them only as properties and do not reflect them as attributes for performance reasons In the words of Kent C Dodds avoid soul crushing components Don t style attributes lt my component open gt lt my component gt my component display none my component open display block For this example to work you need to be extra careful that you are reflecting your open attribute correctly If someone were to change the open property and you forget to reflect it to the attribute your component will break and this can be very difficult to debug Instead use internal classes and style those host styles are sacredBe careful when styling host Anything you put here will NOT be shadow dom encapsulated and thus can be changed by the developers using your component host styles are generally best for default properties like display Try to fail silentlyDoes lt select gt throw an error if you try and pass in an lt h gt as a child No HTML fails silently We should also treat the console as sacred as well and do our best job not to pollute it with unnecessary warnings and errors Throw errors only when you absolutely cannot continue If you re throwing an error take a second to pause and consider why and make sure that you have a good reason Sometimes they are unavoidable though On AstroUXDS we generally like to reserve warnings for deprecating warnings only But this is just an opinionated stye decision Data Flow Props Down Events UpThe traditional wisdom around data flow remains the same Props down events up Lift state up Whatever you want to call it If two sibling components need to talk to each other they probably need a parent mediator component Steal Code I m not a lawyer Seriously The web today is the result of a generation right clicking view source and assimilating what others have done That s how we got to where we are now That s why the web is the most democratizing platform The idea of sharing and openness is baked right in to your browser If you don t personally have an anecdote about trying to create a website for your band in middle school by copy and pasting some piecemeal HTML you found somewhere I guarantee you probably know at least one person who does So stand on the shoulder of giants and don t reinvent the wheel and all those other cliches When you encounter a problem go look at how other people have solved it Pick the one you like the most Forms for example were a fun one Some of the best resources that I ve found are Shoelace Quite possibly the gold standard of web component libraries A lot of these best practices have been adapted from Shoelace s own Best Practices I encourage you to read this in full multiple times My entire foundation of what makes a great web component has come from reading through Shoelace s source Ionic One of the very few early adopters and champions for web components Completely battle tested The amount of eyes they have on their components is insane Superior DX and a perfect case study on how web components can serve developers of all frameworks Spectrum Web ComponentsAdobe s Design System web component flavored OpenUI Not a library but one of the most valuable resources when designing a net new component My go to for inspiration on the mundane task of what to actually name things what are the expected props etc MDN For inspiration return to the classics If you re building a custom element that already exists it s generally a good idea to default to the behavior of the native element Building web components gave me a new appreciation for HTML gt Tip in Chrome Dev Tools you can turn on show user agent shadow dom to see the shadow dom of all your favorite classic elements Web dev s Custom Element Best Practices Another great general list of best practices |
2022-03-16 13:02:43 |
Apple |
AppleInsider - Frontpage News |
iPad Air 5 review roundup: A great yet confounding value proposition |
https://appleinsider.com/articles/22/03/16/ipad-air-5-review-roundup-a-great-yet-confounding-value-proposition?utm_medium=rss
|
iPad Air review roundup A great yet confounding value propositionThe iPad Air has the M comes in five new colors and starts at Here are the initial reactions to Apple s mid range tablet The iPad Air is the cheapest way to get the M processorThe fifth generation iPad Air retains the same external design and display but everything else has been updated The M processor ultra wide selfie camera with Center Stage faster USB C port and G bring the iPad Air incredibly close to the inch iPad Pro yet again Read more |
2022-03-16 13:49:51 |
Apple |
AppleInsider - Frontpage News |
Wemo Smart Plug with Thread review: An affordable & fast HomeKit outlet |
https://appleinsider.com/articles/22/03/16/wemo-smart-plug-with-thread-review-an-affordable-fast-homekit-outlet?utm_medium=rss
|
Wemo Smart Plug with Thread review An affordable amp fast HomeKit outletWemo s latest HomeKit smart plug carries a small price tag but boasts Thread connectivity for rapid response times and excellent home coverage The new Wemo Smart Plug with ThreadAt CES Belkin made a few HomeKit announcements It revealed its Wemo Smart Video Doorbell that hit the market not long after and it announced that it would be bringing Thread to many of its Wemo devices later this year Read more |
2022-03-16 13:25:48 |
Apple |
AppleInsider - Frontpage News |
New leaked 'iPhone 14 Pro' renders back up hole-punch rumors |
https://appleinsider.com/articles/22/03/16/new-leaked-iphone-14-pro-renders-back-up-hole-punch-rumors?utm_medium=rss
|
New leaked x iPhone Pro x renders back up hole punch rumorsA new series of purported iPhone Pro D CAD renders back up previous leaked details including claims of a hole punch design instead of a notch Source mobilesLeaks about the forthcoming iPhone Pro started even before the iPhone Pro was launched Now a new set of what are said to be D CAD renders claim to show the whole design of the next iPhone Read more |
2022-03-16 13:43:41 |
Cisco |
Cisco Blog |
What top tech analysts have to say about our latest Purpose Report |
https://blogs.cisco.com/csr/what-top-tech-analysts-have-to-say-about-our-latest-purpose-report
|
What top tech analysts have to say about our latest Purpose ReportSocial good is at the heart of everything we do Read what top tech analysts had to say about Cisco making its mark with the Purpose Report |
2022-03-16 13:00:54 |
海外TECH |
CodeProject Latest Articles |
Training a Custom Object Detection Model on Azure Custom Vision Part 2: Testing the Model |
https://www.codeproject.com/Articles/5326982/Training-a-Custom-Object-Detection-Model-on-Azur-2
|
Training a Custom Object Detection Model on Azure Custom Vision Part Testing the ModelIn the previous article we trained a simple machine learning model that identifies when and where a human is present in an image This article will demonstrate how to test this model and re train it as necessary |
2022-03-16 13:37:00 |
海外科学 |
NYT > Science |
In Africa, a Mix of Shots Drives an Uncertain Covid Vaccination Push |
https://www.nytimes.com/2022/03/15/health/covid-vaccines-africa.html
|
In Africa a Mix of Shots Drives an Uncertain Covid Vaccination PushSupplies are more plentiful now but they are unpredictable and often a jumble of brands Many places can t meet the W H O s recommended dosing schedules |
2022-03-16 13:59:30 |
金融 |
RSS FILE - 日本証券業協会 |
会長記者会見−2022年− |
https://www.jsda.or.jp/about/kaiken/kaiken_2022.html
|
記者会見 |
2022-03-16 13:30:00 |
ニュース |
BBC News - Home |
Nazanin Zaghari-Ratcliffe and Anoosheh Ashoori on way home to UK |
https://www.bbc.co.uk/news/uk-60756870?at_medium=RSS&at_campaign=KARANGA
|
anoosheh |
2022-03-16 13:53:02 |
ニュース |
BBC News - Home |
Ukraine war: Zelensky invokes 9/11 in plea to US Congress |
https://www.bbc.co.uk/news/world-us-canada-60762022?at_medium=RSS&at_campaign=KARANGA
|
military |
2022-03-16 13:51:52 |
ニュース |
BBC News - Home |
Saudi Arabia: Boris Johnson to raise human rights in energy talks |
https://www.bbc.co.uk/news/uk-politics-60754163?at_medium=RSS&at_campaign=KARANGA
|
supplies |
2022-03-16 13:28:14 |
ニュース |
BBC News - Home |
Wayne Couzens: Met PCs deny sharing offensive messages with killer |
https://www.bbc.co.uk/news/uk-england-london-60763436?at_medium=RSS&at_campaign=KARANGA
|
borders |
2022-03-16 13:38:47 |
ニュース |
BBC News - Home |
Chicago Cubs owners confirm interest in buying Chelsea |
https://www.bbc.co.uk/sport/football/60766823?at_medium=RSS&at_campaign=KARANGA
|
chelsea |
2022-03-16 13:49:42 |
ニュース |
BBC News - Home |
Russia's state TV hit by stream of resignations |
https://www.bbc.co.uk/news/world-europe-60763494?at_medium=RSS&at_campaign=KARANGA
|
channels |
2022-03-16 13:09:26 |
GCP |
Google Cloud Platform Japan 公式ブログ |
動画の需要増加に対しデベロッパー重視のサービスで応じる Mux の手法 |
https://cloud.google.com/blog/ja/topics/startups/mux-focuses-on-developers-for-simpler-video-infrastructure/
|
デベロッパーの環境を簡素化することはイノベーションを実現するうえで不可欠であり、これはMuxがGoogleCloudの耐障害性の高いインフラストラクチャとデベロッパー重視のサービスを利用する理由の一つである、とDahl氏は話します。 |
2022-03-16 14:00:00 |
北海道 |
北海道新聞 |
ウクライナへ輸送目的か ロシア艦4隻、津軽通過 |
https://www.hokkaido-np.co.jp/article/657725/
|
津軽海峡 |
2022-03-16 22:23:02 |
北海道 |
北海道新聞 |
2月の米小売売上高、0・3%増 2カ月連続プラス |
https://www.hokkaido-np.co.jp/article/657761/
|
連続 |
2022-03-16 22:30:00 |
北海道 |
北海道新聞 |
塩野義、海外でも最終治験開始へ コロナ飲み薬、米機関が支援 |
https://www.hokkaido-np.co.jp/article/657750/
|
塩野義製薬 |
2022-03-16 22:19:00 |
北海道 |
北海道新聞 |
道内公立高入試合格発表 2万7450人に春 |
https://www.hokkaido-np.co.jp/article/657703/
|
合格発表 |
2022-03-16 22:19:32 |
北海道 |
北海道新聞 |
国内で5万7922人感染 163人死亡、新型コロナ |
https://www.hokkaido-np.co.jp/article/657694/
|
新型コロナウイルス |
2022-03-16 22:02:25 |
北海道 |
北海道新聞 |
コメリ西桔梗店、30日オープン 道南初、地元店は連携し迎え撃つ |
https://www.hokkaido-np.co.jp/article/657744/
|
道南 |
2022-03-16 22:15:27 |
北海道 |
北海道新聞 |
口永良部島で火山性地震 噴火警戒レベルは2を維持 |
https://www.hokkaido-np.co.jp/article/657747/
|
口永良部島 |
2022-03-16 22:11:00 |
北海道 |
北海道新聞 |
首相、マスク着用継続を訴え 「解除」時期の見通し、明言せず |
https://www.hokkaido-np.co.jp/article/657746/
|
岸田文雄 |
2022-03-16 22:11:00 |
北海道 |
北海道新聞 |
ロシア海軍艦艇4隻、津軽海峡を通過 |
https://www.hokkaido-np.co.jp/article/657743/
|
戦車揚陸艦 |
2022-03-16 22:07:00 |
北海道 |
北海道新聞 |
ソ6―9神(16日) 阪神の佐藤輝が2試合連発 |
https://www.hokkaido-np.co.jp/article/657745/
|
阪神 |
2022-03-16 22:08:00 |
北海道 |
北海道新聞 |
ウクライナ侵攻に悲しみ 「多くのロシア人は戦い望まない」 函館の淡中リーラさん心中を吐露 |
https://www.hokkaido-np.co.jp/article/657742/
|
淡中 |
2022-03-16 22:07:00 |
北海道 |
北海道新聞 |
原付きのご当地ナンバー「ライラック+テレビ塔」 札幌市が今夏導入 |
https://www.hokkaido-np.co.jp/article/657737/
|
記念 |
2022-03-16 22:06:06 |
北海道 |
北海道新聞 |
NY円、118円前半 |
https://www.hokkaido-np.co.jp/article/657739/
|
外国為替市場 |
2022-03-16 22:06:00 |
北海道 |
北海道新聞 |
レースで活躍、高橋国光さん死去 二輪で日本人初の世界GP優勝 |
https://www.hokkaido-np.co.jp/article/657738/
|
高橋国光 |
2022-03-16 22:06:00 |
北海道 |
北海道新聞 |
地元ファンの前で優勝を アイスホッケー・レッドイーグルス 19日から東北とプレーオフ |
https://www.hokkaido-np.co.jp/article/657733/
|
東北 |
2022-03-16 22:04:37 |
北海道 |
北海道新聞 |
ウクライナ、子どもの死者百人超に ロシア外相「NATO問題で合意も」 |
https://www.hokkaido-np.co.jp/article/657617/
|
検察当局 |
2022-03-16 22:01:22 |
GCP |
Cloud Blog JA |
動画の需要増加に対しデベロッパー重視のサービスで応じる Mux の手法 |
https://cloud.google.com/blog/ja/topics/startups/mux-focuses-on-developers-for-simpler-video-infrastructure/
|
デベロッパーの環境を簡素化することはイノベーションを実現するうえで不可欠であり、これはMuxがGoogleCloudの耐障害性の高いインフラストラクチャとデベロッパー重視のサービスを利用する理由の一つである、とDahl氏は話します。 |
2022-03-16 14:00:00 |
コメント
コメントを投稿