投稿時間:2021-11-30 16:43:52 RSSフィード2021-11-30 16:00 分まとめ(52件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
TECH Engadget Japanese 外に出て運動するのが億劫になる季節。だったら室内向けの器具を買えばいいのでは?|Amazonブラックフライデー https://japanese.engadget.com/black-friday-sale-fitness-062015077.html だったら室内向けの器具を買えばいいのではAmazonブラックフライデーいよいよ寒さが本格化してきて、家の外に出るのが億劫になる季節になりました。 2021-11-30 06:20:15
TECH Engadget Japanese ブラックフライデーで50%OFF、球体Echo dotの音質をチェック https://japanese.engadget.com/echo-083036416-000043863-152902676-061541549.html amazon 2021-11-30 06:15:41
TECH Engadget Japanese ドコモ、スマホ故障診断アプリ「スマホ診断 online」に改善提案機能を追加 https://japanese.engadget.com/docomo-smartphone-after-support-online-060013551.html online 2021-11-30 06:00:13
IT ITmedia 総合記事一覧 [ITmedia News] 「@gmail」を「@gmai」と誤記 新潟県職員、個人情報入りメール誤送信 https://www.itmedia.co.jp/news/articles/2111/30/news146.html gmaicom 2021-11-30 15:36:00
IT ITmedia 総合記事一覧 [ITmedia PC USER] センチュリー、“日本人向け”の独自設計を採用したゲーミングチェア https://www.itmedia.co.jp/pcuser/articles/2111/30/news147.html itmediapcuser 2021-11-30 15:30:00
IT ITmedia 総合記事一覧 [ITmedia ビジネスオンライン] 味の素、タイ生産の冷凍唐揚げなど44商品を最大1割値上げ 製造コストの上昇で https://www.itmedia.co.jp/business/articles/2111/30/news140.html itmedia 2021-11-30 15:25:00
IT ITmedia 総合記事一覧 [ITmedia News] 「いのちをだいじに」の時間を生み出す、書類のデジタル化をやっておこう https://www.itmedia.co.jp/news/articles/2111/30/news144.html itmedia 2021-11-30 15:21:00
IT ITmedia 総合記事一覧 [ITmedia News] 事故状況からAIが保険金支払いの可否を判断 損保ジャパン、手続きを全面自動化 https://www.itmedia.co.jp/news/articles/2111/30/news141.html itmedia 2021-11-30 15:15:00
TECH Techable(テッカブル) 人間の操縦も地図もなしでドローンが未知の環境を飛行可能に!? 新しいAIシステムを開発 https://techable.jp/archives/167646 飛行 2021-11-30 06:00:21
IT 情報システムリーダーのためのIT情報専門サイト IT Leaders IIJグローバル、IoT機器の正当性をブロックチェーンで担保する「IoTトラストサービス」 | IT Leaders https://it.impress.co.jp/articles/-/22393 IIJグローバル、IoT機器の正当性をブロックチェーンで担保する「IoTトラストサービス」ITLeadersIIJグローバルソリューションズは年月日、IoT機器管理サービス「IoTトラストサービス」を提供開始した。 2021-11-30 15:40:00
python Pythonタグが付けられた新着投稿 - Qiita ヤコビの二平方定理を使ってみました https://qiita.com/masa0599/items/6e7248e838c3666ce7f3 abnを満たす整数のペアabの個数rnはnの素因数分解が以下のように表されるとすると、spacengpfpfcdotsqhqhcdotspiequivspacemod、qiequivspacemodrnは以下の式で求められますrnffcdotshhcdotsがすべて偶数の時rnhiの一つでも奇数の時要はnの素因数を求めてmodがになるものの数を数えればいいということになります。 2021-11-30 15:10:59
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) pythonでシリアル通信を試みています。 https://teratail.com/questions/371644?rss=all pythonでシリアル通信を試みています。 2021-11-30 16:00:08
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) openCVのv4l2captureが使えない https://teratail.com/questions/371643?rss=all ①vlcaptureを使用する方法このサイトでは、カメラからの画像の取得に、vlcaptureというライブラリを使用しています。 2021-11-30 15:57:12
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) pythonのプログラムをサーバ上で常時起動させたい https://teratail.com/questions/371642?rss=all pythonのプログラムをサーバ上で常時起動させたい前提・実現したいことまずはこのページを見てくださりありがとうございます。 2021-11-30 15:56:44
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) laravelエクセルでCSVダウンロードをしたい https://teratail.com/questions/371641?rss=all laravelエクセルでCSVダウンロードをしたい前提・実現したいことphplaravel共に初心者でどうしても解決できない為、知恵をお貸しいただきたいです。 2021-11-30 15:56:17
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) Emergence of Market Research in India https://teratail.com/questions/371640?rss=all 2021-11-30 15:55:37
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) TypeScriptでオブジェクトの深い値までアクセスしたい https://teratail.com/questions/371639?rss=all TypeScriptでオブジェクトの深い値までアクセスしたい前提・実現したいこと下記のようなコードがあります。 2021-11-30 15:43:47
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) Visual Studio Codeの設定をいじっていたのですが、ユーザー設定に書き込めませんと出てきて他の設定ができないです https://teratail.com/questions/371638?rss=all 2021-11-30 15:43:01
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) DTW(動的時間伸縮法)で探索する距離の範囲を指定したい https://teratail.com/questions/371637?rss=all DTW動的時間伸縮法で探索する距離の範囲を指定したい現在、tweetの感情の時系列と株価の時系列データを比較し、感情の変化がどのくらい株価と連動しているのかの分析をやっており、DTWでつの時系列間の類似度を算出したのですが、図のようにある感情の点オレンジがそれよりも前の時間の株価青の点と対応してしまいます。 2021-11-30 15:41:05
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) Laravel8 php artisan migrate でエラーが出る。 https://teratail.com/questions/371636?rss=all Laravelphpartisanmigrateでエラーが出る。 2021-11-30 15:32:44
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) 【javascript】入力フォームから取得したテキストをそのままボタンのvalueに代入したい https://teratail.com/questions/371635?rss=all 【javascript】入力フォームから取得したテキストをそのままボタンのvalueに代入したいフォームで入力したテキストを、登録ボタンを押すことで作成される新しいボタンのvalueに入れるコードを書きたいのですが、ボタンに表示されるテキストがUndefinedとなってしまいます。 2021-11-30 15:32:36
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) UnityのScrollViewで視差スクロールを実装させたい https://teratail.com/questions/371634?rss=all UnityのScrollViewで視差スクロールを実装させたい前提・実現したいことUnityでスクロールビューを使用する際に、視差スクロールを実現させたいです。 2021-11-30 15:25:49
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) SQLSERVERのINSERT時にIDENTITYの自動採番された値を編集した値を他の列に入力できますか? https://teratail.com/questions/371633?rss=all SQLSERVERのINSERT時にIDENTITYの自動採番された値を編集した値を他の列に入力できますかMSnbspSQLSERVERnbspnbspスタンダードnbspを利用しております。 2021-11-30 15:20:12
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) Local by flywheel 環境下 ワードプレス 毎回パスワードが無効になる https://teratail.com/questions/371632?rss=all Localbyflywheel環境下ワードプレス毎回パスワードが無効になるワードプレス初心者です。 2021-11-30 15:14:12
技術ブログ Developers.IO GENERATED PHOTOSで生成された特徴が一致している顔画像の類似スコアはどれくらい出るのか気になった [Mercury Cloud] #小ネタ https://dev.classmethod.jp/articles/generated-photos-anonymizer-and-mercury-compare-api/ generatedphotos 2021-11-30 06:45:35
技術ブログ Developers.IO AivenがAWS PrivateLinkに対応したので試してみた https://dev.classmethod.jp/articles/aiven-support-for-aws-privatelink/ aiven 2021-11-30 06:35:50
技術ブログ Developers.IO Amazon CodeGuru Reviewerがシークレットを検出するようになりました https://dev.classmethod.jp/articles/amazon-codeguru-reviewer-secret-detect/ amazoncodegurureviewer 2021-11-30 06:09:01
技術ブログ Developers.IO カスタマーエンゲージメントプラットフォーム「Braze」のご紹介 https://dev.classmethod.jp/articles/introducing-braze/ braze 2021-11-30 06:01:00
海外TECH DEV Community Algorithms in JavaScript with visual examples. https://dev.to/swastikyadav/algorithms-in-javascript-with-visual-examples-gh3 Algorithms in JavaScript with visual examples Hello Programmers Most of us are scared of algorithms and don t ever start to learn it But we shouldn t be scared of it An algorithm is just steps to solve a problem Today let s cover major Algorithms in an easy and illustrative manner Don t try to memorize them algorithm is more about problem solving So sit with a paper and pen The terms in table of content might seem very scary but just be with me I promise to explain everything in the simplest manner possible Tabel of content Big O NotationUnderstanding Big O NotationAlgorithmsWhat is an algorithm and why to care RecursionLinear Search AlgorithmBinary Search AlgorithmNaive Search AlgorithmKMP AlgorithmBubble SortMerge SortQuick SortRadix SortBefore we begin I run a weekly Newsletter where I share epic content on web dev and programming Subscribe to build your skillset and become a better developer in minutes a week Understanding Big O NotationBig O Notation is a way to represent the time and space complexity of an algorithm Time Complexity Time taken by the algorithm to complete the execution Space Complexity The memory occupied by the algorithm There are few expressions notations which represents the time complexity of an algorithm O Constant time complexity This is the ideal case O log n Logarithmic time complexity If log n x then it is same as xO n Linear time complexity Time increases with the number of input in a linear manner For ex If one input takes ms inputs will take ms to execute the algo O n Exponential time complexity This mostly happens in case of nested loops O n Factorial time complexity This is the worst case senario which should be avoided You should try to write your algorithm such that it can be represented by the first notations And last two should be avoided as often as possible You want to keep your complexity as low and straight as possible ideally avoiding anything above O n In further sections of this article you will see examples of each notation For now this is all you need to know Algorithm What is algorithm and why to care The way to solve a problem or we can say the steps procedure or set of rules to solve a problem is known as Algorithm ex Search Engine algorithm to find out data related to a search string As a programmer you will come across many problems that needs to be solved with these algorithms So it s better if you already know them RecursionA function calling itself is recursion Think of it as an alternative to loop function recursiveFn console log This is a recursive function recursiveFn recursiveFn In the above snippet look at line recursiveFn is called in recursiveFn itself As I mentioned earlier recursion is an alternative to loop So how many times this function is exactly going to run Well this will create an infinite loop because there is nothing to stop it at any point Let s say we need to run the loop only times On the th iteration function should return That will stop the loop let count function recursiveFn console log Recursive count if count return count recursiveFn recursiveFn In the above snippet line returns and stops the loop at count Now let s see a more realistic example Our task is to return an array of odd numbers from a given array This can be achieved in a number of ways including for loop Array filter method e t cBut to showcase the use of recursion I will use a helperRecursive function function oddArray arr let result function helperRecursiveFn arr if arr length return else if arr result push arr helperRecursiveFn arr slice helperRecursiveFn arr return result oddArray OutPut gt Here the recursive function is helperRecursiveFn Return if the array length is Push the element to result array if the element is odd Call helperRecursiveFn with first element of array sliced Every time the first element of array will be sliced because we have already cheked it for odd or even For ex First time helperRecursiveFn will be called with Next time it will be called with and so on untill the array length is Linear Search AlgorithmLinear search algorithm is pretty simple Say that you need to find if a number exists in a given array or not You will run a simple for loop and check every element untill you find the one you are looking for const array Find in the given array function checkForN arr n for let i i lt array length i if n array i return true n exists at index i return false n does not exist in the given array checkForN array That s linear search algorithm You search for each element in the array one by one in a linear manner Time Complexity of Linear Search AlgorithmThere is only one for loop which will run n times Where n in worst case is the length of the given array Here number of iterations in worst case is directly propotional to the input array of length Hence the time complexity for linear search algorithm is Linear Time Complexity O n Binary Search AlgorithmIn linear search you can eliminate one element at a time But with binary search algorithm you can eliminate multiple elements at once That s why binary search is faster than linear search The point to be noted here is that binary search works only on sorted array This algorithm follows divide and conquer approach Let find the index of in Step Find the middleIndex of the array const array let firstIndex let lastIndex array length let middleIndex Math floor firstIndex lastIndex middleIndex gt Step Check if middleIndex element gt If so that means is on the left of middleIndex Hence change lastIndex to middleIndex Step Else if middleIndex element lt That means is on the right of middleIndex Hence change firstIndex to middleIndex if array middleIndex gt lastIndex middleIndex else firstIndex middleIndex Step With every iteration middleIndex is again set as per the new firstIndex or lastIndex Let s see all those steps together in code format function binarySearch array element let firstIndex let lastIndex array length let middleIndex Math floor firstIndex lastIndex while array middleIndex element amp amp firstIndex lt lastIndex if array middleIndex gt element lastIndex middleIndex else firstIndex middleIndex middleIndex Math floor firstIndex lastIndex return array middleIndex element middleIndex const array binarySearch array OutPut gt Here is visual representation of the above code Step firstIndex middleIndex Step lastIndex middleIndex Step array middleIndex Found It Time Complexity of Binary SearchThere is only one while loop which will run n times But here number of iterations does not depend on the input array length Hence the time complexity for binary search algorithm is Logarithmic Time Complexity O log n And you can check the O notation graph O log n is faster than O n Naive Search AlgorithmNaive search algorithm is used to find if a string contains a given substring For example check if helloworld contains the substring owo First loop on the main string helloworld Run a nested loop on the substring owo If character does not match then break inner loop else keep looping If inner loop is completed and got a match then return true else keep the outer loop going Here is a visual representation Here is the implementation in code function naiveSearch mainStr subStr if subStr length gt mainStr length return false for let i i lt mainStr length i for let j j lt subStr length j if mainStr i j subStr j break if j subStr length return true return false Now let s try to understand the code above At line return false if subString length is greater than mainString length At line start looping on mainString At line start nested loop on subString At line break inner loop if no match is found And move on to next iteration for outer loop At line return true at last iteration of inner loop Time Complexity of Naive SearchThere is a loop inside a loop Nested Loop Both loop run n times Hence time complexity for naive search algo is n n Exponential Time Complexity O n And as discussed at top any time complexity above O n should be avoided if possible We will see a better approach with less time complexity in next algo KMP AlgorithmKMP algo is a pattern recongnition algorithm and it is a bit tough to understand Ok let s try to find if the string abcabcabspl contains the sub string abcabs If we try to solve this with Naive Search Algo it will match for first characters but not for th character And we will have to start over again with next iteration we will lost all the progress in previous iteration So in order to save our progress and use it we must use something called LPS table Now in our matched string abcab we will find the longest same prefix and suffix Here in our string abcab ab is the longest same prefix and suffix Now we will begin the next search iteration from index for main string We saved two characters from our previous iteration In order to figure out the prefix suffix and where to start next iteration from we use LPS table LPS for our substring abcabs is Here is how to calculate LPS table function calculateLpsTable subStr let i let j let lps new Array subStr length fill while i lt subStr length if subStr i subStr j lps i j i i j else if j j lps j else i return lps Here is the implementation in code using LPS table function searchSubString string subString let strLength string length let subStrLength subString length const lps calculateLpsTable subString let i let j while i lt strLength if string i subString j i j else if j j lps j else i if j subStrLength return true return false Time Complexity of KMP AlgorithmThere is only one loop which run n times Hence time complexity for KMP algo is Linear Time Complexity O n Notice how time complexity is improved as compared to that of Naive search algo Bubble Sort AlgorithmSorting means rearranging data in ascending or descending order Bubble sort is one of many sorting algorithms In bubble sort algo we swap the larger number to the end by comparing each number with the previous number Here is a visual representation Bubble sort code implementation function bubbleSort array let isSwapped for let i array length i gt i isSwapped false for let j j lt i j if array j gt array j array j array j array j array j isSwapped true if isSwapped break return array Let s try to understand the above code Looping from end of array with variable i towards beginning Start inner loop with variable j until i If array j gt array j swap them return sorted array Time Complexity of Bubble Sort AlgorithmThere is a nested loop and both loop runs n times so time complexity for this algo is n n that is Exponential Time Complexity O n Merge Sort AlgorithmMerge sort algorithm follows divide and conquer approach It s a combination of two things merge and sort In this algo first we divide main array into multiple indivisual sorted arrays Then we merge the indivisual sorted elements together into final array Let s look at the implementation in code Merge Sorted Arrayfunction mergeSortedArray array array let result let i let j while i lt array length amp amp j lt array length if array i lt array j result push array i i else result push array j j while i lt array length result push array i i while j lt array length result push array j j return result The above code merges two sorted array into a new sorted array Merge Sort Algorithmfunction mergeSortedAlgo array if array length lt return array let midPoint Math floor array length let leftArray mergeSortedAlgo array slice midPoint let rightArray mergeSortedAlgo array slice midPoint return mergeSortedArray leftArray rightArray The above algo uses recursion to divide the array into multiple single element array Time Complexity of Merge Sort AlgorithmLet s try to calculate time complexity of merge sort algorithm So taking our previous example it took steps to divide it into multiple single element array It took steps to divide an array of length Now if we double the length of array it will take steps to divide Means doubling the array length didn t doubled the steps Hence time complexity of merge sort algorithm is Logarithmic Time Complexity O log n Quick Sort AlgorithmQuick sort is one of the fastest sorting algorithm In quick sort we select a single element known as pivot and we will move all element smaller than pivot to the left of pivot A visual representation We will repeat this process for array to left and right of pivot until the array is sorted Code implementationPivot Utilityfunction pivotUtility array start end array length let pivotIndex start let pivot array start for let i start i lt array length i if pivot gt array i pivotIndex array pivotIndex array i array i array pivotIndex array pivotIndex array start array start array pivotIndex return pivotIndex The above code identifies the correct position of pivot and returns that position index function quickSort array left right array length if left lt right let pivotIndex pivotUtility array left right quickSort array left pivotIndex quickSort array pivotIndex right return array The above code uses recursion to keep moving pivot to it s correct position for left and right array of pivot Time Complexity of Quick Sort AlgorithmBEST CASE Logarithmic Time Complexity O n log n AVERAGE CASE Logarithmic Time Complexity O n log n WORST CASE O n Radix Sort AlgorithmRadix sort is also know as Bucket sort algorithm Here first we build buckets of index from to Then we take last character in each number and push the number to the corresponding bucket Retrive the new order and repeat for the second last character of each number Keep repeating the above process till the array is sorted Implementation in code Count Digits The code below counts the number of digits the given element have function countDigits number if number return return Math floor Math log Math abs number Get Digit The code below gives the digit at index i from right function getDigit number index const stringNumber Math abs number toString const currentIndex stringNumber length index return stringNumber currentIndex parseInt stringNumber currentIndex MaxDigit The below snippet finds the number with maximum digits function maxDigit array let maxNumber for let i i lt array length i maxNumber Math max maxNumber countDigits array i return maxNumber The Radix Algo Utilises all the above snippets to sort the array function radixSort array let maxDigitCount maxDigits array for let i i lt maxDigitCount i let digitBucket Array from length gt for let j j lt array length j let lastDigit getDigit array j i digitBucket lastDigit push array j array concat digitBucket return array Time complexity of Radix Sort AlgorithmThere is a nested for loop and we know that time complexity for a nested for loop is O n But in this case both for loop does not run n times The outer loop runs k maxDigitCount times and inner loop runs m length of array times Hence time complexity of Radix Sort is O k x m where k x m n Linear time complexity O n Allright with that we are at the end of this post It is OK if some algos didn t clicked instantly go through them multiple times That s how I understood them Also I run a weekly Newsletter where I share epic content on web dev and programming Subscribe to build your skillset Thanks for reading 2021-11-30 06:50:12
海外TECH DEV Community Building a Task Management Application using Rest API, Spring Boot, Maven and Fauna https://dev.to/aidelojep/building-a-task-management-application-using-rest-api-spring-boot-maven-and-fauna-9b0 Building a Task Management Application using Rest API Spring Boot Maven and FaunaWritten in connection with the Write with Fauna Program This article focuses on the tutorial steps in building a Rest API using the Java Programming framework Spring Boot Maven and Fauna We used Fauna as our database to save our information and integrated this into our Spring Boot project We also outlined these steps to make it easy for beginners to follow through and implement the same using these steps when working on a similar project The Rest API is more suitable for server side API rendering Hence the REST API is a valuable architectural style for microservices because of its simplicity scalability and flexibility In microservice architecture each application is designed as an independent service from the other We recall that microservices rely on small teams to deploy and scale their respective services independently this makes the REST API an invaluable resource to this architectural style PrerequisitesTo fully understand this part of the tutorial you are required to have the following Fundamental knowledge of how to program with Java At least fundamental knowledge of Spring Framework and Spring Boot Java Development Kit JDK installed Postman installed or click on the link to download and install Maven installed or click on the link to download and install IntelliJ installed or click on the link to install You can use any other IDEA of choice What is an API In the simplest form an API is the acronym for application programming interface that allows for two or more different applications to talk to each other Everytime you make use of these applications the applications on your phone gadgets or computer connect to the internet and send data to the server This data retrieved by the server is then interpreted and some actions are performed and a feedback is sent back to you in a human or readable format The API also provides a level of security here since each communication entails a small packet of data the data sharing here only entails that which is necessary Another additional benefit of RESTful APIs is its Client Server constraints This constraint operates on the concept that the client and server side should be separated from each other This is referred to as separation of concerns which guarantees more efficiency in our application Therefore I should be able to make changes on my client side without affecting my database design on the server and vice versa This makes our application to be loosely coupled and easily scalable This article teaches how to create a SpringBoot and Restful API that performs CRUD Create Read Update and Delete operations by making a database call to a Fauna The application we will be building in this tutorial is a “task management app for users to manage all their daily tasks Key TakeawaysHow to create and set up a Spring Boot application with a Tomcat Server Fauna database configuration in a Spring Boot Project Maven for Dependency management Exception Handling in Java How to document API using Swagger Project SetupTo initialize the project we are going to use spring initializer Enter the maven project properties of the project including the dependencies as shown below and click on the generate button This will generate a zip file and download it for you Unzip it and open it in your favorite IDEA and sync the dependencies with Maven For this project we are going to add two dependencies namely Spring web This dependency makes your project a web application The spring boot starter web dependency transitively pulls in all dependencies related to Web development using Spring MVC REST and Tomcat as a default embedded server Spring Data JPA This allows us to persist data in SQL databases using Spring Data and Hibernate which is an implementation of the JPA JPA stands for Java Persistent API it i s a specification that is part of Java EE Enterprise Edition and defines an API for Object Relational Mappings ORM and for managing persistent objects and Relational Databases It is considered a standard approach for Object Relational Mapping Being that JPA is a specification it does not perform any operation by itself as such requires implementation Hibernate is one of those ORM Object Relational Mapping tools that implements JPA Others include TopLink MyBatis The EntryPoint of the ApplicationThe beauty of SpringBoot lies in how easy it is to create stand alone production grade spring based applications that you can just run If you open your TaskManagerApplication java file package com taskVentures taskmanager import org springframework beans factory config ConfigurableBeanFactory import org springframework boot SpringApplication import org springframework boot autoconfigure SpringBootApplication import org springframework context annotation Bean import org springframework context annotation Scope SpringBootApplicationpublic class TaskmanagerApplication public static void main String args SpringApplication run TaskmanagerApplication class args SpringBoot applications should have an entry point class with the public static void main String args methods which is annotated with the SpringBootApplication annotation and will be used to bootstrap the application It is the main method which is the entry point of the JVM to run our application The SpringBootApplication annotation informs the Spring framework when launched to scan for Spring components inside this package and register them It also tells Spring Boot to enable Autoconfiguration a process where beans are automatically created based on classpath settings property settings and other factors The SpringBootApplication annotation has composed functionality from three annotations namely EnableAutoConfiguration ComponentScan and Configuration So we can say it is the shortcut for the three annotations Now we can now run our application We can do this by either clicking on the play button on our IDEA or running this command mvn spring boot run on our command line Navigate to the root of the project via the command line and execute the command Boom Tomcat started on port which is the port we configured our application to run Maven as a dependency management tool The pom xml file houses the dependencies Maven plugins in our project The dependency section simply contains the dependencies we added to our project namely SpringWeb and springfox for documenting our api lt xml version encoding UTF gt lt project xmlns xmlns xsi xsi schemaLocation gt lt modelVersion gt lt modelVersion gt lt parent gt lt groupId gt org springframework boot lt groupId gt lt artifactId gt spring boot starter parent lt artifactId gt lt version gt lt version gt lt relativePath gt lt lookup parent from repository gt lt parent gt lt groupId gt com taskVentures lt groupId gt lt artifactId gt taskmanager lt artifactId gt lt version gt SNAPSHOT lt version gt lt name gt taskmanager lt name gt lt description gt A web application that individual to manage their daily task lt description gt lt properties gt lt java version gt lt java version gt lt properties gt lt dependencies gt lt dependency gt lt groupId gt io springfox lt groupId gt lt artifactId gt springfox boot starter lt artifactId gt lt version gt lt version gt lt dependency gt lt dependency gt lt groupId gt org springframework boot lt groupId gt lt artifactId gt spring boot starter web lt artifactId gt lt dependency gt lt dependency gt lt groupId gt org springframework boot lt groupId gt lt artifactId gt spring boot starter test lt artifactId gt lt scope gt test lt scope gt lt dependency gt lt dependencies gt lt build gt lt plugins gt lt plugin gt lt groupId gt org springframework boot lt groupId gt lt artifactId gt spring boot maven plugin lt artifactId gt lt plugin gt lt plugins gt lt build gt lt project gt Adding Additional Maven DependenciesIn this section we are going to add additional deficiencies to the project To do this we navigate to Maven Repository and search for the Fauna dependency and add it to the dependencies section of the pom xml file Faunadb A Fauna cloud database dependencies that connect our Java application to Fuana serverless database Lombok A lombok dependency helps us to reduce boiler plate codes Sync the newly added dependencies to the application The modified pom xml should like this lt newly added dependencies gt lt dependency gt lt groupId gt com faunadb lt groupId gt lt artifactId gt faunadb java lt artifactId gt lt version gt lt version gt lt dependency gt lt dependency gt lt groupId gt org projectlombok lt groupId gt lt artifactId gt lombok lt artifactId gt lt version gt lt version gt lt scope gt provided lt scope gt lt dependency gt Next we can now proceed to create a database on the Fauna dashboard and generate a server key and configure FaunaClient in the Spring Boot project To create a database and server key for our SpringBoot project we are going to register a Fauna account To do this click on this link sign up today and ignore if you have one already After signup you get a prompt to create a database like the image below Here we named our database as taskmanager db In naming your database always ensure to use a name that is descriptive Next we are going to generate our Fauna secret key Creating a Fauna API KeyTo create a Fauna API Key you would go to your settings on the Fauna sidebar at the top left of the screen This Fauna API key is required to connect the database to our Task Management App The secret keys generated from Fauna are meant to be copied and stored somewhere safe that can be easily retrieved Configuring Fauna ClientIn the resources folder within the src main folder open application properties file and add the secret key that you have generated fauna db secret your api secret key should be here Next we need to create a bean creates a single instance of the configuration with the help of the Scope annotation and inject our api key using the value annotation Value fauna db secret private String serverKey Bean Scope value ConfigurableBeanFactory SCOPE SINGLETON public FaunaClient faunaConfiguration FaunaClient faunaClient FaunaClient builder withSecret serverKey build return faunaClient Project StructureOur project will be structured into four subpackages Data This subpackage will house our Data access layer which will include our Domain and repository Service This is where our business logic will be Web This package will house our controllers Exceptions This is where all our custom exceptions will be Throwing exceptions is very important in building a resilient system This structure will ensure that when a client makes a call to access a resource in the application such client does not have direct access to our database rather a request is directed to our controller Our controller calls the right service the business logic which then through our repository makes a call to our database This architecture also ensures the separation of concerns Creating The Domain ClassIn the data package create another package called models Inside the models package create a class called Task with the following code package com taskVentures taskmanager data models import com faunadb client types FaunaConstructor import com faunadb client types FaunaField import lombok Data import lombok NoArgsConstructor Data NoArgsConstructorpublic class Task private String id FaunaField private String name FaunaField private String description FaunaField private boolean isCompleted FaunaConstructor public Task FaunaField id String id FaunaField name String name FaunaField description String description FaunaField isCompleted boolean isCompleted this id id this name name this description description this isCompleted isCompleted FaunaField annotation Makes the instance variable annotated as database columnWe have used the FaunaConstructor annotation to specify our create constructor and give our files values on creation Data creates setters and getters for the class NoArgsConstructor annotation creates a no argument constructor AllArgsContructor creates an all argument constructor PayloadsInside the data package create a package with the name payloads This package will have two sub packages “request and “response to handle our request payloads and response payloads respectively Request payloadsInside the request package create an EmployeeRequest class with the following code package com taskVentures taskmanager data payloads requests import lombok Data import java time LocalDateTime Datapublic class TaskRequest NotNull NotBlank private String name NotNull NotBlank private String description private boolean isCompleted NotBlank and notnull These two annotation checks and validate the fields where they are mapped to ensure the values are not blank and null respectively Response payloadInside the response package create a TaskResponse class with the following code package com taskVentures taskmanager data payloads response import lombok AllArgsConstructor import lombok Data Data AllArgsConstructorpublic class TaskResponse private String message The above code is simply a POJO Plain Old Java Object with one instance variable a constructor a mutator setters and an accessor getters The RepositoryInside the data package create a sub package called a repository Then create an interface called “TaskRepository that extends JpaRepository The JpaRepository is generic so it takes a model class Type and the data type of the primary key Write the following code in the TaskRepository interface package com taskVentures taskmanager data repository import com taskVentures taskmanager data models Task import org springframework stereotype Repository import java util List import java util concurrent CompletableFuture Repositorypublic class TaskRepository extends FaunaRepository lt Task gt public TaskRepository super Task class todos tasks Override public CompletableFuture lt List lt Task gt gt findAll return null Repository makes the interface a bean It is treated identically to the Component annotation therefore it is a specialization of the Component annotation Beans are simply Java classes that spring knows Next let s create a class called FaunaRepository that will contain methods that will allow us to perform the CRUD Operation We are going to first create an interface that will contain these methods Let s call the interface Repository package com taskVentures taskmanager data repository import com taskVentures taskmanager data models Task import java util List import java util Optional import java util concurrent CompletableFuture public interface Repository lt T extends Task gt CompletableFuture lt T gt save T entity CompletableFuture lt Optional lt T gt gt find String id CompletableFuture lt Optional lt T gt gt remove String id We have defined an interface with methods that allow us to save find and update a task package com taskVentures taskmanager data repository import com faunadb client FaunaClient import com faunadb client errors NotFoundException import com faunadb client query Expr import com faunadb client query Language import com faunadb client types Value import com taskVentures taskmanager data models Task import org springframework beans factory annotation Autowired import java util Optional import java util concurrent CompletableFuture import java util function Function import static com faunadb client query Language import java lang Class public abstract class FaunaRepository lt T extends Task gt implements Repository lt T gt IdentityFactory Autowired protected FaunaClient faunaClient protected final Class lt T gt entityType protected final String collectionName protected final String collectionIndexName protected FaunaRepository Class lt T gt entityType String collectionName String collectionIndexName this entityType entityType this collectionName collectionName this collectionIndexName collectionIndexName Override public CompletableFuture lt String gt nextId CompletableFuture lt String gt result faunaClient query NewId thenApply value gt value to String class get return result Override public CompletableFuture lt T gt save T entity CompletableFuture lt T gt result faunaClient query saveQuery Language Value entity getId Value entity thenApply this toEntity return result Override public CompletableFuture lt Optional lt T gt gt remove String id CompletableFuture lt T gt result faunaClient query Select Value data Delete Ref Collection collectionName Value id thenApply this toEntity CompletableFuture lt Optional lt T gt gt optionalResult toOptionalResult result return optionalResult Override public CompletableFuture lt Optional lt T gt gt find String id CompletableFuture lt T gt result faunaClient query Select Value data Get Ref Collection collectionName Value id thenApply this toEntity CompletableFuture lt Optional lt T gt gt optionalResult toOptionalResult result return optionalResult protected Expr saveQuery Expr id Expr data Expr query Select Value data If Exists Ref Collection collectionName id Replace Ref Collection collectionName id Obj data data Create Ref Collection collectionName id Obj data data return query protected T toEntity Value value return value to entityType get protected CompletableFuture lt Optional lt T gt gt toOptionalResult CompletableFuture lt T gt result CompletableFuture lt Optional lt T gt gt optionalResult result handle v t gt CompletableFuture lt Optional lt T gt gt r new CompletableFuture lt gt if v null r complete Optional of v else if t null amp amp t getCause instanceof NotFoundException r complete Optional empty else r completeExceptionally t return r thenCompose Function identity return optionalResult The above class provides an implementation to the methods defined on the interface You can look up the Fauna documentation for Java by clicking on this link Fauna JVM docpackage com taskVentures taskmanager data repository import java util concurrent CompletableFuture public interface IdentityFactory CompletableFuture lt String gt nextId The TaskServiceCreate a service package under the taskmanager directory This package is going to house the business logic We have divided the service into two an interface where the methods of our business logic will be declared and a concrete class that implements the interface Create an interface with the name “taskService with the following code package com taskVentures taskmanager services import com taskVentures taskmanager data models Task import com taskVentures taskmanager data payloads requests TaskRequest import java util Optional import java util concurrent CompletableFuture componentpublic interface TaskService CompletableFuture lt Task gt createTask TaskRequest taskRequest CompletableFuture lt Optional lt Task gt gt updateTask String id TaskRequest taskRequest CompletableFuture lt Optional lt Task gt gt deleteTask String id CompletableFuture lt Optional lt Task gt gt getTask String id Component annotation is a shorthand for the Bean annotation It registers the TaskService interface as a bean in the application context and makes it accessible during classpath scanning We created five methods that allow us to create update get and delete tasks Next create a TaskServiceImpl class that implements the TaskService interface Write the following code package com taskVentures taskmanager services import com taskVentures taskmanager data models Task import com taskVentures taskmanager data payloads requests TaskRequest import com taskVentures taskmanager data repository TaskRepository import lombok AllArgsConstructor import org springframework stereotype Service import java util Optional import java util concurrent CompletableFuture Service AllArgsConstructorpublic class TaskServiceImpl implements TaskService private final TaskRepository taskRepository Override public CompletableFuture lt Task gt createTask TaskRequest taskRequest CompletableFuture lt Task gt newTask taskRepository nextId thenApply id gt new Task id taskRequest getName taskRequest getDescription taskRequest isCompleted thenCompose taskRepository save return newTask Override public CompletableFuture lt Optional lt Task gt gt getTask String id return taskRepository find id Override public CompletableFuture lt Optional lt Task gt gt updateTask String id TaskRequest taskRequest CompletableFuture lt Optional lt Task gt gt result taskRepository find id thenCompose optionalTodoEntity gt optionalTodoEntity map todoEntity gt taskRepository save new Task id taskRequest getName taskRequest getDescription taskRequest isCompleted thenApply Optional of orElseGet gt CompletableFuture completedFuture Optional empty return result Override public CompletableFuture lt Optional lt Task gt gt deleteTask String id return taskRepository remove id Service annotation is a specialized form of Component With the Service annotation the class that is annotated is registered in the application context and accessible during classpath scanning The TaskServiceImpl class implemented the TaskService interface by overriding the method and implementing them The class throws an exception ResourceNotFoundException This is the custom exception class we created that extends RunTimeException where the Id supplied to get a single task does not exist on the database The ControllerCreate a package called web under the taskmanager package This package is going to house the APIs controller Create an TaskController class with the following code package com taskVentures taskmanager web import com taskVentures taskmanager data payloads requests TaskRequest import com taskVentures taskmanager services TaskService import io swagger annotations ApiResponses import lombok AllArgsConstructor import org springframework http HttpStatus import org springframework http ResponseEntity import org springframework web bind annotation import java util concurrent CompletableFuture RestController RequestMapping task AllArgsConstructor ApiResponses value io swagger annotations ApiResponse code message This is a bad request please follow the API documentation for the proper request format io swagger annotations ApiResponse code message Due to security constraints your access request cannot be authorized io swagger annotations ApiResponse code message The server is down Please bear with us public class TaskController TaskService taskService PostMapping create public CompletableFuture lt gt createTask RequestBody TaskRequest taskRequest return taskService createTask taskRequest thenApply todoEntity gt new ResponseEntity lt gt todoEntity HttpStatus CREATED GetMapping get id public CompletableFuture lt gt getTask PathVariable id String id CompletableFuture lt ResponseEntity gt result taskService getTask id thenApply optionalTodoEntity gt optionalTodoEntity map todoEntity gt new ResponseEntity lt gt todoEntity HttpStatus OK orElseGet gt new ResponseEntity lt gt HttpStatus NOT FOUND return result PutMapping update id public CompletableFuture lt gt updateTask PathVariable id String id RequestBody TaskRequest taskRequest CompletableFuture lt ResponseEntity gt result taskService updateTask id taskRequest thenApply optionalTodoEntity gt optionalTodoEntity map todoEntity gt new ResponseEntity lt gt todoEntity HttpStatus OK orElseGet gt new ResponseEntity lt gt HttpStatus NOT FOUND return result DeleteMapping value delete id public CompletableFuture lt gt deleteTask PathVariable id String id CompletableFuture lt ResponseEntity gt result taskService deleteTask id thenApply optionalTodoEntity gt optionalTodoEntity map todo gt new ResponseEntity lt gt todo HttpStatus OK orElseGet gt new ResponseEntity lt gt HttpStatus NOT FOUND return result RestController This annotation marks the EmployeeController as an HTTP request handler and allows Spring to recognize it as a RESTful service RequestMapping task annotation sets the base path to the resource endpoints in the controller as task Next we injected the TaskService class GetMapping is a shortcut for RequestMapping method RequestMethod GET and is used to map HTTP GET requests to the mapped controller methods We used it to return all the tasks and a single task PathVariable annotation shows that a method parameter should be bound to a URI template variable PostMapping is a shorthand for RequestMapping where the method is equal to POST It is used to map HTTP POST requests to the mapped controller methods RequestBody This annotation takes care of binding the web request body to the method parameter with the help of the registered HttpMessageConverters So when you make a POST request to the “ task add URL with a Post JSON body the HttpMessageConverters converts the JSON request body into a Post object and passes it to the createTask method PutMapping is a shorthand for RequestMapping where the method is equal to PUT It is used to map HTTP PUT requests to the mapped controller methods DeleteMapping Using this annotation makes the Mapped controller method to be ready for a delete operation is a shortcut for RequestMapping method RequestMethod DELETE Documenting your API with SwaggerWe already added the io springfox dependency to the pom xml With this dependency we will document the API so that it will be easy for other developers to use it All is required is to add the following line of code at the class level of our controller as follows ApiResponses value io swagger annotations ApiResponse code message This is a bad request please follow the API documentation for the proper request format io swagger annotations ApiResponse code message Due to security constraints your access request cannot be authorized io swagger annotations ApiResponse code message The server is down Please bear with us We added the ApiResponse annotation from swagger at the class level As simple as this our APIs are fully documented Go localhost swagger ui to access the documentation and test that our APIs are still working properly Use the Swagger API document at localhost swagger ui to add an employee get update and delete an employee ConclusionIn this article project we successfully built a Task Management Application using SpringBoot framework and Maven as our dependency management and build tools We used Fauna as our Cloud datastore Additionally we learned how to throw exceptions in our application which ensures that our application is fault tolerant and resilient We also learned how to document our API using Swagger You can clone the project from my GitHub via this link Task Management SpringBoot ProjectIf you have any questions don t hesitate to contact me via any of my socials Peter Aideloje LinkedInPeter Aideloje Twitter 2021-11-30 06:48:06
海外TECH DEV Community NextJS For beginners https://dev.to/hardeepcoder/nextjs-for-beginners-569a NextJS For beginners nextjs tutorial for beginnerscheck and give me feedback 2021-11-30 06:43:32
海外TECH DEV Community Kotlin filter List example https://dev.to/harrynguyen88/kotlin-filter-list-example-23g3 Kotlin filter List exampleIn the tutorial Grokonez will show you how to work with Kotlin List filter methods Read more 2021-11-30 06:24:06
海外TECH DEV Community Publishing yassgy to crates.io https://dev.to/jerryhue/publishing-yassgy-to-cratesio-14od Publishing yassgy to crates ioThis time I would like to talk about publishing yassgy to crates io and the process I went through in the case there is a fellow developer who is going to publish their application Publishing a crate what is a registry If it is the first time you hear about the word a registry is as it name entails a list of entries used for referential purposes This might be too of a general answer so let me narrow it to the topic at hand a registry like crates io is a list of packages which you can refer to download packages from which can include binary crates regular applications or a library crate Setting up the package for publishingPublishing a package with cargo is very easy and it requires very minimal configuration Although the cargo book goes in a very thorough explanation about every little detail about cargo you might not be interested on all the details when starting out Thus I would like to explain what I had to do Most of the changes would be done in Cargo toml generated when creating a project using cargo new There are several values that you might need to add to your Cargo toml some of them are the license your program uses in my case I wrote the MIT license a small description of the package and a URL to the repository of the package Other files you might want to reference is the exclude list of values where each value is a pattern to a file to not include during packaging In my case I included the following values testfiles tests vscode rustfmt toml git This can decrease the total size of the package that will be uploaded to crates io After that you may check whether there are no issues before actual publishing by running the command cargo publish dry runand you can also check what files are being included in the package by running the command cargo package list Making a release on GitHub through tagsAfter making sure that the packaging was fine I decided to make a GitHub release by tagging the latest commit available in the master branch I ran the following command git tag a v m Initial release to create the tag on the master branch and then I pushed the tags withgit push follow tagsThen I created a new GitHub release with the v tag Finally I published my package to crates io with the following command cargo publishYou can view the crates io page here InstallationTo install yassgy you would need Rust and cargo since cargo downloads the source code which then gets compiled in the computer of the user The command to install yassgy is the following cargo install yassgyIt doesn t get simpler than that ConclusionsReleasing yassgy was an interesting experience since this is the first time I have openly released software to the world intentionally I have to admit that I am not fully satisfied with the capabilities of yassgy but I am sure that I will be able to upgrade yassgy and improve it to the full view I have for it 2021-11-30 06:02:23
医療系 医療介護 CBnews オミクロン株発生踏まえサーベイランス体制強化を-厚労省が都道府県などに事務連絡 https://www.cbnews.jp/news/entry/20211129122323 厚生労働省 2021-11-30 16:00:00
医療系 医療介護 CBnews グループ薬局の調剤基本料、店舗数・立地別損益踏まえて-中医協、厚労省論点を各側が支持 https://www.cbnews.jp/news/entry/20211130145520 中央社会保険医療協議会 2021-11-30 15:25:00
金融 JPX マーケットニュース [東証]制限値幅の拡大:1銘柄 https://www.jpx.co.jp/news/1030/20211130-01.html 東証 2021-11-30 15:15:00
金融 JPX マーケットニュース [OSE]特別清算数値(2021年11月限):FTSE中国50 https://www.jpx.co.jp/markets/derivatives/special-quotation/ 特別清算 2021-11-30 15:15:00
金融 ニッセイ基礎研究所 顕在化する米インフレリスク-消費者物価は31年ぶりの水準に上昇。インフレは来年以降の低下予想も、長期間高止まりする可能性 https://www.nli-research.co.jp/topics_detail1/id=69499?site=nli 目次はじめに米国のインフレリスクが顕在化・CPI、PCE価格指数総合指数は前年同月比で年ぶりの水準・物価上昇要因財需要の増加と財価格上昇・物価上昇要因原材料価格、物流コストの増加・上昇要因サプライチェーンの混乱に伴う供給制約今後のインフレ見通し・今後のインフレ見通し年にかけてインフレ率の低下を予想・今後の注目ポイント労働供給の回復と賃金上昇・今後の注目ポイント家賃の持続的な上昇米国では月の消費者物価指数CPIが前年同月比となったほか、個人消費支出PCE価格指数もと、いずれも年以来年ぶりの水準となるなど、インフレリスクが顕在化している。 2021-11-30 15:16:03
ニュース ジェトロ ビジネスニュース(通商弘報) 政府が新型コロナ経口治療薬モルヌピラビルの購入契約締結を公表 https://www.jetro.go.jp/biznews/2021/11/3fecc64d911ff1ba.html 契約締結 2021-11-30 06:30:00
ニュース ジェトロ ビジネスニュース(通商弘報) 南部アフリカ8カ国からの入国を実質的に禁止 https://www.jetro.go.jp/biznews/2021/11/88f10749e618c12c.html 実質的 2021-11-30 06:20:00
海外ニュース Japan Times latest articles Japan confirms first case of omicron coronavirus variant https://www.japantimes.co.jp/news/2021/11/30/national/japan-omicron-case/ Japan confirms first case of omicron coronavirus variantA Namibian diplomat in his s has been found to be infected with the heavily mutated variant after he tested positive for the coronavirus at 2021-11-30 15:46:43
海外ニュース Japan Times latest articles Japanese crown prince made decision to forgo daughter’s marriage rites https://www.japantimes.co.jp/news/2021/11/30/national/crown-prince-mako/ akishino 2021-11-30 15:21:17
海外ニュース Japan Times latest articles Kishida showcases swiftness amid omicron variant scare https://www.japantimes.co.jp/news/2021/11/30/national/politics-diplomacy/kishida-quick-reactions/ Kishida showcases swiftness amid omicron variant scareThe prime minister s prompt decision making reflects lessons learned from his predecessor Yoshihide Suga who was criticized for being slow to respond to COVID 2021-11-30 15:16:30
ニュース BBC News - Home Covid: Face masks rules return in England amid Omicron spread https://www.bbc.co.uk/news/uk-59470344?at_medium=RSS&at_campaign=KARANGA omicron 2021-11-30 06:49:37
ニュース BBC News - Home Barbados becomes a republic and parts ways with the Queen https://www.bbc.co.uk/news/world-latin-america-59470843?at_medium=RSS&at_campaign=KARANGA rihanna 2021-11-30 06:05:46
北海道 北海道新聞 道内8人感染 3日連続1桁 新型コロナ https://www.hokkaido-np.co.jp/article/617308/ 新型コロナウイルス 2021-11-30 15:15:29
マーケティング MarkeZine コーセー、新作アイパレットの色味や質感をTikTokで体験できるブランドエフェクトを開発 http://markezine.jp/article/detail/37864 tiktok 2021-11-30 15:30:00
IT 週刊アスキー カイロソフトのSLG『冒険ダンジョン村2』が「Google Play ベスト オブ 2021」インディー部門<部門賞>を受賞! https://weekly.ascii.jp/elem/000/004/076/4076643/ googleplay 2021-11-30 15:50:00
IT 週刊アスキー 港北区の11商店街が参加! デジタルスタンプラリー「こうほくの商店街 ちょいより散歩」12月1日から https://weekly.ascii.jp/elem/000/004/076/4076642/ 二次元コード 2021-11-30 15:30:00
マーケティング AdverTimes 4月から18歳成人、当事者と保護者への意識調査 https://www.advertimes.com/20211130/article369996/ 引き下げ 2021-11-30 06:27:19
マーケティング AdverTimes 2021年CM出稿量1位は斎藤工さんに Indeedの積極攻勢で https://www.advertimes.com/20211130/article370102/ indeed 2021-11-30 06:09:10
マーケティング AdverTimes 足利銀行、栃木の地酒販路開拓支援 https://www.advertimes.com/20211130/article370036/ 販路開拓 2021-11-30 06:00:59

コメント

このブログの人気の投稿

投稿時間:2021-06-17 22:08:45 RSSフィード2021-06-17 22:00 分まとめ(2089件)

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

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