Skip to content

Instantly share code, notes, and snippets.

View sohang3112's full-sized avatar
:octocat:

Sohang Chopra sohang3112

:octocat:
View GitHub Profile
@sohang3112
sohang3112 / zed_editor_notes.md
Last active July 4, 2026 10:52
Zed Editor (which is written in Rust)

Zed Editor NOTES

Tried Zed 1.7.2 on Ubuntu 26.04 .

Disabled AI completion in Markdown .md files because of useless completions (especially putting nonsensical paths while writing image links), by putting this in Zed Settings JSON file (source: zed-industries/zed#59727) :

"edit_predictions": {
  "provider": "copilot",        // Github Copilot
 "mode": "eager",

Machine Learning Notes

ML Concepts

  • Dealing with Missing Values: For dealing with missing values in some columns of training data, one approach is to just drop the columns having missing values. But this is not recommended because the column could have important information. Instead a better approach is to fill in missing values with the column's average using sklearn.impute.SimpleImputer.

  • Dealing with Categorical Data: Categorical data are like Enums - they have one of a fixed set of values (eg. male, female, other). 2 approaches:

@sohang3112
sohang3112 / terminal_show_links.py
Created March 2, 2026 04:17
Show web url-like behaviour in terminal using ANSI escape codes
@sohang3112
sohang3112 / tee.py
Created January 27, 2026 15:27
Implementing tee() function of itertools
def tee(it):
it = iter(it)
cache = []
counts = [0,0]
class _Iterator:
def __init__(self, i, j):
self.i = i
self.j = j
@sohang3112
sohang3112 / parse_outlook_safe_link.py
Created December 22, 2025 06:24
Parse actual url from "safe links" of Outlook
@sohang3112
sohang3112 / mathjax_NOTES.md
Last active June 3, 2026 12:47
Notes on MathJAX (a Latex-like mini language using which pretty math expressions can be embedded in Github Markdown documents)

MathJAX NOTES

Reference: MathJAX Macros table - macros start with \. Github Markdown allows a limited subset of MathJAX and no MathJAX extensions can be used. But in static site generators, extensions can be installed using <script> tag.

Inline expressions are written within $ $, block expressions within $$ $$. Curly Brackets { } are required for grouping multiple symbols where otherwise only a single character/symbol is expected

  • eg. after _ (superscript under) and ^ (power/subscript over).
@sohang3112
sohang3112 / git_squash_merge_commits.py
Created December 4, 2025 19:16
Shrink .git folder size by converting merge commits into normal squash commits
# 'Squash Merge' video by anthonywritescode, this is script shown at timestamp 16:50 :
# https://youtu.be/5_8FTivl8Vs?si=krcdLDevrAC_DLuo&t=1013
# Uses https://github.com/newren/git-filter-repo (python script)
# Explanation: `git cat-file commit COMMIT_ID` shows parent commit id
# normal commits have 1 parent, merge commits have 2 parents
# this script simply deletes 1 parent (keeping only parent id of main branch),
# converting merge commit into normal (squash) commit
# An impressive example of this script is shown,
@sohang3112
sohang3112 / gpg_sign_commits_github.md
Created December 3, 2025 12:09
GitHub: Create GPG key and sign commits with it (required by some open source projects)
$ gpg --full-generate-key
$ gpg --list-secret-keys --keyid-format=long
$ gpg --armor --export GPG_KEY_ID    # get key id from prev list command - see details in above link

Copy output of last command (gpg armor export). Go to Github > Settings > SSH and GPG Keys > New GPG Key and paste it.

@sohang3112
sohang3112 / pdf2ipynb.py
Created November 17, 2025 12:53
Convert PDF files to Jupyter Notebook .ipynb file
#! /usr/bin/env python3
import os
import fitz # PyMuPDF
import nbformat
# Source: https://www.reddit.com/r/learnpython/comments/1ji0qwz/comment/mjblesy/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
def pdf_to_ipynb(pdf_path: os.PathLike, ipynb_path: os.PathLike) -> None:
"""Convert PDF -> Jupyter Notebook .ipynb file."""
doc = fitz.open(pdf_path)
@sohang3112
sohang3112 / compress_consecutive_chars.hs
Last active April 13, 2025 08:33
(Haskell) Compresses a string by counting consecutive repeating characters.
{-# LANGUAGE BangPatterns #-}
import Data.List (foldl')
-- | Compresses a string by counting consecutive repeating characters.
--
-- Returns a list of tuples where each tuple consists of a character and the
-- number of its consecutive occurrences in the string.
--
-- This function uses 'reverse', 'foldl'' and bang patterns for strict accumulation.