Skip to content

Instantly share code, notes, and snippets.

View pujitm's full-sized avatar

Pujit Mehrotra pujitm

View GitHub Profile
@pujitm
pujitm / extract_plg_entity.sh
Created July 11, 2025 16:37
Extract `ENTITY` values from Unraid Plugin manifests
#!/bin/bash
# Script to extract entity values from PLG (Plugin) files via URL or local file path
#
# PLG files are XML files used by Unraid to define plugins. They contain entity
# definitions in the DOCTYPE section, like: <!ENTITY name "value">
#
# Usage: ./extract_plg_entity.sh [--verbose] [--preview] <entity_name> [url_or_file_path]
#
# Examples:
@pujitm
pujitm / compare_directories.py
Created June 24, 2025 21:19
Compare & diff the contents of two directories
#!/usr/bin/env python3
# Note: AI-generated
"""
Directory comparison script that recursively compares two directories
and shows files that exist in one but not the other, plus diffs for common files.
"""
import os
import sys
import subprocess
@pujitm
pujitm / rc.unraid-api.sh
Created April 9, 2025 18:48
How to mask "Ignored build scripts" warning message from pnpm
# Executes pnpm install with production dependencies and offline preference
# Captures and logs build script warnings to a dedicated log file at /var/log/unraid-api/build-scripts.log
# Args: none
# Output: Streams install progress and logs build script warnings
run_pnpm_install() {
local log_file="/var/log/unraid-api/build-scripts.log"
stdbuf -oL pnpm install --prod --offline --reporter=append-only 2>&1 | sed -e "/^╭ Warning/,/^╰/w $log_file" -e "/^╭ Warning/,/^╰/c\Build scripts completed. See $log_file for details."
echo "Note: This warning is expected. Build scripts are intentionally ignored for security and performance reasons." >> "$log_file"
}
@pujitm
pujitm / Thirty Percent Feedback.md
Created February 10, 2024 20:05 — forked from ezl/Thirty Percent Feedback.md
Thirty Percent Feedback by Jason Freedman (42 Floors)

Thirty Percent Feedback

By Jason Freedman in Startups and Uncategorized on February, 26, 2014 Source: https://42floors.com/blog/startups/thirty-percent-feedback (Copied in case this resource disappears)


I remember showing school essays to my dad growing up. He’s a really good writer and so getting his feedback before I turned a paper in usually helped me make some improvements. But whenever I’d watch him reading over the pages, I would secretly be hoping he’d read it and say that everything is perfect. I obviously thought it was already perfect, otherwise I wouldn’t have shown it to him.

@pujitm
pujitm / gordons-algo.py
Created January 24, 2019 16:15
Gordon's Basic Hashing Algorithm Implementation
import sys
# Gordon's Basic Hashing Algorithm
# Professor Steven Gordon - MIS3560-01
# Usage
#
# [A]: Replace `mString` at the bottom of this file and run this script without any arguments
# [B]: Run this script with an argument in quotes. See the example below.
# $> python ./gordons-algo.py "custom text"
@pujitm
pujitm / loc_login.py
Created December 31, 2018 18:47
Library of Congress login script
from selenium import webdriver
import json
# A script for logging into the Library of Congress Website (to facilitate use after session expiration)
# Requires Selenium module + Browser Driver in PATH (This script uses Chrome)
# The following element id's are up-to-date as of 12-31-2018
element_id = {
"last_name": "last-name", # Field for Last Name
@pujitm
pujitm / user_privacy.ts
Last active January 13, 2024 19:07
TypeScript Cloud Functions for User Privacy on Firebase
/**
* Message from Editor:
* This is the TypeScript translation of `functions/index.js` in the User Privacy Firebase repo.
* [https://github.com/firebase/user-privacy]
* The License has not been altered.
*/
/**
* Copyright 2017 Google Inc. All Rights Reserved.
*
@pujitm
pujitm / StringComparisonTest.java
Created March 7, 2018 16:26
My test for a boolean expression I found in production code. Surprisingly, this test passes!
public class StringComparisonTest {
//JUnit 4 Test
@Test
public void test() {
assert(wtf());
}
private boolean wtf() {
String empty = "";