Skip to content

Instantly share code, notes, and snippets.

View Shivanshu-Gupta's full-sized avatar

Shivanshu Gupta Shivanshu-Gupta

View GitHub Profile
@Shivanshu-Gupta
Shivanshu-Gupta / typer-dataclass.py
Last active August 11, 2025 01:50 — forked from tbenthompson/config.py
dataclass and YAML configurator on top of typer
"""
Usage:
A dataclass/YAML/CLI config system:
- write a @dataclass with your config options
- make sure every option has a default value
- include a `config: str = ""` option in the dataclass.
- write a main function that takes a single argument of the dataclass type
- decorate your main function with @dataclass_cli
- make sure your main function has a docstring.
@Shivanshu-Gupta
Shivanshu-Gupta / parameters.py
Created August 11, 2025 01:47
A dataclass with dict- and attribute-style access and lots of additional freebies!
# Taken from https://github.com/Shivanshu-Gupta/attr-hyperparams
import attr
import cattr
from collections.abc import MutableMapping
from collections import UserList
from typing import IO, Iterable, Text, Union, get_origin, get_args
from pathlib import Path
from itertools import product
from copy import deepcopy
@Shivanshu-Gupta
Shivanshu-Gupta / logging.py
Created August 11, 2025 01:45
Rich logging
import random
import logging
from rich.logging import RichHandler
from rich.pretty import pretty_repr
class CustomRichHandler(RichHandler):
def emit(self, record) -> None:
if not isinstance(record.msg, str):
record.msg = pretty_repr(record.msg)
return super().emit(record)
@Shivanshu-Gupta
Shivanshu-Gupta / track.py
Last active August 11, 2025 01:32
rich-progress-bar
# Usage:
# for _ in track(range(10), "Doing stuff..."):
# pass
from typing import Callable, Iterable, List, Optional, Sequence, Union
from rich.progress import ProgressType, Progress, TextColumn, ProgressColumn, BarColumn, TimeElapsedColumn, TimeRemainingColumn
from rich.style import StyleType
from rich.console import Console
def get_progress_bar(
@Shivanshu-Gupta
Shivanshu-Gupta / slideslive-downloader.py
Created December 12, 2021 08:26
slideslive-downloader
import os
import requests
# import selenium.webdriver as webdriver
import seleniumwire.webdriver as webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
URL = 'https://slideslive.com/embed/presentation/38969236?embed_parent_url=https%3A%2F%2Fnips.cc%2Fvirtual%2F2021%2Ftutorial%2F21891&embed_container_origin=https%3A%2F%2Fnips.cc'
DOWNLOADS_DIR = '/Users/shivanshu/Downloads/neurips/tut-structural-priors/'

How to Negotiate Industry Offers in AI by Rora - ICML 2021

Ways Offer Negotiations are Complex

Choosing the right job offer is a complex decision

  • Career growth requires choosing the right company, team, and manager in addition to your own effort. Every candidate should have an answer for:
    • How do you know
      • This company is on a growth trajectory?
  • This team within the company is influential/important?
# ---------------------------------------------------------------------------- #
# Python #
# ---------------------------------------------------------------------------- #
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
@Shivanshu-Gupta
Shivanshu-Gupta / gdrive_download
Created May 16, 2021 09:24 — forked from darencard/gdrive_download
Script to download files from Google Drive using Bash
#!/usr/bin/env bash
# gdrive_download
#
# script to download Google Drive files from command line
# not guaranteed to work indefinitely
# taken from Stack Overflow answer:
# http://stackoverflow.com/a/38937732/7002068
gURL=$1
@Shivanshu-Gupta
Shivanshu-Gupta / cloudSettings
Last active October 1, 2020 08:56
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-10-01T08:42:47.138Z","extensionVersion":"v3.4.3"}