Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Always Curious!

That Js Dev nishantmendiratta

🎯
Always Curious!
View GitHub Profile
@nishantmendiratta
nishantmendiratta / random.sh
Created May 4, 2022 — forked from biaocy/random.sh
linux generate 32 length alphanumeric string
View random.sh
cat /dev/urandom | tr -cd 'a-zA-Z0-9' | fold -w 32 | head -n 1
@nishantmendiratta
nishantmendiratta / Time To Get Back To The Basics - How Browser Reads HTML, CSS, and JavaScript.md
Last active Feb 6, 2022
📖 Getting Back To The Basics - How Browser Reads HTML, CSS, and JavaScript?
View Time To Get Back To The Basics - How Browser Reads HTML, CSS, and JavaScript.md

What happens when a browser loads a website?

  1. It fetches the HTML page (index.html)
  2. Begin parsing the HTML
  3. The parser encounters a <script> tag referencing an external script file.
  4. The browser requests the script file. Meanwhile, the parser blocks and stops parsing the other HTML on your page.
  5. After some time the script is downloaded and subsequently executed.
  6. The parser continues parsing the rest of the HTML document.

(Step 4) It causes a bad user experience. Your website basically stops loading until you've downloaded all scripts. If there's one thing that users hate it's waiting for a website to load.

View two-sum.md
  1. Brute force solution twoSumExpensive. Select every element and find the remainder after that iterate over the array to check if remainder exists in the remaining array or note.

  2. Better solution using the Hash table. Iterate over all elements and check if the remainder is present in hash table or not if not set the number and it's index using map[nums[i]] = i

// https://leetcode.com/problems/two-sum/
// https://www.youtube.com/watch?v=dRUpbt8vHpo&list=PLgUwDviBIf0rVwua0kKYlsS_ik_1lyVK_&index=2
#include<iostream>
View 3 Catchy Open-Source Projects.md

One of the reasons why I like javascript is because you can build and validate any kinda idea in no time.

The community is huge and generous enough that it has open-sourced tons of complex projects.

First off, I would like to thank all the open-source contributors who are making the world a better place. I hope you would be able to use some of the following resources and return the favor by contributing to our open-source community. Cheers to these unsung heroes!

As a curious software engineer, I'm always looking for the open-sourced alternatives of popular solutions. This post covers opensource alternatives of Notion, Google docs & Grammarly.

Also, don't expect that you will get a complete solution for free. These opensource projects may not have the exact functionality and tons of features but they do cover the basic idea of the product.

View Algorithms > Sorting > Quick Sort.md

QuickSort is a divide and conquer algorith. It picks an element as a pivot and partition the given array around the picked pivot.

This key process in quickSort is partion(). Target of partion is, given an array and an element of array x as pivot, put x at its correct position in sorted array and put all smaller elements (smaller than x) before x, and put all greater elements (greater than x) after x. All this should be done in linear time.

#include <iostream>
#include <algorithm>
using namespace std;
View Algorithms > Sorting > Merge Sort.md

Merge sort is divide and conquer algorithm. It divides input array in two halves, calls itself for the two halves and then merge the two sorted sub-arrays.

#include <iostream> 
using namespace std;

/* UTILITY FUNCTIONS */
/* Function to print an array */
void printArray(int *A, int size) { 
View Algorithms > Sorting > Bubble Sort.md

Bubble sort works by repeatedly swapping the adjacent elements if they are in wrong order

int main() {
    int temp;
    int arr[] = {3, 2, 1, 4, 10, 6, 0};
    int n= 7;
    
    for (int i=0; i<n-1; i++){
 for (int j = 0; j &lt; n-i-1; j++) {
View Algorithms > Sorting > Selection Sort.md

The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning. The algorithm maintains two subarrays in a given array.

  1. Sub-array which is already sorted.
  2. Remaining subarray which is unsorted. In every iteration of selection sort, the minimum element (considering ascending order) from the unsorted is picked and moved to the sorted subarray.
#include <iostream>
using namespace std;
@nishantmendiratta
nishantmendiratta / ThatJsDev's Speed Analysis (Lighthouse).md
Last active Jun 20, 2020
ThatJsDev's Speed Analysis (Lighthouse)
View ThatJsDev's Speed Analysis (Lighthouse).md

TL;DR: it took about half a day to go from an abysmal 48 to a 100 Lighthouse score on my Nuxt.js blog.

ThatJsDev - Site Speed Analysis

Since launch, I haven't paid much attention to the performance of my blog. I read this article by Addy Osmani which explains why website performance is important. How important is the role of javascript in the page rendering cycle? If you want to know The Cost of Javascrip - Read this article

In short, this article includes some best practices to reduce estimated input latency and improve the performance of the site. You will also find 3 crucial tips to keep in mind while using nuxt framework. Want to learn how the webpage is read by the browser?. Read my post titled ["Getting Back To The Basics - How Browser Reads HTML, CSS, and JavaScript?"](https

@nishantmendiratta
nishantmendiratta / Can you beat ACP Pradyuman in this case?.md
Last active Jun 9, 2020
🦸 Can you beat ACP Pradyuman in this case?
View Can you beat ACP Pradyuman in this case?.md

WhatsApp Image 2020-06-05 at 9 21 48 PM

Most of you know that I'm not a storyteller. If you don't know my profession, I would strongly recommend looking into the IG-Bio [trust me first-cry, blowing candle जैसी vulgar बातों में से कुछ नहीं है उसमें]. Anyway, since we are talking about the profession, I hope you are familiar with this guy in this picture.

If you don't remember, this guy is ACP Pradyuman, and let me remind you CID was one of the Most Ridiculous TV Shows. These are not my words, this is something I read over the weekend. CID had supernatural powers. Why? -- BC they are the only humans capable of capturing infra-red radiations with swimming goggles, magnifying pictures thousands of times without ruining their resolution, and slapping criminals so hard that they immediately end up in the CID bureau. Moreover, these guys can find the supplier of