/images/art2.png

All String Method in Javascript

Show all function: Try String.prototype & String in browser console. fromCharCode 1 2 console.log(String.fromCharCode(189, 43, 190, 61)); // expected output: "½+¾=" fromCodePoint 1 2 console.log(String.fromCodePoint(9731, 9733, 9842, 0x2f804)); // expected output: "☃★♲你" raw 1 2 3 4 5 6 // Create a variable that uses a Windows // path without escaping the backslashes: const filePath = String.raw`C:\Development\profile\aboutme.html`; console.log(`The file was uploaded from: ${filePath}`); // expected output: "The file was uploaded from: C:\Development\profile\aboutme.

All array method in Javascript

Show all function: Try Array.prototype & Array in browser console. foreach 1 2 3 4 5 6 7 8 9 10 let numbers = [1, 2, 3, 4, 5]; // each element in a func numbers.forEach((element, index, arr) => { console.log(`a[${index}] = ${element}`); }); // a[0] = 1 // a[1] = 2 // a[2] = 3 // a[3] = 4 // a[4] = 5 map 1 2 3 4 5 6 7 let numbers = [1, 2, 3, 4, 5]; // [] => [] (some size) let numbers2 = numbers.

Express Overview

Express.js is a web framework for Node.js Example 1 2 3 4 5 6 7 8 9 10 11 12 13 14 const express = require('express'); const app = express(); app.use(...); // get and post or middle ware app.get('/', (req, res) => { return res.send({hello:"world"}); }) const PORT = 4000; app.listen(PORT, ()=> { console.log(`Server is ready on http://localhost:${PORT}`); })

How to demonstrate your front end application on Github by gh-page

Github provide a tech called github pages that can hosted your project directly from repository. Basely push you project into gh-pages branch and the index.html will show on the page which is {<github username>.github.io}/{<repository name>} gh-pages gh-pages provide by Tim Schaub is a npm package that can help you push something directly into gh-page branch Read more detail in repository command line usage This package also provide a command line tool:

CSS Overview

CSS cheat sheet: html & css provided by Traversy Media Font font-size size font-family: <FAMILY_NAME>, <GENERIC_NAME>; font-family: Lobster monospace; GENERIC_NAME: sans-serif serif monospace; sans-serif force on connected and serif force on single alphabet. line-height: 25px; Import font Could use google font and add link into index.html or in style.css Control space There are three important properties to control the space: padding, margin and border Border border-size border-color border-width border-style border: <border-width> <border-style> <border-color>

Basic Terminal command

Basic cd route ls list pwd show current path cat concatenate and print file (usually as read file) touch change file access and modification time; (usually as create file) Routing cd <directory> cd . current cd .. last cd ~ home cd / root List ls ls -a list all included hiding file ls -l list detail Move & Copy cp <name1> <name2> copy mv <name1> <name2> rename move one file within this directory to another name.

How to check the Chinese ID is correct

This check method will help you find out whether one digit is wrong or 2 adjacent digit are in reverse order. Sample code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 checkChineseId = (id) => { const ID_LENGTH = 18; // check type if (typeof id !

Structured binding

Structured binding is a new feature since c++17 cppreference.com auto [ identifier-list ] = expression Bind array 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 int main(int argc, char const *argv[]) { int test[3] = {1, 2, 3}; auto [a, b, c] = test; // an new array e copy from test and a = e[0]; b = e[1]; c = e[2]; auto &[x, y, z] = test; // x = test[0]; x = test[1]; x = test[2] cout << ++a << " " << ++b << " " << ++c << " " << endl; for (int &i : test) cout << i << " "; cout << endl; cout << ++x << " " << ++y << " " << ++z << " " << endl; for (int &i : test) cout << i << " "; cout << endl; return 0; } tuple 1 2 3 4 5 6 7 8 9 10 11 12 int main(int argc, char const *argv[]) { tuple<int, int, int> test(1, 2, 3); auto &[a, b, c] = test; // 1 2 3 pair<int, char> test2(1, 'c'); auto &[a2, b2] = test2; // 1 c return 0; } struct 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 struct test { int a; int b; }; int main(int argc, char const *argv[]) { test one; one.

Traverse a tree

Idea to traverse a tree Tree structure The tree structure: 1 2 3 4 5 6 struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; BFS DFS Pre-order In-order Post-order Relationship: Iterative Loop for BFS: 1 2 3 4 5 6 7 8 9 10 11 void BFS(TreeNode *root){ stack<TreeNode *> q; q.push(root); while(!q.empty()){ TreeNode *temp = q.front(); q.pop(); // do something if(temp->left !

How to find next permutation

This is introduce how to find the next lexicographically permutation. Suppose the permutation is 1 2 3. The next one is 1 3 2. Algorithm in C++ C++ provide an algorithm called next_permutation to support that. Reference Example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #include <iostream> // std::cout #include <algorithm> // std::next_permutation, std::sort int main () { int myints[] = {1,2,3}; std::sort (myints,myints+3); std::cout << "The 3!