Skip to content

Instantly share code, notes, and snippets.

View gpDA's full-sized avatar
🏠
Working from home

GP LEE gpDA

🏠
Working from home
View GitHub Profile
// recursion
const recursiveSumInteger = (number) => {
if (number === 0) {
return 0;
}
return number + recursiveSumInteger(number - 1);
}
// recursion 1 - using helper function
const RecursiveHelperSumArr = (arr) => {
let index = arr.length - 1;
// helper function
const recur = (curIndex, sum) => {
sum += arr[curIndex];
if (curIndex === 0) return sum;
return recur(curIndex - 1, sum); // decrement the index and recursion
}
// recursive
const recursiveOddOrEven = (number) => {
if (number === 0) {
return true;
} else if (number === 1) {
return false;
} else {
return recursiveOddOrEven(number - 2);
}
}
// Things to go over
// 1 - mongodb (mongoose ORM) list of strings & default
// 2 - router middleware (koa)
// 3 - CRUD (with simple validation) write / read /remove / update
////\\\\
// models/post.js
////\\\\
const mongoose = require('mongoose');
// things to go over
// 1 - IntersectionObserver why it is being loaded (rendering 20 players at a time vs. lazy loading)
// 2 - lazy loading using `lazy` classname
async componentDidMount() {
this.handleScroll();
}
handleScroll = () => {
const lazys = document.querySelectorAll('.lazy');
// want to go over
// 1 - use of functional components
// 2 - dynamic component `component :is`
<template functional>
<header
:class="[
`${props.blockName}__text-head`,
{'gls-download-content__text-head--no-msg':
props.blockName === 'gls-download-content' && !props.commentMessage}]"
>
<docs>
- share-success-root-wrapper
-- This class is to hide custom blur overflow from overlay-scrollbars modal
</docs>
// want to go over
// 1 - use of overlay-scrollbars
// 2 - use of `named slot`
// 3 - dynamic classname
// 4 - native SVG components
// chunkUpload
// uniformChunkRequest
// partialChunkRequest
// chunkRequestHelper
// want to go over
// 1 - uniform & partial upload (why there are 2 different functions)
// 2 - use of `chunkRequestHelper` function to send headers & body (formData)
// 3 - chunkStar & chunkEnd - how it's being calculated `chunkStart + CHUNK_SIZE > fileClone.size`
// want to go over
// 1 - use fo constants
// 2 - cancelToken
// 3 - progress upload + how `numberOfRequests` is being used to represent the multiple requests
// 4 - `uploadFileResponseHelper` & `uploadFileErrorHelper` helper functions
// constants/file.constants.js
const CHUNK_SIZE = 1000 * 1000 * 100; // 100mb
// ASSUMPTION
// text files will be placed in the same directory as the program file
// Question
// is the word case-insensitive? not specified in the problem statement
// so in the code below, I take care of each words as case-insensitive e.g.) so & So are the same words
// HOW TO RUN PROGRAM
// node <file_name> <sampleFile> <commonFile>
// for example, node test.js alice_in_wonderland.txt 1-1000.txt