python |
Pythonタグが付けられた新着投稿 - Qiita |
pythonを使ってリアクティブなWebアプリを作りたい【開発編4】パスワードの暗号化 |
https://qiita.com/geeorgey/items/85905a4772903b180fad
|
それでも暗号化されているのはなぜかというとモデルに答えがあります。 |
2021-07-21 22:46:27 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
コルーチンで参照渡し(的なこと)をしたい |
https://teratail.com/questions/350682?rss=all
|
コルーチンで参照渡し的なことをしたい前提・実現したいことUnityでゲーム開発をしています。 |
2021-07-21 22:55:52 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
TypeScript: ユニオン型のタイプガードをやりたい。 |
https://teratail.com/questions/350681?rss=all
|
TypeScriptユニオン型のタイプガードをやりたい。 |
2021-07-21 22:53:45 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
OVRCustomHandPrefabの指をTouchControllerの入力で動かしたい |
https://teratail.com/questions/350680?rss=all
|
OVRCustomHandPrefabの指をTouchControllerの入力で動かしたいバージョンOculusnbspquestUnitynbspfOculusnbspIntegrationnbsp前提・実現したいことUnity初学者です。 |
2021-07-21 22:36:34 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
二重投稿を阻止するために、htmlを書き換えるかphpで制御したい。 |
https://teratail.com/questions/350679?rss=all
|
二重投稿を阻止するために、htmlを書き換えるかphpで制御したい。 |
2021-07-21 22:34:45 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
pygameのインストールができない |
https://teratail.com/questions/350678?rss=all
|
pygameのインストールができないpygameをインストールしようとしているのですが、importnbsppygameではエラーが発生しています。 |
2021-07-21 22:09:20 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
【Ruby】3つの:(コロン)の意味 |
https://qiita.com/shiiishim920/items/b5e9750c8a019a45b171
|
etruelengthmaximumcontent |
2021-07-21 22:24:01 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
【Git】チームから学ぶGitの使い方 gitignore編 |
https://qiita.com/nao0725/items/cbba149627bc9ee2a04e
|
対象者gitignoreを知りたい方目的gitignoreに記述して管理から外すファイルを記述する実際の手順と実例gitignoreとはgitとはバージョン管理システムです。 |
2021-07-21 22:11:10 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
ACM+CloudFront+S3で構築したSorryページにRoute53を使ってDNSフェイルオーバーを設定する。 |
https://qiita.com/takasho9321/items/18f2d1acd6294af3fc77
|
構築手順の目次ACMで証明書を発行RouteにてCNAMEレコードを作成プライマリ用のALBを作成セカンダリ用のSバケットを作成Sorryページを作成SorryページのHTMLファイルをSバケットにアップロードCloudFrontを作成RouteでDNSフェイルオーバールーティング先を設定プライマリの設定セカンダリの設定DNSフェイルオーバーの動作確認ACMで証明書を発行構築手順の目次へ、検索バーに「ACM」と入力し、CertificateManagerをクリックする。 |
2021-07-21 22:24:31 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
Dockerコンテナにラベルを設定する |
https://qiita.com/error484/items/42e2577dac1274bcfa74
|
Dockerコンテナにラベルを設定するlabelsを設定dockercomposeymlversionservicesappcontainernameapplabelstestcontainertypeweb例えば、コンテナにtestcontainertypeというキーでwebという値を設定します。 |
2021-07-21 22:44:54 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
Dockerの基本について |
https://qiita.com/atsu123456789/items/85efeb736d1963532706
|
①dockerhubからimageをpullこれはdockerhubにあげられているimageを以下のコマンドでダウンロードする。 |
2021-07-21 22:33:06 |
golang |
Goタグが付けられた新着投稿 - Qiita |
とりあえずバージョン管理しつつGoを利用してみる |
https://qiita.com/yukiyamamuro/items/224072fcde8de4f345ee
|
自分は以上で利用したかったので上記のようにしています。 |
2021-07-21 22:41:33 |
Git |
Gitタグが付けられた新着投稿 - Qiita |
【Git】チームから学ぶGitの使い方 gitignore編 |
https://qiita.com/nao0725/items/cbba149627bc9ee2a04e
|
対象者gitignoreを知りたい方目的gitignoreに記述して管理から外すファイルを記述する実際の手順と実例gitignoreとはgitとはバージョン管理システムです。 |
2021-07-21 22:11:10 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
【Git】チームから学ぶGitの使い方 gitignore編 |
https://qiita.com/nao0725/items/cbba149627bc9ee2a04e
|
対象者gitignoreを知りたい方目的gitignoreに記述して管理から外すファイルを記述する実際の手順と実例gitignoreとはgitとはバージョン管理システムです。 |
2021-07-21 22:11:10 |
海外TECH |
DEV Community |
Building an MVP from Scratch 🚀 |
https://dev.to/codechem/building-an-mvp-from-scratch-5a3e
|
Building an MVP from Scratch Back in October I decided to start a pet project with a goal to learn a new technology I noticed people on Twitter were saying how much they like the Developer Experience of Blitz JS so I decided to use it in this pet project But then I thought this pet project could be something useful to our employees So after a little research I decided to build an Absence Tracker so we can ditch the Telegram group where we reported our absences The InceptionI decided to use Chakra UI along with Blitz JS because it s rich with components and it allows me to quickly build the UI And it looks I did a little planning and Database Design in diagrams net and started to layout the pages One month in I decided to stream the whole development process on Twitch That was one of my best decisions I ve met a lot of cool folks on my streams and they gave me some interesting ideas regarding the implementation All of my streaming archive can be found on my YouTube channel The ChallengesOne of the challenges was keeping up with the changes of Blitz JS When I started the project Blitz was still in alpha And as we all know alpha software tends to change and it s totally normal Blitz JS is maturing in a great way but keeping track of the changes did require a lot of release notes reading and checking out past PRs Another challenge was using Chakra UI with an experimental version of React default by Blitz JS I couldn t find a good workaround so I decided to use the stable version of React The drawback of that was disabling the Concurrent mode of React even though I really liked that feature The BenefitsThis tech stack grew to be my favourite It really allows you to build your app in a record time I really like the DX of Blitz JS and Chakra UI and their intuitive APIs I ll definitely use these technologies for my future projects too As I mentioned streaming on Twitch was one my best decision I ve gotten a lot of followers and met a lot of cool folks that hung around my streams I ve also gotten the attention of Chakra UI They liked my streams and invited me to join the core team The FinaleI decided to bring my colleague iboshkov as a guest to my live stream where we Dockerized the app and deployed it on our company servers There was a readymade Docker image for Blitz JS but we decided to build our own It wasn t complicated at all After we set up everything in a Docker Compose network the deployment was a single line command Next on our list is to onboard all of the employees synchronise the old data with the new platform and officially start using the new platform It started off as a pet project a placeholder for me to learn a new technology but it grew into a cool usable app that will make our lives easier It s been a wild ride but I d do it all over again without thinking |
2021-07-21 13:29:23 |
海外TECH |
DEV Community |
Work in the kitchen. |
https://dev.to/rekki/work-in-the-kitchen-4ifm
|
Work in the kitchen TLDR Use your product and talk to your users as a developer there is nobetter way to work on the things that matter Almost every other pathleads to institutional imperative and deepest technical debt thatis almost impossible to pay There is no better way to code than to work in the kitchen Hi I joined REKKI months ago REKKI is an ordering app that lookslike a chat app that chefs use to order from their suppliers kind oflike inverse deliveroo Whatsapp for chefs is how Ronen describedit when we met best fucking CEO I have ever seen it is pointless totalk here about his vision and etc but if you get a chance to meethim don t miss it My mom has a small grocery shop in Sofia and Iknow how much pain is for her to order from her suppliers and also Ibelieve that the whole producer gt supplier gt restaurant gt consumer marketis completely non transparent and everything can be improved So as I said I joined months ago and then I really did notunderstand what is the actual difference between whatsapp and REKKI so I asked Ronen if he can set me up to work in a restaurant for weeks weeks are you crazy who will write code he said so hegave me days My first hour shift was few days after that My expectations were fairly low besides me being in complete panicand outside of my comfort zone I thought I will wash the dishes andobserve the dynamics I wanted to not be minus to the staff so I pre trained myself howto use the industrial dishwashers watching youtube videos BTWthose things have the best UX ever the colors they use to conveyinformation the way everything works is just incredible PANIC The day has arrived I calmed myself down by watching moredish washing videos from the metro on my way to Restaurant X I wasthere at as agreed The restaurant is fairly big and the kitchen is in the middle soeveryone can see you cooking and the dishwasher was in the back insmaller kitchen You can t imagine my smile when it was one of thedishwashers I have pre trained for The staff was very welcoming and when I told them I trained for thedishwasher they were happy for me to wash the dishes while they dosome veg prep that s kitchen slang for vegetable preparation likechopping potatoes haha Shortly after that they gave me a knife andsome carrots to peel I am fairly good with the knife I doleatherworking and woodworking as a hobby but in no way I amcomparable with a chef for them knifes are more like body parts thananything else still I didn t do bad and when they saw I didn t drawany blood they gave me more and more veg prep work The restaurant opens at and the guests arrive around weate around and then the guests started coming I was in kitchen wearing apron and everything also I have just as much tattoos as thechefs so on the outside there was no question if I am a chef or not Because of my veg prep and dish washing performance I suspect theygave me actual dish to cook mushroom ravioli I think it involved those things long mushroom stems the ones I cut earlier some other mushroomstruffle butterchicken broth one of the tricks I learned everything tastes better if you use chicken broth instead of watersome sauce I forgot how it is calledstirring until mushrooms get goldensome olive oil in the endBTW you can also check out my soup recipe if you are interested in my cookingabilities Turns out all people order food in the same time I am telling you Ihave been dealing with distributed system consensus for the last years and I never thought unorganized entities can act in this waywithout behavior emerging from simple rule like ducks following itsCHAOS I have to do so much mushroom ravioli PANIC You know howall chefs stir the pan by tossing the food in the air Well I have touse a spoon to stir also all the guests can see me using a spoon Anyway I did ok nobody returned their food At It is the firsttime I can step outside for a breath of fresh air for minutes Then things get easier from to guests only drink and westarted cleaning the kitchen around my last metro leaves at so if I don t leave at I won t catch it and of coursethere are guests that won t leave despite restaurant closing My legs hurt from to nonstop bloody hell this is somebrutal work I couldn t take notes or do anything just chop chopchop stir stir stir BTW If the people of RestaurantX happen to read this post thank youso much for letting me cook You rock Few weeks after that I got my second shift in a small michelin starrestaurant Things went in quite similar way but I was moreconfident I did some dishes a lot of veg prep which they thoughtwas boring but I kind of liked it there is not that many times in mylife when I know exactly what to do Again from to and again people did not leave whenrestaurant is closing fuck people just leave Chefs are tired I will do a small divergence here to tell you about the tech stackwe had when I joined Elixir was chosen because whatsapp uses erlang and we needpresence and who is typing feature as any serious chat app In order to build a chat app elixir makes a lot of sense hot codereloading can keep the sockets alive during deploys you have nativepresence with phoenix channels etc also super easy to buildchannels and joining and leaving and everything So I came back to work and let me tell you REKKI is not a Whatsappfor chefs app It is an ordering app that looks like a chat but thereis no way that two chefs are in the app in the same time if one isordering from suppliers the others are cooking or veg prepping oranything but not ordering Oh and I forgot to mention the internet in the kitchen is total shit constantly switching wifi and g and in some parts you have neither Phoenix channels abstraction on top of websocket are full duplex butserial which means you basically can t block on your endpointsbecause no new requests can come through the channel so the payloadwas sent to rabbitmq and then something else executed it This lead toincredibly interconnected and complex especially with retries systemin order to write a record in a database but it was a requirement ifwe want someone is typing except we don t And guess how good the websockets perform with the kitchen s internet Heartbeats reconnects flushing queues pending actions etc etc allhad to be taken care of This is true technical debt you can only solve by doubling down onthe problem you already have and of course you make it work and youimprove it but you can only make incremental improvements You see if you work in the kitchen you see what your technology isdoing and what your users do Now we are moving from elixir to go we moved from channels toendpoints pulled up the queue actions in the endpoints so the chefgets immediate feedback if there is any kind of error with theirrequest I have to say I love the app now how snappy and clean it is We moved away from elixir because we can t get devs and also every onecan read and write go it has like ten reserved words and alsoempowered frontend devs to become fullstack devs and make theirendpoints also it is super annoying to write business logic in afunctional language There is no better way to code than to work in the kitchen Fri Feb CET Borislav Nikolov References BERKSHIRE HATHAWAY shareholders letter training |
2021-07-21 13:22:00 |
海外TECH |
DEV Community |
Optimize Node.js performance with clustering |
https://dev.to/logrocket/optimize-node-js-performance-with-clustering-7ki
|
Optimize Node js performance with clusteringWritten by Geshan Manandhar ️Node js has gained a lot of popularity in the past few years It is used by big names like LinkedIn eBay and Netflix which proves it has been battle tested well In this tutorial we will learn how to use clustering in Node js to get great performance benefits by using all the available CPUs Let s get going The need for clustering in Node jsAn instance of Node js runs on a single thread you can read more about threads in Node js here The official Node js About page states “Node js being designed without threads doesn t mean you can t take advantage of multiple cores in your environment That s where it points to the cluster module The cluster module doc adds “To take advantage of multi core systems the user will sometimes want to launch a cluster of Node js processes to handle the load So to take advantage of the multiple processors on the system running Node js we should use the cluster module Exploiting the available cores to distribute the load between them gives our Node js app a performance boost As most modern systems have multiple cores we should be using the cluster module in Node js to get the most performance juice out of these newer machines How does the Node js cluster module work In a nutshell the Node js cluster module acts as a load balancer to distribute the load to the child processes running simultaneously on a shared port Node js is not great with blocking code meaning if there is only one processor and it is blocked by a heavy and CPU intensive operation other requests are just waiting in the queue for this operation to complete With multiple processes if one process is busy with a relatively CPU intensive operation other processes can take up the other requests coming in utilizing the other CPUs cores available This is the power of the cluster module where workers share the load and the app does not come to a stop due to high load The master process can distribute the load to the child process in two ways The first and default is a round robin fashion The second way is the master process listens to a socket and sends the work to interested workers The workers then process the incoming requests However the second method is not super clear and easy to comprehend like the basic round robin approach Enough of the theory let s have a look at some prerequisites next before diving into the code PrerequisitesTo follow this guide about clustering in Node js you should have the following Node js running on your machine Working knowledge of Node js and Express Basic knowledge on how processes and threads work Working knowledge of Git and GitHubNow let s move into the code of this tutorial Building a simple Express server without clusteringWe will start by creating a simple Express server This server will do a relatively heavy computational task which will deliberately block the event loop Our first example will be without any clustering To get Express set up in a new project we can run the following on the CLI mkdir nodejs clustercd nodejs clusternpm init ynpm install save expressThen we will create a file called no cluster js on the root of the project like below The contents of the no cluster js file will be as follows const express require express const port const app express console log Worker process pid started app get req res gt res send Hello World app get api slow function req res console time slowApi const baseNumber let result for let i Math pow baseNumber i gt i result Math atan i Math tan i console timeEnd slowApi console log Result number is result on process process pid res send Result number is result app listen port gt console log App listening on port port Let s look at what the code is doing We start off with a simple Express server that will run on port It has two URIs that show Hello World and another path api slow The slow API GET method has a long loop that loops which is times In each loop it does a math atan or an arctangent in radians of a number and a math tan the tangent of a number It adds these numbers to the result variable After that it logs and returns this number as the response Yes it has been made deliberately time consuming and processor intensive to see its effects with a cluster later We can quickly test it out with node no cluser js and hit http localhost api slow which will give us the following output The CLI where the Node js process is running looks like the screenshot below As seen above the API took ms for loops to finish as per our profiling added with console time and console timeEnd calls The code up to this point is accessible as a pull request for your reference Next up we will create another server that looks similar but has the cluster module in it Adding Node js clustering to an Express serverWe will add an index js file that looks similar to the above no cluster js file but it will use the cluster module in this example The code for the index js file looks like the below const express require express const port const cluster require cluster const totalCPUs require os cpus length if cluster isMaster console log Number of CPUs is totalCPUs console log Master process pid is running Fork workers for let i i lt totalCPUs i cluster fork cluster on exit worker code signal gt console log worker worker process pid died console log Let s fork another worker cluster fork else startExpress function startExpress const app express console log Worker process pid started app get req res gt res send Hello World app get api slow function req res console time slowApi const baseNumber let result for let i Math pow baseNumber i gt i result Math atan i Math tan i console timeEnd slowApi console log Result number is result on process process pid res send Result number is result app listen port gt console log App listening on port port Let s look at what this code is doing We first require the express module then we require the cluster module After that we get the number of CPUs available with require os cpus length It was eight in my case on a Macbook Pro with Node js running Consequently we check if the cluster is master After a couple of console logs we fork workers the same amount of times as the number of CPUs available We just catch on the exit of a worker we log and fork another one If it is not the master process it is the child process and there we call the startExpress function This function is the same as the Express server in the previous example without clustering When we run the above index js file with node index js we see the following output As we can see all eight CPUs have eight relevant workers running ready to take up any requests coming in If we hit http localhost api slow we will see the following output identical to the output from the previous non clustering server The code for the server with the cluster module is in this pull request Next up we will load test an Express server with and without clustering to evaluate the difference in response times and the number of requests per second RPS it can handle Load testing servers with and without clusteringTo load test our Node js servers with and without clustering we will use the Vegeta load testing tool Other options can be the loadtest npm package or the Apache benchmark tool as well I find Vegeta easier to install and use because it is a Go binary and the precompiled executables are seamless to install and get started After we have Vegeta running on our machine we can run the following command to start the Node js server without any clustering enabled node no cluster jsIn another CLI tab we can run the following command to send RPS for s with Vegeta echo GET http localhost api slow vegeta attack duration s rate vegeta report type textIt will result in an output like below after around s If you check the other tab with Node js running you will see lots of logs flowing Some quick insight from the above load test A total of requests were sent and the server had a maximum good response of RPS The fastest response time was μs and the slowest one was s Similarly only requests came back with response codes meaning a percent success rate without the cluster module Let s stop that server and run the other server with cluster module with node index jsIf we run the same test of RPS for s in this second server we can see a difference We can run the load test by running echo GET http localhost api slow vegeta attack duration s rate vegeta report type textAfter s the output will look something like this We can clearly see a big difference here as the server can exploit all the CPUs available not only one All requests were successful coming back with a response code The fastest response was in ms and the slowest was only ms compared to s without the cluster module The throughput was also so this time the server had no issues handling RPS for s With all eight cores available to process it can easily handle a higher load than the previous RPS If you look at the CLI tab with the Node js server with cluster it should show something like this This tells us that at least two of the processors were used to serve up the requests If we had tried with say RPS it would use up more of the CPUs and processes as per need You can surely give it a try with RPS for s and see how it fares It maxed out at around RPS on my machine From RPS without cluster to RPS with cluster the cluster module has a response success rate nearly four times better This is the advantage of using a cluster module to use all the available CPU resources Next stepsUsing clustering on our own is beneficial for performance as seen above For a production grade system it would be better to use battle tested software like PM It has cluster mode built in and includes other great features like process management and logs Similarly for a production level Node js application running in containers on Kubernetes the resource management part might be better handled by Kubernetes These are the decisions and tradeoffs you and your software engineering team will need to make to have a more scalable performant and resilient Node js application running on a production environment ConclusionIn this article we learned how to exploit the Node js cluster modules to fully utilize the available CPU cores to extract better performance from our Node js application Amongst other things clustering can be yet another useful tool in the Node js arsenal to gain better throughput s only ️Monitor failed and slow network requests in productionDeploying a Node based web app or website is the easy part Making sure your Node instance continues to serve resources to your app is where things get tougher If you re interested in ensuring requests to the backend or third party services are successful try LogRocket LogRocket is like a DVR for web apps recording literally everything that happens on your site Instead of guessing why problems happen you can aggregate and report on problematic network requests to quickly understand the root cause LogRocket instruments your app to record baseline performance timings such as page load time time to first byte slow network requests and also logs Redux NgRx and Vuex actions state Start monitoring for free |
2021-07-21 13:18:09 |
海外TECH |
DEV Community |
'N' and 'E' of MERN - Fundamentals of Node.js and Express.js |
https://dev.to/jaskaran/n-and-e-of-mern-fundamentals-of-node-js-and-express-js-13bc
|
x N x and x E x of MERN Fundamentals of Node js and Express js Introduction What is Node js Node js is an open source cross platform back end JavaScript runtime environment that executes JavaScript code outside a web browser Open source because it s source code is available for use and modification legally Cross platform works across different platforms like Linux OSX and Windows Backend receives requests from clients and contains the logic to respond to it JS runtime environment where JavaScript code gets parsed and executed Node is a JavaScript environment built on the same JavaScript engine used in Google s Chrome web browser It has some great features that make it an attractive choice for building server side applications including web servers and web services for platform APIs Primary goals of this article Understand how Node js applications are builtImplement a TODO application using Node jsImplement REST APIs using Express jsPrerequisite As Node js is based on JavaScript it s easier to learn to get started with for developers who know JavaScript This also means that both the frontend and backend can now be written with just JavaScript knowledge Before we jump in make sure you have node installed Install from Here Let s get started Let s look at how to create a simple server using Node jscreate a file app js and paste the following code File app jsconst http require http const port http createServer request response gt Set response status code and response headers response writeHead Content Type text html Set response body i e data to be sent response write lt h gt TODO lt h gt Tell the server the response is complete and to close the connection response end listen port gt Log text to the terminal once the server starts console log Nodejs server started on port port Execute node app js in the terminal You will see the following in terminal Nodejs server started on port Basically your server has started on port Let s test it with curl curl X GET http localhost Or visit http localhost in your browser to see the response sent by the above server That s it You ve just built your first Node app So What s happening with above code http is an inbuilt Node module you can use require to import it The http module exposes a function createServer which can be used to create an HTTP server You have to pass a callback function as a parameter to the createServer function This function gets executed every time the server receives a request The parameters to the callback function are the HTTP request and response objects We used these response object methods writeHead the first parameter is the response status code and the second any response headers write to add response body to be sent back to the client end tells the server that the response is complete and OfCourse we can add any number of response write calls before response end is called to send more data Here We are just sending a h tag with text as TODO curl command prints out the response as such lt h gt TODO lt h gt The browser renders the HTML tag and displays an h heading with text TODO The listen method sets the port in which the server listens to the requests You can also add a callback function to listen which will get executed once when the server starts Normally we add lines such as Nodejs server started on port to make sure that server is listening RoutingOk So currently our server sends same response h Tag with status code to every irrespective of url and method request it receives Let s change the body of createServer method with following const method url request fetch request method and path by using the request object s method and url properties if url todos if method GET response writeHead Content Type text html response write lt h gt TODO lt h gt response write lt p gt Track your work lt p gt else response writeHead or response statusCode else response writeHead response end Now the server checks if url variable is todos If so check if method is GET If so return the header and HTML responseElse return just a status codeElse return status code Now if you try tocurl X GET http localhost randomCan you guess what response are you going to get from server The url path is random so server sends response with status code as if you try tocurl X POST http localhost todosyes the url is todos but the method is POST now you will get response code as Note that OK response status code is send by default if it s not set explicitly Request BodyThe request object that s passed in to a handler implements the ReadableStream interface This stream can be listened to or piped elsewhere just like any other stream We can grab the data right out of the stream by listening to the stream s data and end events The request on method can be used to look for the stream events The data is read in chunks and is a buffer Once the whole data is read known by the end event you can parse the JSON data as a JavaScript object using the JSON parse function let body request on error err gt console error err on data chunk gt body chunk keep concatenating the chunk on end gt body JSON parse body URL ModuleWhat if we want to filter the response based on url parmaters We can use the Built in URL Module The URL module splits up a web address into readable parts var url require url var adr http localhost default htm year amp month february request urlvar q url parse adr true console log q host returns localhost console log q pathname returns default htm console log q search returns year amp month february var qdata q query returns an object year month february console log qdata month returns february Now If you have gone through the complete article up to this point you have really good knowledge of Node js and of course there are always so many new things to explore ExpressExpress js is a Node js framework and makes it easier to build APIs We will be implementing the same APIs we created using Node js You can then compare both the implementations to view how Express js makes it easier First let s get Express to work on your system npm install expressExpress enables you to create a web server that is more readable flexible and maintainable as compared to developing a web server using only the Node HTTP library which can get complicated for even the most basic web servers Routing in Express and HTTP MethodsThe syntax for defining a route handler function is app httpMethod path handler Here httpMethod can be get put post delete etc The path is the actual route where the request will go and the handler is the same callback function which were passing to createServer in node js that is it will execute when the requested route is found Let s implement the GET API to the todos path using Expressconst app express app get todos request response gt response status response send lt h gt TODO lt h gt const port app listen port function console log Nodejs server started on port port Express Server is initialized using the express method For GET we used app get method likewise you will use app post app delete etc for other HTTP methods The response object s send method is used to send the response body To bind the server to a port you use the listen method on the Express application app As Javascript is a case sensitive language app GET won t work Express MiddlewaresMiddleware functions are those that have access to request and response objects just like we do within routes Middlewares are capable of changing requests response objects and can end the response cycle as well You can think of middleware as a stack of functions that gets executes whenever a request is made to the server Generally a middleware function takes parameters a request object a response object and a next function Whenever you write a middleware you must call this next function at the end of every middleware function you write In order to use middleware in your application you have to make a call to app use and pass a middleware function as an argument For example User defined Middlewareapp use function req res next console log Inside Middleware function next If you do not call next no more route handlers or middleware will be processed If still for some reason you don t want to call next then just send a response to the client or else the client will remain in hang state and eventually get timed out Now we have basic understanding of Express let s complete our TODO application using Express const express require express importing expressconst app express initializing express appapp use express json express json middleware to parse the request body as JSON const port let todoList Complete writing blog Complete project Get all TODOS curl v http localhost todos app get todos request response gt response send todoList Add a TODO to the list curl v X POST d name Plan for next week http localhost todos H content type application json app post todos request response gt let newTodo request body name todoList push newTodo response status send Delete a TODO to the list curl v X DELETE d name Complete writing blog http localhost todos app delete todos request response gt let deleteTodo request body name console log deleteTodo for let i i lt todoList length i if todoList i deleteTodo todoList splice i response status send app all todos request response gt response status send app all request response gt response status send app listen port gt console log Nodejs server started on port port What is app all To send a status code for requests to todos other than GET POST and DELETE we can use the app all method below the current set of routes Express returns a status code with HTML content by default for any unimplemented route or we can also use the app all method at the end to add a custom handler ConclusionCongratulations on making till the end We have learned a lot in this article I hope you now have a decent knowledge of Node and Express Now you can create simple applications using the Node js framework Use Node js to create a web server that listens to multiple routes Utilize the Express js library in your Node applications I will come with more articles on this topic soon Till then Keep Learning Also please ️ if you liked this article |
2021-07-21 13:06:04 |
Apple |
AppleInsider - Frontpage News |
Wall Street consensus on Apple Q3 performance 'conservative,' says analyst |
https://appleinsider.com/articles/21/07/21/wall-street-consensus-on-apple-q3-performance-conservative-says-analyst?utm_medium=rss
|
Wall Street consensus on Apple Q performance x conservative x says analystInvestment bank Wedbush believes that an iPhone supercycle and Apple s services will lead to another major earnings beat when the Cupertino tech giant reports its Q quarterly results The iPhone and iPhone Pro In a note to investors seen by AppleInsider Wedbush analyst Daniel Ives says he expects Apple s June quarter fiscal results to be another beat across the board Read more |
2021-07-21 13:58:15 |
Apple |
AppleInsider - Frontpage News |
Virulent Windows 'XLoader' malware is now on macOS |
https://appleinsider.com/articles/21/07/21/virulent-windows-xloader-malware-is-now-on-macos?utm_medium=rss
|
Virulent Windows x XLoader x malware is now on macOSA particularly powerful malware tool called XLoader has been ported to the Mac and users can be tricked into giving it access to passwords clipboard and allowing it to take screenshots Malware on Mac is still a small scale threat compared to Windows but it is growing and there have even been Apple Silicon versions Now the infamous XLoader malware for Windows has been detected on Macs While there might be a gap between Windows and MacOS malware the gap is slowly closing over time The truth is that MacOS malware is becoming bigger and more dangerous said Yaniv Balmas of Check Point Security which discovered the macOS version told Bleeping Computer Read more |
2021-07-21 13:49:13 |
Apple |
AppleInsider - Frontpage News |
Apple's M1 iPad Pro 12.9-inch drops to $999, lowest price ever |
https://appleinsider.com/articles/21/07/13/apples-m1-ipad-pro-129-inch-drops-to-999-lowest-price-ever?utm_medium=rss
|
Apple x s M iPad Pro inch drops to lowest price everApple s brand new M iPad Pro is on sale at Amazon with the inch model off and the inch tablet off while supplies last New M iPad Pro markdownsAmazon s deal delivers the lowest inch iPad Pro price available on the GB M model with units in stock in the sleek Space Gray finish at press time Read more |
2021-07-21 13:44:15 |
海外TECH |
Engadget |
How to watch the Tokyo Olympics |
https://www.engadget.com/how-to-watch-the-tokyo-olympics-134504180.html?src=rss
|
How to watch the Tokyo Olympics nbsp After a year long delay due to the global COVID pandemic the games of the XXXII Olympiad are scheduled to begin in Tokyo this week Despite Japan s struggles to contain the virus and athletes testing positive inside the Olympic Village the event is still on The sheer amount of action happening every day through the first week of August means you ll need to plan ahead to catch all of the events you want to see especially if you re on the opposite side of the world When do the Olympics start The official start to the Olympics is the opening ceremony on Friday July rd at AM ET but a few events will actually kick off before that Softball and Women s Soccer competition begins Wednesday Tokyo time but the first games aired Tuesday night on the east coast Softball Men s Soccer and Rowing are set to take place on Thursday with Rowing Cycling Tennis and Women s Water Polo scheduled after the Opening Ceremony Friday and into Saturday This weekend is when things really get going though with a packed slate of events from Saturday onward The closing ceremony will air at PM ET on NBC on Sunday August th How to watchUSA TODAY USPW reutersFor those of us in the United States NBC is the official broadcaster of the Summer Olympics and has been since The network s current deal goes through so you won t have to look around to find the games on new channels anytime soon Due to the volume of events NBC proper isn t enough to show all of the action so you can also find live coverage on NBCSN USA CNBC Golf Channel and the Olympic Channel ーcable or TV streaming subscription required Following controversy over tape delays during previous Olympics NBC began airing events live in despite the massive time differences During prime time in the US the network will show highlights from earlier in the day in addition to any live action At least a portion of the marquee events ーincluding the opening closing ceremonies Women s Soccer Final Basketball Track amp Field ーwill air on NBC A lot of the events that take place in the middle of the night Eastern time which is the bulk of the action will be shown on the other networks and NBC s streaming service Peacock NBC Sports announced that Peacock will be home to “major events live each morning including Women s and Men s Gymnastics Track amp Field and Basketball The streaming service will also have six themed channels alongside three highlight shows throughout the day Eastern time along with a spotlight series that focuses on the women of Team USA Olympics coverage will be available for free on Peacock with the exception of Men s Basketball You ll need a subscription to watch those games If you d rather watch from your computer phone or tablet NBC says “every single event will be available through NBCOlympics com and the NBC Sports app Twitch will also serve up Olympics content but not live events There you ll find interviews highlights and of course competitions The platform will also host streams and co streams with Twitch creators during some of the primetime broadcasts Thomas Peter reutersSeveral services and TV providers offer tools to help you keep up with all of the action YouTube TV for example allows you to select which events you re interested in and the app will automatically record them to its cloud DVR Here s to watching Swimming at a normal hour and not staying up until AM YouTube TV has also added a medal table for quick reference and its “Jump To feature lets you hop around events and specific moments easily Cable providers like Comcast owned by NBC s parent company are offering Olympics hubs on their services for easy access There s a degree of personalization across Xfinity tiers for example as well as notifications about “must see moments and playlists of highlights For a full schedule visit NBCOlympics com to find info on all of the events you re looking for Fans in the UK don t have to contend with quite the time difference as those of us in the States but they ll still get to watch as much of the action as they want The BBC is the official broadcaster in the UK and it s promising over hours of coverage through early August BBC One and BBC Two will show live events while an additional livestream will be available on BBC iPlayer The network will have daily highlights and recap shows in both the morning and evening with anything that airs on BBC One or Two available on demand via iPlayer Coverage is also available through BBC Radio Live and The Olympics Daily podcast |
2021-07-21 13:45:04 |
海外TECH |
Engadget |
The best laptops for gaming and schoolwork |
https://www.engadget.com/best-gaming-laptops-for-students-170026726.html?src=rss
|
The best laptops for gaming and schoolworkThere s never been a better time to be a PC gamer especially when it comes to laptops Gaming notebooks are lighter more powerful and cheaper than ever before They re particularly useful for students because their beefy hardware could be helpful for rendering video and doing any other schoolwork that would make super thin ultraportables sweat You can find some general advice on choosing gaming laptops in our guide In this piece you ll find a few selections specifically geared towards school use Are gaming laptops good for college As stated above gaming laptops are especially helpful if you re doing any demanding work Their big promise is powerful graphics performance which isn t just limited to games Video editing and D rendering programs can also tap into their GPUs to handle especially demanding tasks While you can find decent GPUs on some productivity laptops like Dell s XPS you can sometimes find better deals on gaming laptops My general advice for any new workhorse machine Get at least GB of RAM and the largest solid state drive you can find Those components are both typically hard to upgrade down the line The one big downside to choosing a gaming notebook is portability For the most part we d recommend inch models to get the best balance of size and price Those typically weigh in around pounds which is a significantly more than three pound ultraportables Today s gaming notebooks are still far lighter than older models though so at least you won t be lugging around a pound brick Also if you re not into LED lights and other gamer centric bling keep an eye out for more understated models or make sure you know how to turn those lights off Best midrange for most people ASUS Zephyrus GWill Lipman Photography ASUSThe Zephryus G has all the power you d want in a gaming laptop at a price that s more reasonable than higher end options It s a slightly larger follow up to last year s favorite for this category the G but there s still lots to love The G features AMD s latest Ryzen processors along with NVIDIA s RTX GPUs And judging from our benchmarks it manages to make good use of all that power It also has a fast Hz p screen which is ideal for playing games at high framerates The G doesn t have a webcam but its solid specs and performance more than make up for that Buy Zephyrus G at Best Buy Best high end option Razer Blade Will Lipman Photography for EngadgetFor years Razer has staked a reputation for building gaming laptops that look as good as MacBooks And that s still true Razer s Blade features a sleek and sturdy metal case an impressively understated design unless you really kick up those RGB keyboard lights and just about all the power you d want in a portable gaming powerhouse If money is no object you can equip the Blade with Intel s latest th gen processors NVIDIA s powerful RTX and either a Hz QHD or Hz HD screen While you ll pay a bit more for the Blade compared to some other models you ve still got a few different price points to work with The entry level model starts at with an RTX GPU and Hz p display That s certainly enough power for most games and creative apps If you re looking for something a bit smaller Razer s new AMD powered Blade looks compelling as well Buy Blade at Razer A stylish mid range option Alienware M R Ryzen EditionWill Lipman Photography AlienwareAlienware s M notebooks have made for solid options over the last few years but the R Ryzen Edition adds something new to the mix with AMD s latest processors Basically you can expect slightly better multi core performance from this machine compared to its Intel equipped siblings The Alienware M still retains the brand s signature sci fi like aesthetic making the R Ryzen Edition a great option if you want a notebook that s also distinct without looking garish like cheaper offerings Buy M R Ryzen Edition at Dell Best budget option Dell G Will Lipman Photography DellWhile Alienware has established itself as a solid premium brand Dell s cheaper G series notebooks are worth a look for anyone on a budget In particular the G continues the trend of delivering very capable hardware under Sure the case may contain a lot of plastic and the screen doesn t offer all of the latest niceties but for the price it s hard to find something much better Buy G at Dell Best no limit gaming laptop ASUS Zephyrus Duo SEWill Lipman Photography ASUSTaking the idea of a gaming laptop to the absolute extreme ASUS s latest Zephyrus Duo combines AMD s latest Ryzen mobile processors with all of NVIDIA s great RTX series hardware And true to its name it has two screens a gorgeous inch main display and a very wide secondary panel right below That opens up a near desktop level of multitasking since you can have windows spread across both screens That could be useful for browsing the web and keeping an eye on Twitter at the same time Or perhaps squeezing in a game of Overwatch while following an online lecture on the other screen We won t tell anyone Buy Zephyrus Duo SE at ASUS |
2021-07-21 13:30:19 |
海外TECH |
Engadget |
Uber can deliver your Costco groceries (if you live in Texas) |
https://www.engadget.com/uber-costco-grocery-delivery-pilot-131110472.html?src=rss
|
Uber can deliver your Costco groceries if you live in Texas Uber s grocery deliveries will soon include Costco s bulk sized foodstuffs provided you live in the right state The internet giant is launching a pilot that will deliver Costco groceries from warehouses in Texas with seven more locations available in the quot coming weeks quot Uber and Uber Eats app users will initially find the option available in Austin Dallas and Houston You ll need to place at least a order and you ll have to pay for delivery unless you re an Uber Pass or Eats Pass member A virtual storefront in the Uber and Uber Eats apps will focus on your quot favorite quot essential items This is Uber s first experiment with an American food wholesaler It s not certain if the pilot will translate to a full fledged expansion but it would represent a major move if so While Uber recently doubled the scale of its US grocery deliveries with over new cities a larger team up with Costco would improve the depth of that service ーyou d have more shopping choices particularly if you need to make large orders |
2021-07-21 13:11:10 |
海外TECH |
CodeProject Latest Articles |
Building/deploying Jekyll and Hugo sites via GitLab CI |
https://www.codeproject.com/Articles/5308545/Building-deploying-Jekyll-and-Hugo-sites-via-GitLa
|
gitlab |
2021-07-21 13:52:00 |
海外TECH |
CodeProject Latest Articles |
Building a Native WebView Application for Windows on Arm with Electron |
https://www.codeproject.com/Articles/5308608/Building-a-Native-WebView-Application-for-Windows
|
Building a Native WebView Application for Windows on Arm with ElectronIn this article we will look at how you can create a new Electron app targeted at bit WoA devices and how you can port existing Electron apps |
2021-07-21 13:30:00 |
海外TECH |
CodeProject Latest Articles |
API Key Authentication - Extending the Native Implementation |
https://www.codeproject.com/Articles/5308560/API-Key-Authentication-Extending-the-Native-Implem
|
API Key Authentication Extending the Native ImplementationIn this article we re going to create the code and understand how it works to handle API Key authentication with just three lines of code extending the native Authentication mechanism |
2021-07-21 13:09:00 |
金融 |
RSS FILE - 日本証券業協会 |
会長記者会見−2021年− |
https://www.jsda.or.jp/about/kaiken/kaiken_2021.html
|
記者会見 |
2021-07-21 13:30:00 |
金融 |
金融庁ホームページ |
資金交付制度について公表しました。 |
https://www.fsa.go.jp/common/shinsei/shikinkohu/index.html
|
資金 |
2021-07-21 15:00:00 |
ニュース |
BBC News - Home |
Brexit: NI-GB trade agreement must be overhauled immediately - UK |
https://www.bbc.co.uk/news/uk-politics-57911148
|
agreement |
2021-07-21 13:06:41 |
ニュース |
BBC News - Home |
Keir Starmer to isolate after child gets Covid |
https://www.bbc.co.uk/news/uk-politics-57918823
|
covid |
2021-07-21 13:52:30 |
ニュース |
BBC News - Home |
Medal hope Amber Hill out of Tokyo Olympics |
https://www.bbc.co.uk/sport/olympics/57917553
|
covid |
2021-07-21 13:08:14 |
ニュース |
BBC News - Home |
Priti Patel defends deal to stop rising numbers crossing Channel |
https://www.bbc.co.uk/news/uk-57916659
|
channelthe |
2021-07-21 13:20:03 |
ニュース |
BBC News - Home |
'Catastrophic' backlog at driving licence body, warns union |
https://www.bbc.co.uk/news/business-57916619
|
processing |
2021-07-21 13:36:27 |
ニュース |
BBC News - Home |
PMQs: Boris Johnson urged to apologise for 'over 80s' Covid comment |
https://www.bbc.co.uk/news/uk-politics-57917172
|
cummings |
2021-07-21 13:54:05 |
ニュース |
BBC News - Home |
Giant hail damages cars and windows in heatwave storm |
https://www.bbc.co.uk/news/uk-england-leicestershire-57909700
|
england |
2021-07-21 13:19:39 |
ニュース |
BBC News - Home |
Vue Cinemas apologise over Birmingham seat crush death |
https://www.bbc.co.uk/news/uk-england-birmingham-57917470
|
ateeq |
2021-07-21 13:08:35 |
ニュース |
BBC News - Home |
Dinosaurs: 'Spectacular' fossil footprint find by four-year-old goes on display |
https://www.bbc.co.uk/news/uk-wales-57910510
|
footprint |
2021-07-21 13:11:39 |
ニュース |
BBC News - Home |
Jones to captain Lions in first Test against South Africa |
https://www.bbc.co.uk/sport/rugby-union/57914574
|
Jones to captain Lions in first Test against South AfricaAlun Wyn Jones returns to captain the British and Irish Lions against South Africa on Saturday in a side including three Scottish players for the first time since |
2021-07-21 13:51:49 |
ニュース |
BBC News - Home |
'We got bopped' - Sweden end USA's 44-match unbeaten run in Tokyo |
https://www.bbc.co.uk/sport/olympics/57912250
|
x We got bopped x Sweden end USA x s match unbeaten run in TokyoSweden s women s football team stun world champions the United States in their opening match at the Olympic Games in Tokyo |
2021-07-21 13:22:37 |
LifeHuck |
ライフハッカー[日本版] |
キーボードやソファの隙間もスッキリ!ペットボトルサイズの小型掃除機【今日のライフハックツール】 |
https://www.lifehacker.jp/2021/07/238619lht-xiaomi-mi-vacuum-cleaner-mini.html
|
xiaomi |
2021-07-21 22:05:00 |
北海道 |
北海道新聞 |
兵庫・明石歩道橋事故から20年 遺族ら献花、犠牲者11人追悼 |
https://www.hokkaido-np.co.jp/article/569877/
|
兵庫県明石市 |
2021-07-21 22:14:00 |
北海道 |
北海道新聞 |
胆振管内8人感染 日高管内はゼロ 新型コロナ |
https://www.hokkaido-np.co.jp/article/569879/
|
新型コロナウイルス |
2021-07-21 22:17:00 |
北海道 |
北海道新聞 |
東京五輪、23日に開会式 サッカー女子、日本引き分け |
https://www.hokkaido-np.co.jp/article/569880/
|
引き分け |
2021-07-21 22:17:00 |
北海道 |
北海道新聞 |
首相、記者団の取材にいら立ち 立て続け質問、注意促す |
https://www.hokkaido-np.co.jp/article/569868/
|
立て続け |
2021-07-21 22:05:00 |
北海道 |
北海道新聞 |
柏崎原発再稼働「22年度以降」 東電が経営計画発表 |
https://www.hokkaido-np.co.jp/article/569846/
|
東京電力ホールディングス |
2021-07-21 22:16:11 |
北海道 |
北海道新聞 |
首相とジル夫人、22日に面会 五輪外交スタートへ |
https://www.hokkaido-np.co.jp/article/569844/
|
大統領夫人 |
2021-07-21 22:16:03 |
北海道 |
北海道新聞 |
マツカワ無事に育って 漁業振興協、白老港で稚魚10万匹放流 |
https://www.hokkaido-np.co.jp/article/569873/
|
太平洋海 |
2021-07-21 22:10:00 |
北海道 |
北海道新聞 |
五輪チケット購入者の情報流出 ボランティアも、組織委が調査 |
https://www.hokkaido-np.co.jp/article/569872/
|
情報流出 |
2021-07-21 22:09:00 |
北海道 |
北海道新聞 |
後志管内5人感染 新型コロナ |
https://www.hokkaido-np.co.jp/article/569871/
|
新型コロナウイルス |
2021-07-21 22:08:00 |
北海道 |
北海道新聞 |
衆院選道4区、見えぬ対決構図 立憲は混迷、共産は転換、自民は着々 |
https://www.hokkaido-np.co.jp/article/569870/
|
任期満了 |
2021-07-21 22:06:00 |
北海道 |
北海道新聞 |
NY円、110円前半 |
https://www.hokkaido-np.co.jp/article/569869/
|
外国為替市場 |
2021-07-21 22:05:00 |
北海道 |
北海道新聞 |
ハママシケ陣屋跡の大手門復元 浜益・川下地区で工事完了 郷土の歴史後世に |
https://www.hokkaido-np.co.jp/article/569867/
|
浜益区川下 |
2021-07-21 22:02:00 |
仮想通貨 |
BITPRESS(ビットプレス) |
日本暗号資産ビジネス協会(JCBA)、7/29にWEBで会員対象の「7月度勉強会」開催 |
https://bitpress.jp/count2/3_15_12594
|
資産 |
2021-07-21 22:26:07 |
仮想通貨 |
BITPRESS(ビットプレス) |
[CoinChoice] 経済学者タレブ氏がビットコイン(BTC)を「価値がなく、通貨として失敗」と批判 |
https://bitpress.jp/count2/3_9_12660
|
coinchoice |
2021-07-21 22:13:21 |
コメント
コメントを投稿