投稿時間:2021-05-09 21:33:04 RSSフィード2021-05-09 21:00 分まとめ(32件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
IT MOONGIFT twemoji-image-picker - twemojiをmacOSの絵文字ピッカー風に選択 http://feedproxy.google.com/~r/moongift/~3/cXONtP3puv4/ twemojiimagepickertwemojiをmacOSの絵文字ピッカー風に選択絵文字は色々な場面で使われます。 2021-05-09 21:00:00
python Pythonタグが付けられた新着投稿 - Qiita ROSでの通信遅延時間検証 その① https://qiita.com/moominparis/items/79ccd5b96548e958e837 送信レートと通信遅延時間の検証ターミナルの表示結果をscriptでログをとって解析しても良いのですが、ROSの機能でこの結果は自動的にログとして残っています。 2021-05-09 20:25:30
python Pythonタグが付けられた新着投稿 - Qiita 【個人開発】化合物の物性予測サービスをリリースした話 https://qiita.com/kimisyo/items/65a66b71df0b6b5209bd Herokuの無料プランではレコード数の制限があるため、ユーザの入力データや、予測結果は、時ファイルやメモリ上で処理することとし、データベースに一切保存しないようにした。 2021-05-09 20:05:43
python Pythonタグが付けられた新着投稿 - Qiita gRPC Pythonのコード生成で、相対参照に近い意図したパッケージとして生成する https://qiita.com/74th/items/cc5fcfb9e30d5a24c148 protogisapppbgrpcpyimportgrpcfromprotoimportgisapppbasprotodotgisapppb解説パッケージ構成は、Iで指定したフォルダから、定義ファイルgisappprotoまでのディレクトリ構成になります。 2021-05-09 20:05:31
js JavaScriptタグが付けられた新着投稿 - Qiita 【Vue.js 勉強メモ】v-forを使う時の注意点 key属性 https://qiita.com/yuta-katayama-23/items/ea5df45d93d2bed8b42c vforを使う時の注意点key属性vforディレクティブを使う際には、key属性を付与する事で予期せぬバグが発生しないように注する必要がある。 2021-05-09 20:01:32
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) Javascript(vue.js)で、配列のデータを指定して取り出したい https://teratail.com/questions/337410?rss=all 該当のソースコードresimagespositionが最小値のimagepathを取得したいです。 2021-05-09 20:59:39
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) vscodeのcodeコマンドはどこに記述されてますか? https://teratail.com/questions/337409?rss=all vscodeのcodeコマンドはどこに記述されてますかvscodeをターミナルから起動できるようにnbspここnbspの通りに設定しましたコマンドパレットnbspgtnbspShellnbspCommandnbspInstallnbspaposcodeaposnbspcommandnbspinnbspPATHターミナルでcodeコマンドを使えるようになったのですが、これはどのファイルに書かれているのでしょうかホームディレクトリのzshrc、etczshrc、etczprofilenbspを見ましたが確認できませんでした。 2021-05-09 20:45:25
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) 稼働中の実機CentOS7をHyper-VのGuestOSにする方法 https://teratail.com/questions/337408?rss=all 稼働中の実機CentOSをHyperVのGuestOSにする方法実現したいこと現在稼働中の社内向け実機サーバーCentOSがあり、リプレイスをする予定になっています。 2021-05-09 20:40:12
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) rust-libp2pのexampleのpingを模写して実行するとcargoが壊れる https://teratail.com/questions/337407?rss=all rustlibppのexampleのpingを模写して実行するとcargoが壊れる新規プロジェクトにexamplenbsppingのコードをコピーし、Cargotomlを以下のようにして実行したところ、プログラムが途中で強制終了しerrornbspthenbspaposcargoexeaposnbspbinarynbspnormallynbspprovidednbspbynbspthenbspaposcargoaposnbspcomponentnbspisnbspnotnbspapplicablenbsptonbspthenbspaposstablexpcwindowsmsvcaposnbsptoolchainというエラーがでるようになってしまいました。 2021-05-09 20:25:57
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) matlabの回帰分析でグラフを作成したい https://teratail.com/questions/337406?rss=all matlabの回帰分析でグラフを作成したいMATLABによる回帰分析についての質問です。 2021-05-09 20:19:45
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) Ruby FizzBuzz問題 文字列も数値で返ってくる https://teratail.com/questions/337405?rss=all RubyFizzBuzz問題文字列も数値で返ってくる前提・実現したいことFizzBuzzで、aで割り切れる→Fizzbで割り切れる→Buzzcでもでも割り切れる→FizzBuzzdそれ以外の数値→数値をそのまま返すe数値以外の入力→エラーメッセージこのようなプログラムを組みたいです。 2021-05-09 20:18:40
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) packageやimportの記載が上手くいかずNoClassDefFoundErrorが発生 https://teratail.com/questions/337404?rss=all packageやimportの記載が上手くいかずNoClassDefFoundErrorが発生java初心者です。 2021-05-09 20:16:09
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) heroku createがうまく動作しない https://teratail.com/questions/337403?rss=all herokucreateがうまく動作しない前提・実現したいことHerokunbspCLIを使ってWebアプリを公開したいと考えています。 2021-05-09 20:13:39
Ruby Rubyタグが付けられた新着投稿 - Qiita 初学者向けエラーとの戦い方 https://qiita.com/tochisuke221/items/f4016f48c4a47115d83e ちなみに科学的根拠は全然知りませんが、効果は抜群です笑技術編技術については、私もプロではないゆえ、偉そうなことは言えませんが私なりの考えをまとめていきますまず、エラー原因は全てログの中に答えがあるということです。 2021-05-09 20:33:10
Ruby Rubyタグが付けられた新着投稿 - Qiita [Ruby]Class毎のよく使う操作をまとめたので見てくれ!! https://qiita.com/ren0826jam/items/24d28839d307ffa825fc RubyClass毎のよく使う操作をまとめたので見てくれClass一覧Numeric数値クラスInteger等のトップクラスです。 2021-05-09 20:06:31
AWS AWSタグが付けられた新着投稿 - Qiita 【AWS】通信プロトコルについて https://qiita.com/mzmz__02/items/2ed8926b99167fa5bef2 層名称規格プロトコル概要利用例層アプリケーション層HTTPFTPDNSSMTPPOPなど個々のアプリケーションwwwメール層プレゼンテーション層SMTPFTPTelnetなどデータの表現形式HTML層セッション層TLSNetBIOSなど通信手段HTTPS層トランスポート層TCPUDPNetWareIPなどエンド間の通信制御TCPUDP層ネットワーク層IPARPRARPICMPなどデータを送る相手を決め最適な経路で送信IP層データリンク層PPPEthernetなど隣接する機器同士の通信を実現Ethernet層物理層RSUTP無線物理的な接続、電気信号UTPケーブル光ファイバーケーブルアプリケーション層Webアプリケーションなどの通信サービスの通信方法を規定する。 2021-05-09 20:50:05
Docker dockerタグが付けられた新着投稿 - Qiita Docker環境でmysqlを二つ立ち上げる方法 https://qiita.com/_miyagi_/items/f36fcf9ea4ce07a8e203 Docker環境でmysqlを二つ立ち上げる方法テスト環境と本番環境でDBを分けたいときがありますそんな時にDockerでDBを二つ立ち上げる方法について記載しますDockerfileまずは結論versionservicesappbuildyourappdockerfiledependsonmysqltestmysqlcommandexecutecommandportsmysqlbuildyourmysqlimagepathenvironmentMYSQLDATABASEyourdbMYSQLUSERuserMYSQLPASSWORDpasswordMYSQLROOTPASSWORDpasswordportsvolumesmysqldatavarlibmysqlcachedphpmyadminimagephpmyadminphpmyadminenvironmentPMAARBITRARYPMAHOSTmysqlPMAUSERuserPMAPASSWORDpassworddependsonmysqllinksmysqlportsvolumessessionstoolsphpMyAdminphpiniusrlocaletcphpphpinitestmysqlbuildyourtestmysqlimagepathenvironmentMYSQLDATABASEyourtestdbMYSQLUSERuserMYSQLPASSWORDpasswordMYSQLROOTPASSWORDpasswordportsvolumestestmysqldatavarlibmysqlcachedtestphpmyadminimagephpmyadminphpmyadminenvironmentPMAARBITRARYPMAHOSTtestmysqlPMAUSERuserPMAPASSWORDpassworddependsontestmysqllinkstestmysqlportsvolumessessionstoolsphpMyAdminphpiniusrlocaletcphpphpinivolumesmysqldatatestmysqldata実行方法注意点すでにある環境が立ち上げ済みで、dockerファイルを追記していたら、以下のコマンドで、既存のDBデータをすべて消して再度イメージをビルドしなおさないと私の環境ではエラーになりました絶対に本番環境ではやらないでください。 2021-05-09 20:43:48
Linux CentOSタグが付けられた新着投稿 - Qiita 【VMware】ゲストOSからホストOSへpingが通らないときの対処法 https://qiita.com/C_Koch/items/48fba7c5b54ad3e0e29d 2021-05-09 20:38:11
Ruby Railsタグが付けられた新着投稿 - Qiita 初学者向けエラーとの戦い方 https://qiita.com/tochisuke221/items/f4016f48c4a47115d83e ちなみに科学的根拠は全然知りませんが、効果は抜群です笑技術編技術については、私もプロではないゆえ、偉そうなことは言えませんが私なりの考えをまとめていきますまず、エラー原因は全てログの中に答えがあるということです。 2021-05-09 20:33:10
Ruby Railsタグが付けられた新着投稿 - Qiita [Ruby]Class毎のよく使う操作をまとめたので見てくれ!! https://qiita.com/ren0826jam/items/24d28839d307ffa825fc RubyClass毎のよく使う操作をまとめたので見てくれClass一覧Numeric数値クラスInteger等のトップクラスです。 2021-05-09 20:06:31
海外TECH DEV Community The new generation of code generator https://dev.to/danieldx/the-new-generation-of-code-generator-26h1 The new generation of code generator Speaking from a scaffoldDaniel Recently I want to build a code generator that can quickly generate project codes What recommendation does Brother Egg have Mr Egg I have always used yeoman in the past and it is an open source project that is nearly k stars However what I want to recommend to you today is not yeoman but a new generation code generator ncgen it may seem more approachable Daniel I like the simple one the most How does it work Mr Egg Old rules you say your needs I will try to answer them one by one First you need a project templateDaniel I have a project template for example vue ncgen demo I hope all new projects come from this project template so I only need to concentrate on maintaining this project template Mr Egg OK this is the function of the project scaffolding Let s take a look at how ncgen is processed The first step is to install ncgen npm i ncgen g yarn global add ncgenThe second step is to generate the configuration file ncgen config js which describes the logic of the code generator ncgen genConfStep Modify main tmplSource in ncgen config js to the url of the project template export default main tmplSource Try it out ncgen ncgen config js Simple copying is not enough modification is necessaryDaniel Whoops is good However the currently generated project is exactly the same as the project template but it will always have its own information that is different from the project template such as the name of the project the name of the author etc I don t want to modify these manually every time the project is generated Mr Egg OK the request is very reasonable Since this information can only be provided by the person who created the project we need to collect this information through some questions and then we can make some modifications to the generated project based on this information We modify the main prompt and main updateFiles in ncgen config jsExample description Perform string replacement on the package json file in the generated project the rules are as follows Replace the string vue ncgen demo with the project name entered by the userReplace the string Daniel xiao with the author name entered by the userexport default main prompt type input name author message What is the author s name updateFiles package json function content options const answers this answers return api replace content vue ncgen demo answers projectNameObj kebabCase Daniel xiao answers author Daniel Hey I noticed that the template engine is not used here but the string replacement is used directlyMr Egg Yes this design has a lot of meaning Using a template engine to replace files may cause the project template itself to fail to run normally because the template engine requires placeholders and placeholders may cause code parsing errorsDaniel Yes in this way the project template is just an ordinary project and there is no need to make some template placeholder transformations What about extra files please deleteDaniel Then I will continue There are some template directories and files such as module template directories component template files in my project template but I don t want to see these templates in the generated project Mr Egg OK no problem just delete the specified files and directories Let s modify the main removeFiles in ncgen config js Example description Delete the ncgen config js and src components base Template vue files in the generated projectexport default main removeFiles ncgen config js src components base Template vue One stop service automatic installation of dependenciesDaniel I just noticed that the above example will automatically install dependencies when it runs It should be installed with npm can this support yarn If I am a non NodeJS project such as Python Go etc can I do it Mr Egg Of course The generated ncgen config js uses npm i to install dependencies by default See the example below If you want to change to yarn just change command to yarn install And if it is Python Go and other languages you only need to change command to the corresponding dependency installation command export default main installDependencies skip false tips Dependencies are being installed it may take a few minutes command npm i Finally give some friendly tipsDaniel That s great The project scaffolding was completed in just a few clicks I think a friendly welcome and beautiful ending is needed in the end Mr Egg Simply modify the main welcome and main complete as you wishexport default main welcome Welcome to use Vue TypeScript Vite project generator complete Congratulations the operation is successful High frequency use is not scaffoldingDaniel The scaffolding is done but it is only used when building a new project High frequency operations are still part of the increase in code such as adding a functional module adding a component adding an API etc Mr Egg I understand what you mean Old rules you ask me to answer The code template exists in the project templateDaniel I want to add a new component to a project I don t want to copy an existing component and then perform various operations to modify and delete the code In fact there is a component template in the project templateMr Egg OK Let s first add a subcommand called add component in ncgen config js Example description assuming that the values ​​of category and name are busi and demo respectively description is used to describe the function of a subcommand api listDirs This API is very useful for allowing users to choose where to insert the code The configuration of addFilesTo will insert the src components base Template vue in the project template into the src components busi Demo vue file in the project export default sub add component description Add vue component prompt type list choices function return api listDirs src components name category message Please select the category type input name name message What is the component name validate input if input return The component name is required return true tmplSource addFilesTo function const answers this answers return src components base Template vue src components answers category answers nameObj upperFirstCamelCase vue The code template does not exist in the project templateDaniel Pretty But for the existing projects these projects are not from the project template and I also want to add some sub commands to generate part of the code for the project how to do Mr Egg The subcommand supports two ways to add files one is the code template from the project template mentioned above and the other is dynamically created by you Both can be used at the same time The following example demonstrates how to dynamically create a code fileExample description assuming that the values ​​of category and name are busi and demo respectively The configuration of addFiles will create a src components busi Demo md file in the project The content of this file is Demoexport default sub add component addFiles function const answers this answers return src components answers category answers nameObj upperFirstCamelCase md function return answers nameObj upperFirstCamelCase Highly recommended replacement techniqueDaniel Next some file contents are modified for example when a page is added the routing rules file will be automatically modified to register routes for the page right The operation is the same as the main command Mr Egg Well savvy A tip recommended here is to add some identification comments where you need to insert the fragment code as shown in the src App vue code lt template gt lt img alt Vue logo src assets logo png gt lt HelloWorld msg Hello Vue TypeScript Vite gt lt Don t touch me place component gt lt template gt lt script lang ts gt import defineComponent from vue import HelloWorld from components busi HelloWorld vue lt Don t touch me import component gt export default defineComponent name App components HelloWorld lt Don t touch me register component gt lt script gt Cooperate with api insertBefore this API to insert the specified content before the specified matching position of the fileexport default sub updateFiles function const answers this answers return src App vue function content options return api insertBefore content lt Don t touch me import component gt import answers nameObj upperFirstCamelCase from components answers category answers nameObj upperFirstCamelCase vue lt Don t touch me register component gt answers nameObj upperFirstCamelCase lt Don t touch me place component gt lt answers nameObj upperFirstCamelCase gt src components answers category answers nameObj upperFirstCamelCase vue function content options return api replace content Template answers nameObj upperFirstCamelCase Daniel Perfect Thank you brother egg I am now eager to try my first code generatorMr Egg Welcome looking forward to your feedback Written at the end Above complete configurationFor the complete configuration of ncgen config js in the example please view Below ncgen official websiteKeywords ncgen scaffolding generator code generator 2021-05-09 11:54:10
海外TECH DEV Community A Quick Dive into the Python Programming Language. https://dev.to/goodnessolawoore/a-quick-dive-into-the-python-programming-language-3cde A Quick Dive into the Python Programming Language Python is a very popular general purpose programming language and has some of the world s largest products built on it Google Netflix Uber Spotify Pinterest Reddit and Instagram are examples of great sites that are built on the python programming language PYTHON PHILOSOPHYPython is said to be the most beginner friendly programming language anyone could learn This philosophy was established way long ago and as much as I am aware of it hasn t been challenged with a countering opinion While I wouldn t say python is the easiest programming language to learn it sure is one of the pretty easy programming languages you could pick up at any point in time PYTHON IS AN OBJECT ORIENTED PROGRAMMING LANGUAGEObject Oriented Programming is a programming pattern that focuses on the concept of classes and objects Python allows us to develop application softwares using this approach  These objects are likened to real world entities like cars schools books etc Take for instance an object could be a car with properties like colour maker model or a school with properties like classes teachers students courses PYTHON IS A DYNAMICALLY TYPED LANGUAGEPython doesn t require you to declare the type of a variable while assigning a value to it unlike some languages where you are compelled to declare the type of a variable before assigning it a value For example if you are going to declare a variable that will contain a string value in C you need to declare the type of that variable as a string before assigning it a value otherwise the program will return an error Example Below In C string language Python Whereas in python you don t need to declare the type at all Python language Python PYTHON IS A GENERAL PURPOSE LANGUAGEThis basically means that python could be used for a wide range of things ranging from web application development mobile application development desktop application development game development machine learning artificial intelligence data science automation etc While Python doesn t singularly support all these variants platforms it has built in libraries and frameworks that make working on these platforms possible and seamless Below are a few Python Frameworks Libraries that you can leverage to suit your desired goal Web Development Django flask Falcon WebpyData Science Numpy Pandas Scrapy Mobile Development Kivy Machine Learning and Artificial Intelligence TensorFlow PyTorch Keras Scikit learn Desktop Development Kivy Tkinter PyQT Game Development Pygame Pykyra PyOpenGl Kivy Pyglet PYTHON IS VERY BEGINNER FRIENDLYPython is written in pure English language and emphasises readability unlike some programming languages that are somewhat naturally complex and would really take the grace of God for a beginner to understand the code that outputs Hello World Hello to C A LITTLE COMPARISONWhile curly brackets are only used to indicate the beginning and the ending of a code block in most programming languages indentation is used instead in python  And while indentations are mainly for styling purposes in other languages it is a strict requirement for your code to get compiled and executed here It basically tells the python interpreter that a series of code statements belongs to a particular block of code READABILITYPython programs are faster to write and much easier to read compared to other programming languages and you can literally read a python code the way you d read an English text PYTHON VERSIONSThere are currently two versions of Python which are version and version While Python version passes for an older and legacy version of Python Python version is the current and actively supported version of the language GET STARTED WITH PYTHON INTEGRATED DEVELOPMENT ENVIRONMENT IDE An IDE basically provides developers with an interface to write code There are a couple of IDEs Integrated Development Environment that support the Python programming language Anaconda Sublime Texts Atom Visual Studio Code PyCharm Vim are good examples Python also has a default IDLE Integrated Development and Learning Environment which is automatically installed when you install python on your PC It is an interactive window where you can type in python codes and see the result This is very beginner friendly and easy to use I will be using the Visual Studio code IDE and the Python IDLE for the purpose of this article You can download VS code if you don t already have it follow the instructions on the site to correctly install and get it running INSTALL PYTHON  Download the latest version of python at www python org downloads Note that this guide is focused on the Windows Operating System To check if python is now installed open the command prompt window on your computer you can easily do this by pressing the Win R keys this would automatically open a quick search window Type “cmd in the search box and press Enter your command prompt window will open afterwards Type the word “python or “py in your command prompt Input pythonORpy Desired result This would check if python is installed and if yes it would return the version of python that you re running also the version of your system OS plus some additional information This is said to be the easiest way to check if Python is installed on a windows PC But if you are sure that python is installed and you just want to check for the version that you re running you could typepython version This would return the version of python installed on your computer Input python version Desired result py version would also work Input py version Desired result As you can see I am running on the latest version of Python Python Now that you have confirmed that python is successfully installed on your machine I know that you are eager to write your first Python code This can be done in three different ways gt Open Visual Studio Code gt Switch to a python interactive environment by typingpythonin your command prompt interface gt Close the command prompt and open the built in Interactive Development and Learning Environment IDLE that was installed with python by default Let s go with the rd option Head over to the folder that contains your Python installation packages My directory looks like this Run the Python application This will open a Python IDLE where you can play around with python codes Alternatively you can hit the Win S keys and type python into the search box Click on the IDLE Python bit If you are running another version of python other than version or bit you won t see “Python bit you will see the exact version that you are running Now that you are in your python interactive environment you might want to type “help to gain insight into the environment available python modules etc Input help Desired result You will see a couple of instructions like the one above You can follow on if you wish RUN YOUR FIRST PYTHON PROGRAM You are about to write your first ever python code fasten your seatbelt What first statement could we print if not the message that welcomes everyone to the world of programming In python theprint function is used to display a message to the screen Let s go ahead and display “Hello World To display an “Hello World text in Python we typeprint “Hello World in C this same code is written as include lt iostream gt     using namespace std  int main     cout lt lt Hello World     return with each line having certain functions they do But since you already said “Yes to python I urge you to be focused and not be distracted Now you can switch back to your Python IDLE Type “print “Hello World and see your first python program run before your eyes Did you get a result like the one above If yes then Congratulations You just successfully ran your first python program Note that the print function is case sensitive andPrint will not work asprint Notice how we didn t use the Visual Studio Code It s all good as you won t need to install it again when you want to start writing codes on an IDE Now that you ve written your first ever python program go rejoicing for you shall now be called a Python Programmer I officially launched this blog last week and I wrote about it you can check it out here 2021-05-09 11:44:35
海外TECH DEV Community Build a simple Node.js RESTful API https://dev.to/youssefallalix/build-a-simple-node-js-restful-api-5g40 Build a simple Node js RESTful API Table Of ContentsWhat is REST PrerequisitesSet up the workspaceSet up the databaseSet up the routesSet up the controllerSet up the serverTest the APIConclusionFinal words What is REST REST is an acronym for Representational State Transfer and it is a software architectural style which uses a subset of HTTPRESTful APIs relies on HTTP verbs to perform four operations The GET to read a resource POST to create and or update a resource and DELETE to delete a resource RESTful APIs are defined with the following aspects A base URI such as Standard HTTP methods e g GET POST PUT and DELETE Media types such as application json In this tutorial we will learn how to create a RESTful API using Node js Prerequisites In order to follow along with this tutorial you will need A Node js environnement installed on your machine A text editor program or IDE VS Code for example A mongoDB instance here in this tutorial we will be using the cloud database MongoDB Atals An API Client such as Postman to help us make HTTP requests and test our API server To avoid running into any compatibility issues I will list the versions of programs and tools used in this tutorial ToolVersionHow to checkNode jsv node vMongoDB Node js driver or laterexpress npm module npm list expressmongoose npm module npm list mongoose Set up the workspace Start the projectIn this tutorial we will be creating a todo list application that will let us create read update and delete tasks Before we begin make sure you have Node js installed mongoDB Atlas instance working and Postman ready for the testing Now open a terminal window or CMD on Windows in a preferred location or use the following command to create a folder and set it as a workspace mkdir todo list api cd todo list apiNow it s time to start our application by typing the following command npm init yWhat it basically does is create a file named package json that contains all the information about our project and its dependencies the y parameter lets me skip filling informations about my project since I could modify these later in the package json file Create necessary folders and filesNow let s create the file that will contain our server script we ll be naming it index js since that s the default name other conventional names can be app js or server js In the command line type the command that will create a new empty file touch index jsNext let s add some folders and files via the following commands Create a folder named api mkdir apiCreate three separate folders models routes and controllers inside the api folder mkdir api controllers api models api routesCreate the empty files controller js routes js and model js inside their respective folders controller routes and model touch api controllers controller js api models model js api routes routes js Set up the database Now that we have our server ready let s set up a database Install mongoose modulemongoose will be used to manage our MongoDB Atlas instance npm install mongoose saveDefine a schemaOpen the file model js and type the following code and then save it model jsconst mongoose require mongoose const taskSchema new mongoose Schema name type String required Enter the name of the task date created type Date default Date now status type type String enum pending ongoing completed default pending module exports mongoose model Tasks taskSchema In the code above we imported the mongoose module into our file and we created a model that defines the structure of our mongoDB collection Set up the routes In Express routing instructs the sever on how to respond to client request for a specific endpoint URI and a specific HTTP request method To do this open the file routes js and type the following code and then save it routes jsmodule exports app gt const todoList require controllers controller js app route tasks get todoList listTasks post todoList createTask app route tasks taskId get todoList readTask put todoList updateTask delete todoList deleteTask In the code above we defined two basic routes tasks and tasks taskId with different methods tasks has the methods GET and POST while tasks taskId has GET PUT and DELETE As you can see we also required the controller so each of the routes methods can call its respective handler function Set up the controlleropen the file controller js and type the following code and then save it controller jsconst mongoose require mongoose const task mongoose model Tasks exports listTasks req res gt task find err task gt if err res send err res json task exports createTask req res gt const new task new task req body new task save err task gt if err res send err res json task exports readTask req res gt task findById req params taskId err task gt if err res send err res json task exports updateTask req res gt task findOneAndUpdate id req params taskId req body new true err task gt if err res send err res json task exports deleteTask req res gt task remove id req params taskId err task gt if err res send err res json message Task deleted In the code above we defined different functions for different actions listTasks lists our tasks createTask creates a new task readTask reads the content of a task updateTask updates the content of a task deleteTask deletes a task Each of these functions is exported in order to be used in our routes Note that each of these functions uses different mongoose methods such as find findById save findOneAndUpdate and deleteOne Set up the server In this section we will be connecting our controller js database the created models body parser and the routes together and at the end we will run our server and test it Install express moduleExpress will be used to create the server npm install express saveStart the server Open the file index js and follow the steps Essentially what we will be doing isConnect our database by adding a url to the mongoose instance connection you can learn how to set up one by following this article Load the created model task Register our created routes in the server Now type the following code inside the file index js and save it Note Don t forget to replace the string in connectionUrl variable with your Atlas connection string index jsconst express require express const app express const port process env PORT const mongoose require mongoose const task require api models model js app use express json app use express urlencoded extended true mongoose instance connection url connectionmongoose Promise global Promise Replace the following with your Atlas connection string const connectionUrl mongodb srv lt username gt lt password gt lt clusterName gt mongodb net lt databaseName gt retryWrites true amp w majority mongoose connect connectionUrl useNewUrlParser true useFindAndModify false useUnifiedTopology true useCreateIndex true import routesconst routes require api routes routes js register the routeroutes app app listen port gt console log RESTful API server running on port Now back to the terminal and type node index js and if everything is fine you ll see the message RESTful API server running on printed to the console Test the API Now that everything is connected let s test some of our routes with the the registered methods Launch Postman or use the web based version you ll need to set up an account it s free In Postman we will test our routes by making requests to their respective endpointsSince there are no tasks nor tasklists in our database yet get requests will return an empty array from the server So the first thing we can do is create a task Create a taskIn order to create a new task let s make a POST request to the following http localhost tasksif you can t use Postman for some reason you can always use the command line tool curl curl data urlencode name Do homework http localhost tasks Delete a taskNow let s try to delete the task we have just created in order to do that let s make a DELETE request to the following http localhost tasks lt taskId gt Note that we have to replace the taskId placeholder with the task identified id we received from the last request Again if you can t use Postman use the command line tool curl curl X DELETE http localhost lt taskId gt Conclusion Congrats you made a functioning RESTful API Final words Don t hesitate to leave any questions you may have for me in the comments I ll be pleased to reply and subscribe for more interesting content like this one 2021-05-09 11:39:57
海外TECH DEV Community Build a Simple Game to Practice Drag Clicking | Minecraft | HTML | CSS | JAVASCRIPT https://dev.to/devko/build-a-simple-game-to-practice-drag-clicking-minecraft-html-css-javascript-448c Build a Simple Game to Practice Drag Clicking Minecraft HTML CSS JAVASCRIPTDrag clicking is one of the most commonly used techniques by the Minecraft gaming community Unlike the traditional clicking this technique helps to get an immense amount of clicks which can lead you so far in the Minecraft game In simple words if you want to dominate in Minecraft PVP game mode you need to be good at clicking with your mouse This simple Drag Clicking Test allows the users to test how good they are at drag clicking and enables them to get to know about their standings Rules of this GameThis game is simple and easy to use there are no complex rules to be honest You just have to use your mouse to perform drag clicking on this game which will eventually get you results there are few limitations in this games such as Users can select a time limit ranging from second up to seconds Users have to click on the dedicated area in order to get their clicks registered Features of this GameThere are plenty of features that make this game stand out one of the Core features of this game is that it is quite simple and easy to use anybody can simply use it without any hassle some of the key features are listed below It shows the remaining time If it shows the real time CPS score Users can opt for light and dark modes as per their comfort level A Video Guide to Drag ClickingIf you are relatively new to drag clicking or you are not that much familiar with drag clicking or simply you want to know how to perform drag clicks while aiming in a better or most efficient way you can follow this video link to a YouTube video further enhance your skills to reach the god level OR simply follow this video to learn basic drag clicking on any mouse Complete Source Code of this GameHere is a complete source code of the drag click test game don t just copy this game and use it as per your requirements but I will encourage you guys to take this project as a starter and amend it as per your needs and your vacation in order to excel in your programming skills HTML lt button id click gt lt button gt lt div id textDiv gt lt p id cps gt lt p gt lt p id timeRemaining gt lt p gt lt p id clickCount gt lt p gt lt p id allTime title Double click to reset gt lt p gt lt div gt lt div id slider container gt lt label id time for timeSlider gt lt label gt lt input type range min max id timeSlider value gt lt input type checkbox id darkTheme gt lt label for darkTheme gt Dark Theme lt label gt lt div gt CSSbody bg color white text color black click color rgb shadow color rgb background color var bg color color var text color overflow hidden click background color var click color width vh height vh border radius box shadow px var shadow color position relative border none font size em click play again after content Click me to play again click active box shadow px px px var shadow color click active after color white click after content Click Me position absolute top vh left text align center width vh font size em body display flex align items center justify content center font family sans serif flex wrap wrap html body height textDiv font size em margin left em width vw clickCount before content Total Clicks cps font size em cps after content cps font size em timeRemaining before content Time Remaining slider container width vw timeSlider width time after content seconds single after content second important time text align center width display block label vertical align middle allTime before content All Time Input type range styles from range css input type range width margin px background color transparent webkit appearance none input type range focus outline none input type range webkit slider runnable track background b border border radius px width height px cursor pointer input type range webkit slider thumb margin top px width px height px background rgba border px solid ff border radius px cursor pointer webkit appearance none input type range focus webkit slider runnable track background ee input type range moz range track background b border border radius px width height px cursor pointer input type range moz range thumb width px height px background rgba border px solid ff border radius px cursor pointer input type range ms track background transparent border color transparent border width px color transparent width height px cursor pointer input type range ms fill lower background a border border radius px input type range ms fill upper background b border border radius px input type range ms thumb width px height px background rgba border px solid ff border radius px cursor pointer margin top px Needed to keep the Edge thumb centred input type range focus ms fill lower background b input type range focus ms fill upper background ee TODO Use one of the selectors from and figure outhow to remove the virtical space around the range input in IE supports ms ime align auto Pre Chromium Edge only styles selector taken from h input type range margin Edge starts the margin from the thumb not the track as other browsers do JAVASCRIPTconst click document getElementById click const clickCountP document getElementById clickCount let clickCount const cps document getElementById cps const timeRemaining document getElementById timeRemaining const timeSlider document getElementById timeSlider const timeText document getElementById time timeSlider oninput gt timeText innerText timeSlider value time timeSlider value if time timeText classList add single else if timeText classList contains single timeText classList remove single let time timeSlider value let startTime null const allTime document getElementById allTime allTime ondblclick gt localStorage removeItem all time updateAllTime const updateAllTime newScore gt console log newScore Number localStorage getItem all time if newScore gt Number localStorage getItem all time localStorage setItem all time newScore toString allTime textContent localStorage getItem all time updateAllTime const showClicks gt clickCountP innerText clickCount showClicks const animFunc gt const elapsed Date now startTime if elapsed lt time cps innerText Math round clickCount elapsed timeRemaining innerText time elapsed toFixed window requestAnimationFrame animFunc else click disabled true cps innerText Math round clickCount time timeRemaining innerText updateAllTime Number cps innerText cps innerText Result cps innerText startTime null click classList add play again setTimeout gt click disabled false const clickHandler gt if startTime startTime Date now window requestAnimationFrame animFunc clickCount click classList remove play again clickCount showClicks click addEventListener mousedown event gt if event button clickHandler click addEventListener contextmenu event gt event preventDefault clickHandler const darkTheme document getElementById darkTheme const isDarkTheme localStorage getItem dark theme true darkThemeIfy bind checked isDarkTheme darkTheme checked isDarkTheme darkTheme oninput darkThemeIfy function darkThemeIfy if this checked document body style setProperty bg color black document body style setProperty text color white document body style setProperty click color rgb document body style setProperty shadow color white localStorage setItem dark theme true else document body style setProperty bg color document body style setProperty click color document body style setProperty text color document body style setProperty shadow color localStorage setItem dark theme false 2021-05-09 11:21:21
海外科学 NYT > Science E-Commerce Mega-Warehouses, a Smog Source, Face New Pollution Rule https://www.nytimes.com/2021/05/08/climate/e-commerce-warehouse-smog-regulation.html E Commerce Mega Warehouses a Smog Source Face New Pollution RuleA plan aimed at the nation s largest cluster of warehouses is designed to spur electrification of pollution spewing diesel trucks and could set a template for restrictions elsewhere 2021-05-09 11:58:21
海外ニュース Japan Times latest articles EU and India agree on trade reboot to confront China threats https://www.japantimes.co.jp/news/2021/05/09/business/eu-india-trade-talks/ china 2021-05-09 21:34:17
海外ニュース Japan Times latest articles Man City made to wait for title after last-minute defeat to Chelsea https://www.japantimes.co.jp/sports/2021/05/09/soccer/epl-mancity-chelsea/ Man City made to wait for title after last minute defeat to ChelseaHundreds of Manchester City fans gathered outside Etihad Stadium for a Premier League title celebration that proved premature as Chelsea ruined the script with a 2021-05-09 20:39:50
海外ニュース Japan Times latest articles NHL eases virus safety rules for the vaccinated in playoffs https://www.japantimes.co.jp/sports/2021/05/09/more-sports/ice-hockey/nhl-playoff-vaccine-rules/ NHL eases virus safety rules for the vaccinated in playoffsThe National Hockey League will relax COVID safety protocols for fully vaccinated teams and individuals in the Stanley Cup playoffs the league announced Saturday The NHL 2021-05-09 20:07:25
ニュース BBC News - Home Election results 2021: PM calls Covid recovery summit after SNP victory https://www.bbc.co.uk/news/uk-57043758 independence 2021-05-09 11:54:11
ニュース BBC News - Home Wales election 2021: Labour set to form new Welsh government alone https://www.bbc.co.uk/news/uk-wales-57042797 basis 2021-05-09 11:25:19
ニュース BBC News - Home Scottish election 2021: Results in maps and charts https://www.bbc.co.uk/news/uk-scotland-scotland-politics-57028315 parliament 2021-05-09 11:29:35
LifeHuck ライフハッカー[日本版] 五月病予防にも。休み明け、明るい気分で仕事に取り組む8つのヒント https://www.lifehacker.jp/2021/05/234347how-to-work-happily-after-gw.html 休み明け 2021-05-09 21:00:00

コメント

このブログの人気の投稿

投稿時間: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件)