vvlnote.github.io


Summary of setting up Express and MongoDB as Backend Server

Install Express.js and MongoDB as backend server

  1. Create a folder with your project name.
  2. cd to the folder that you just created.
  3. Run npm init.
    • For the backend, the start poinst is server.js
    • License : β€œMIT” After above type in, you will get a package.json file under the folder.
  4. Install dependencies:
    npm i express body-parser mongoose concourrently cors dotenv

    • Express is a Node.js web application server framework, designed for building single-page, multi-page, and bybrid web application will be creating routers or APIs
    • body-parser is a middleware in order for application to be able to ready the body of an incoming JSON object. If express.js version is 4.16+, the exrpess.js package included this middleware. so you do not need to to install this.
    • mongoose is an ODM (Object Data Modeling) library for MongoDB and Node.js.
      It manages relationships between data, provides shcema validation, and is used to translated between objects in code and the represenation of those objects in MongoDB.
    • concurrently, this can run multiple comaands concurrently. After this is installed, you can set up your NPM start script (in package.json file) to run multiple commands by spearating each individual command with quotes. You can reference this article to learn more 4 Solutions to Run Multiple Node.js or NPM commands Simultaneously
    • cors stands for Cross-origin resource sharing, it allows AJAX requests to skip the Same-origin police and access resources from remote hosts. The cors package provides an Express middleware that can enable CORS with different options.
    • detenv loads environment variables from a .env file into process.env. This makes developmenet simpler. Instead of setting environment variables on our app, they can be stored in a file, it is .env file.

Treaps ?! - Part II

Treap = Tree + Heap

As suggested by name, Treap is the combination of Tree and Heap. Teap is a Self-balancing Binary Search Tree or a Randomized Binary Search Tree.


Treaps ?! - Part 1

What is Treaps?

In short, Treap is simply a Self-balancing binary search tree., but of course, much cooler.


Note of binary tree traverse and sorting algorithms


Experience of solving the Count Triplets coding challenge in JavaScript

This post is inspired by How to solve the Sherlock and Anagrams coding challenge in JavaScript by Mihail Gaberov. I would like to share my experience about how to construct my thoughts, and optimized my code to pass the time constraints. This coding challenge is called β€œCount Triplets.”