Skip to content

Instantly share code, notes, and snippets.

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

Nishant Kumar lastbyte

🏠
Working from home
View GitHub Profile
@lastbyte
lastbyte / dsu.py
Created April 29, 2026 12:06
Prims MST
class DSU:
def __init__(self, nodes : int):
self.sizes = [1] * nodes
self.parent = [i for i in range(nodes)]
def find(self, node : int) -> int:
if node != self.parent[node]:
node = self.find(self.parent[node])
return self.parent[node]
const puppeteer = require('puppeteer');
const XLSX = require('xlsx');
const { NetworkConditions } = puppeteer;
async function measureRequestTime(url, jsFileName, numberOfRuns, bandwidthMbps) {
const timings = [];
const networkConditions = {
// Convert Mbps to bytes/second
downloadThroughput: bandwidthMbps * 125000,
uploadThroughput: bandwidthMbps * 125000,
@lastbyte
lastbyte / utility.ts
Last active October 6, 2023 14:38
Typescript one liners
class Strings {
static reverse(str: string): string {
if (str === null || str === undefined)
throw new Error("empty or invalid string");
return str.split("").reverse().join("");
}
static trimLeft(str: string): string {
if (str === null || str === undefined)
const htmlString = `<div class="text" style="height : 10 ; width : 60;">
<div class="text" style="background : red;height : 10 ; width : 60;">
<div class="text" style="background : red;height : 10 ; width : 60;"></div></div></div>`
const div = document.createElement('div');
div.innerHTML = htmlString;
const getSelector = (root : HTMLElement, index: number) => {
@lastbyte
lastbyte / language.java
Created April 22, 2019 08:53
java, language
a