Skip to content

Instantly share code, notes, and snippets.

@IAmAnubhavSaini
IAmAnubhavSaini / course-schedule.js
Created March 21, 2024 05:48
207. Course schedule
"use strict";
class Graph {
#InitialCourses;
constructor(edges) {
this.E = new Map();
this.V = new Set();
this.I = new Map();
this.#InitialCourses = [];
if (edges.length === 0) {
return;
@IAmAnubhavSaini
IAmAnubhavSaini / bipartite_matching.js
Created March 21, 2024 01:48
interviews be like...
class Graph {
constructor(edgesArray) {
this.V = new Set();
this.E = {};
if(edgesArray.length === 0) {
return this;
}
edgesArray.forEach(edge => {
@IAmAnubhavSaini
IAmAnubhavSaini / multiply-strings.js
Created March 18, 2024 20:24
Big strings multiplication
/**
* @param {string} num1
* @param {string} num2
* @return {string}
*/
var multiply = function(num1, num2) {
if(num1 === "0" || num2 === "0") {
return "0";
}
const numbers = Array.from({length: num2.length}, _ => "0");
@IAmAnubhavSaini
IAmAnubhavSaini / future.js
Created March 18, 2024 16:39
generatePairs and Future
class Future {
#value = null;
#error = null;
#successCallbacks = [];
#failureCallback = () => {}
#finalCallback = () => {}
constructor(fn) {
const onSuccess = (value) => {
this.#value = value;
@IAmAnubhavSaini
IAmAnubhavSaini / 36.valid-sudoku.js
Created August 31, 2023 06:18
36. valid sudoku
/**
* @param {character[][]} board
* @return {boolean}
*/
var isValidSudoku = function(board) {
toString(board);
const len = board.length;
let valid = true;
for(let i = 0; i < len && valid; i++) {
valid = valid && isValidRow(board, i) && isValidColumn(board, i);
@IAmAnubhavSaini
IAmAnubhavSaini / bash_strict_mode.md
Last active January 2, 2023 13:43 — forked from mohanpedala/bash_strict_mode.md
bash_strict_mode

Quick

#!/usr/bin/env bash

set -euxo pipefail
IFS=$'\n\t'

set -euxo pipefail

@IAmAnubhavSaini
IAmAnubhavSaini / the-algebra-of-algebraic-data-types.md
Created September 17, 2022 10:19 — forked from gregberns/the-algebra-of-algebraic-data-types.md
The Algebra of Algebraic Data Types, Part 1, by Chris Taylor
@IAmAnubhavSaini
IAmAnubhavSaini / profiling-in-react.md
Created April 6, 2022 03:42 — forked from bvaughn/index.md
How to use profiling in production mode for react-dom

React recently introduced an experimental profiler API. This page gives instructions on how to use this API in a production release of your app.

Table of Contents

Profiling in production

React DOM automatically supports profiling in development mode for v16.5+, but since profiling adds some small additional overhead it is opt-in for production mode. This gist explains how to opt-in.

Update 28 July 2019: An updated version of this guide for Ubuntu Server 18.04 LTS is now available. Feel free to check it out.

Update 23 May 2020: This guide is ALREADY OUTDATED and might no longer work with new versions of Ubuntu and VirtualBox. Please consider switching to the updated guide instead. I will no longer respond to the replies to this gist. Thank you.

Mounting VirtualBox shared folders on Ubuntu Server 16.04 LTS

This guide will walk you through steps on how to setup a VirtualBox shared folder inside your Ubuntu Server guest. Tested on Ubuntu Server 16.04.3 LTS (Xenial Xerus)

@IAmAnubhavSaini
IAmAnubhavSaini / deleteQuickly.browser.script.js
Created August 21, 2021 17:59
Delete github repo on security page
(function deleteQuickly() {
var t = document.querySelector('details.flex-md-order-1 > details-dialog:nth-child(2) > div:nth-child(3) > p:nth-child(2) > strong:nth-child(1)').innerText
document.querySelector('details.flex-md-order-1 > details-dialog:nth-child(2) > div:nth-child(3) > form:nth-child(3) > p:nth-child(3) > input:nth-child(1)').value = t
document.querySelector('button.btn-danger:nth-child(4)').disabled = false
document.querySelector('button.btn-danger:nth-child(4)').click()
})()