Skip to content

Instantly share code, notes, and snippets.

View sharmaeklavya2's full-sized avatar
๐Ÿ“š
Not coding actively anymore. Doing math instead.

Eklavya Sharma sharmaeklavya2

๐Ÿ“š
Not coding actively anymore. Doing math instead.
View GitHub Profile
@sharmaeklavya2
sharmaeklavya2 / get_gists.py
Created May 17, 2026 00:39
Fetch all public gists for a GitHub username
#!/usr/bin/env python3
"""
Fetch all public gists for a GitHub username.
"""
import sys
import argparse
import json
import urllib.request
from collections.abc import Mapping, Sequence
@sharmaeklavya2
sharmaeklavya2 / buildTex.py
Last active May 12, 2026 04:03
Build a latex project by repeatedly calling pdflatex
#!/usr/bin/env python
import os
import sys
import shlex
import shutil
import argparse
import subprocess
DEFAULT_REPS = 2
@sharmaeklavya2
sharmaeklavya2 / makeBibdb.py
Last active May 8, 2026 01:27
Implement \citet by reading the .bib file using a python script
#!/usr/bin/env python3
"""
Reads references.bib and creates a file called bibdb.tex, containing manually parsed bibtex data.
This data is used to implement a custom \\citet command.
bibdb.tex will contain one line per citation entry, each of this format: '\\regCitation{key}{authors}'.
Here 'authors' is a shortened et al format, suitable for use in citation.
"""
import os
@sharmaeklavya2
sharmaeklavya2 / extref.tex
Created January 31, 2026 08:31
extref.tex: useful for mocking and appendectomies
% syntax: \extRefReg{label}{type}{id}
\newcommand*{\extRefReg}[3]{%
\expandafter\def\csname extref-type:#1\endcsname{#2}%
\expandafter\def\csname extref-id:#1\endcsname{#3}%
}
\newif\ifUseExtRef
\let\extRefOn\UseExtReftrue
\let\extRefOff\UseExtReffalse
@sharmaeklavya2
sharmaeklavya2 / ekubib.js
Created December 11, 2025 21:48
custom Zotero translator
{
"translatorID": "e26cad9e-c9c3-438b-bbab-ea9a3353c3f7",
"label": "ekubib",
"creator": "Eklavya Sharma",
"target": "bib",
"minVersion": "2.1.9",
"maxVersion": "",
"priority": 200,
"configOptions": {
"async": true,
@sharmaeklavya2
sharmaeklavya2 / test.py
Created December 11, 2025 03:15
WEF1 with code2dtree
#!/usr/bin/env python3
import unittest
import wef1
class EnumerationTest(unittest.TestCase):
def testOrderings(self) -> None:
orderings = list(wef1.findAllOrderingsHelper(3, 2, []))
self.assertEqual(orderings, [
@sharmaeklavya2
sharmaeklavya2 / style.css
Last active December 6, 2025 18:48
nginx autoindex injected CSS
/* color scheme */
body {
--bg-color: white; --text-color: #202020; --link-color: #1a0dab; --vlink-color: #681da8; --tint: rgba(128,128,128,0.2);
}
@media (prefers-color-scheme: dark) {
body {
--bg-color: #1b1e20; --text-color: #c8c8c8; --link-color: #8ab4f8; --vlink-color: #c58af9;
}
}
@sharmaeklavya2
sharmaeklavya2 / bibtex.js
Created July 8, 2025 04:41
My Zotero export translator for BibTeX
// See https://www.zotero.org/support/dev/translators
var zotero2bibtexTypeMap = {
"book": "book",
"bookSection": "incollection",
"journalArticle": "article",
"magazineArticle": "article",
"newspaperArticle": "article",
"thesis": "phdthesis",
"letter": "misc",
@sharmaeklavya2
sharmaeklavya2 / compress-photos.py
Created June 20, 2025 02:35
Recursively compress pictures
#!/usr/bin/env python3
"""
Compresses all photos in a directory recursively.
Outputs a new directory tree instead of replacing original photos.
Tools 'djpeg', 'moz-cjpeg', and 'exiftool' must be installed.
"""
import sys
import argparse
@sharmaeklavya2
sharmaeklavya2 / lptTightApprox.py
Last active April 7, 2025 01:51
Use code2dtree to find the tight approximation factor for the LPT algorithm for makespan minimization
#!/usr/bin/env python3
"""
Uses code2dtree (https://github.com/sharmaeklavya2/code2dtree) to find
the tight approximation factor of the LPT algorithm for makespan minimization
for a given number of jobs and machines.
Specifically, for every possible scenario, we find out the maximum load
a machine in the LPT schedule can have if the optimal makespan is at most 1.