Skip to content

Instantly share code, notes, and snippets.


Mohit Sharma mohitsharma93

  • indore
View GitHub Profile
View node-basic-scrape.js
const scrape = require('website-scraper');
const websiteUrl = 'Website url you want to scrap';
urls: [websiteUrl],
urlFilter: function (url) {
return url.indexOf(websiteUrl) === 0;
recursive: true,
maxDepth: 50,
mohitsharma93 / timer-component.html
Last active Dec 21, 2020
angular timer with rxjs
View timer-component.html
<h2>{{remainingSeconds$ | async}}<>
mohitsharma93 / object-to-formData.ts
Last active Dec 27, 2020
convert object to formData
View object-to-formData.ts
public objectToFormData(request) {
// create form data
const newPostRequest: FormData = new FormData();
Object.keys(request).forEach(x => {
newPostRequest.append(x, request[x]);
return newPostRequest;
mohitsharma93 / app-routing.module.ts
Last active Apr 23, 2021
update a page title statically(Angular)
View app-routing.module.ts
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
const routes: Routes = [{
path: 'home',
component: HomeComponent,
children: [
{ path: '', redirectTo: 'email', pathMatch: 'full', data: { title: 'Email' } },
{ path: 'email', component: EmailListComponent },
mohitsharma93 / singleLinkedList.js
Created May 8, 2021
single linked list in JavaScript
View singleLinkedList.js
* linked list is a linear data structure similar to an array. However, unlike arrays,
* elements are not stored in a particular memory location or index. Rather each element is a separate
* object that contains a pointer or a link to the next object in that list.
* for ex: head--> [D, reference to next] [D, reference to next] [D, null] --> tail
* D belongs to data.
* The head is a reference to the first node in the linked list.
* The last node on the list points to null. If a list is empty, the head is a null reference
mohitsharma93 / remove.empty.js
Created May 5, 2021
remove all empty value and empty object from object(for nested objects).
View remove.empty.js
* Recurcively remove empty value, empty object.
* you can add more checks on line 12 as per your requirments
function removeEmpty(data) {
return Object.keys(data).reduce((accumulator, key) => {
const isObject = typeof data[key] === 'object';
const isDateTime = key === 'from_date_time' || key === 'to_date_time';
const value = isObject ? this.removeEmpty(data[key]) : data[key];
mohitsharma93 / Stack.js
Last active May 8, 2021
JavaScript presentation of stack data structure
View Stack.js
* A stack is useful when we want to add data in sequential order and remove data. Based on its definition,
* a stack can remove only the most recently added data.
* stack is work on LAST IN FIRST OUT principle.
* stack is just like array with only capabilities of push and pop (method).
* [6] ----> which is last element of stack
* [5]
* [4]
* [3]
mohitsharma93 / Queue.js
Last active May 8, 2021
JavaScript presentation of queue data structure
View Queue.js
* A queue can remove only the most recently added value, what if we need to remove old value. here comes another
* data structure QUEUE.
* queue is work on FIRST IN FIRST OUT
* queue is work on LAST IN FIRST OUT principle.
* queue is just like array with only capabilities of push and pop (method).
* [6]
* [5]
* [4]
mohitsharma93 / debounce.js
Last active Sep 26, 2022
debounce is decorator wrapper that suspends calls to f until there’s ms milliseconds of inactivity
View debounce.js
* use this function if you want to call other function after some
* time(provided by you in ms parameter) with latest arguments.
* Basically it delay our functino call by given MS(milliseconds).
function debounce(fun,ms) {
let time; // storing timer returned by setTimeout api.
return function() {
clearTimeout(time); // clear timer on each time of function call.
time = setTimeout(() => fun(...arguments), ms)