Skip to content

Instantly share code, notes, and snippets.

View navjotahuja92's full-sized avatar
🎖️

Navjot Ahuja navjotahuja92

🎖️
View GitHub Profile
@navjotahuja92
navjotahuja92 / setup.ts
Last active February 2, 2024 15:11
Nest.js Test Setup with In Memory Postgres Database (pg-mem)
// Install npm i pg-mem --save-dev
import { DataSource, Repository } from 'typeorm';
import { newDb, DataType } from 'pg-mem';
import { v4 } from 'uuid';
const setupDataSource = async () => {
const db = newDb({
autoCreateForeignKeyIndices: true,
});
@navjotahuja92
navjotahuja92 / disjointSet.js
Created March 13, 2018 18:36 — forked from peterkhayes/disjointSet.js
Javascript Disjoint Set
/*
Useful for HackerRank problems.
*/
function main (numNodes, edges) {
const parent = [];
const rank = [];
function makeSet (x) {
@navjotahuja92
navjotahuja92 / introrx.md
Created February 19, 2017 14:38 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@navjotahuja92
navjotahuja92 / ssyoutube.js
Last active August 26, 2016 06:54
Collect all links from youtube playlist for ssyoutube
var videoNodesArray = document.getElementsByClassName('pl-video-title-link');
videoNodesArray = [].slice.call(videoNodesArray);
var ssYoutubeUrlArray = videoNodesArray.map(function(videoNode) {
var httpStr = videoNode.href.replace('https', 'http');
httpStr = httpStr.replace('you', 'ssyou');
console.log(httpStr);
return httpStr;
})
ssYoutubeUrlArray.forEach(function(ssYoutubeUrl) {
window.open(ssYoutubeUrl);