Skip to content

Instantly share code, notes, and snippets.

View pulkitgoyal56's full-sized avatar
🔥

Pulkit Goyal pulkitgoyal56

🔥
View GitHub Profile
@pulkitgoyal56
pulkitgoyal56 / Metaclass Method Inheritance.py
Last active March 24, 2025 16:19
Interesting Python Problems
class BaseMeta(type):
def __init__(cls, *args):
cls.f = cls.f # comment this line and run again!
pass
def f(cls):
print(cls)
class Derived(metaclass=BaseMeta):
pass
@pulkitgoyal56
pulkitgoyal56 / .scripts.sh
Last active March 13, 2025 19:16
Scripts
## Set ENV variables for path abbreviations H (Home) and P (Projects)
export H="$HOME" # ~
export P="$H/projects"
## Generate SSH Key for GitHub and add to SSH Agent
ssh-keygen -t ed25519 -C "pulkitmds@gmail.com" -f $H/.ssh/mykey
eval "$(ssh-agent -s)"
## Show public key
@pulkitgoyal56
pulkitgoyal56 / install-zsh-windows-git-bash.md
Last active December 20, 2022 20:18 — forked from fworks/install-zsh-windows-git-bash.md
Zsh / Oh-my-zsh on Windows Git Bash
@pulkitgoyal56
pulkitgoyal56 / checkvenv.py
Last active July 10, 2021 02:30
Check if Python interpreter is from a virtual environment
import sys
def get_base_prefix_compat():
"""Get base/real prefix, or sys.prefix if there is none."""
return getattr(sys, "base_prefix", None) or getattr(sys, "real_prefix", None) or sys.prefix
def in_virtualenv():
return get_base_prefix_compat() != sys.prefix
in_virtualenv()