API
API123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354const express = require("express");const app = express();const bodyParser = require("body-parser");const https = require("https"); // it's a native node module so we dont need to use npm installapp.use(bodyParser.urlencoded({ extended: true }));app.get("/", function (req, res) { res.sendFile(__dirname + "/index.html");}) ...
Overview
npm i -y
npm i dotenv express hbs mysql
npm i –save nodemon
Double-check that your package.json file has the “scripts” section defined with the “start” script. It should look like this:
123"scripts": { "start": "nodemon app.js"}
you run npm start in terminal.
cannot start mysql in xamppThe most likely reason that XAMPP’s MySQL service is unable to start is because port 3306 is already used by a different program that is currently running on your comput ...
EJS
EJS(Embedded JavaScript templates)GET STARTED1.
1npm install ejs
2.
https://github.com/mde/ejs/wiki/Using-EJS-with-Express
In Express v4, a very basic setup using EJS would look like the following. (This assumes a views directory containing an index.ejs page.)
12345678910let express = require('express');let app = express();app.set('view engine', 'ejs'); // TELL APP TO USE EJSapp.get('/', (req, res) => { res.render('index', {fo ...
Bootstrap
Bootstraplayout
using bootstrap will make you have a lot of classes in tags which is called class bloat
On pc, two columns, on mobile, 1 colum
1234<div class="row"> <div class="col-xl-6 col-sm-12">50% desktop, 100% mobile</div> <div class="col-xl-6 col-sm-12">50% desktop, 100% mobile</div></div>
actually you can delete col-sm-12 ,cause everything else is defaulted to 100 percent.
xl-> pc
sm-> phone
https://appbrewer ...
Git
Local Git Repository
remember to run in git bash
mkdir foldername
touch filename
code filename (open the file)
1234567891011121314151617181920212223242526// intialize a git repositorygit init // see what's in staging area// it can also help to see which file has been modified after last commitgit status// add file to staging areagit add chapter1.txtgit add .// remove from staging areagit rm --cached -r filename// commit the filesgit commit -m "test"// see what's been commite ...
jQuery
jQuerya library. make js a lot easier. jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code.
1eg. document.querySelector("h1") = $("h1")
Incorporate jQuery1234567<body> . . . <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> //this one is from the website, copy the link <script s ...
Overview
Node.jsNode.js is a server-side runtime environment for running JavaScript code outside the browser, while React.js is a client-side JavaScript library for building user interfaces. Node.js is used for server-side development, while React.js is used for creating interactive UI components in web applications. They can be used together to build full-stack web applications.
Node.js is perfect for building fast and scalable data intensive apps.
use: API with database behind(preferably NoSQL)
don’t u ...
NodeJS
Node.jsIt’s an asynchronous event driven JavaScript Runtime. it’s designed to build scalable network applications.
it’s actually not a framework, instead it’s a runtime environment. it enables us to use javescript on a computer and not just limited to wihtin the browser.
Express, on the other hand is actually a javascript framework that allow us to create backend for our websties.fs moduleintroductionIn JavaScript, the term “fs” typically refers to the “File System” module. The “fs” module is ...
frontend
ctrl + tilde character –> launch the terminal window from within VS Code.
npx create-react-app <NAME>–> When you run the npx create-react-app <NAME> command, it will create a new directory with the name <NAME> in the current directory and set up the basic structure of a React project inside that directory. The resulting project will include all the necessary files and dependencies to start building a React application.
code .—>is a command that opens the current direct ...
Graph
Graph 🌼foundation:https://github.com/youngyangyang04/leetcode-master/blob/master/problems/%E5%9B%BE%E8%AE%BA%E6%B7%B1%E6%90%9C%E7%90%86%E8%AE%BA%E5%9F%BA%E7%A1%80.md
dfs是可一个方向去搜,不到黄河不回头,直到遇到绝境了,搜不下去了,再换方向(换方向的过程就涉及到了回溯)。
bfs是先把本节点所连接的所有节点遍历一遍,走到下一个节点的时候,再把连接节点的所有节点遍历一遍,搜索方向更像是广度,四面八方的搜索过程。
797. All Paths From Source to TargetMedium
Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1 and return them in any order.
The graph ...