Skip to content

Instantly share code, notes, and snippets.

View rnag's full-sized avatar

Ritvik Nag rnag

View GitHub Profile
@rnag
rnag / .editorconfig
Created January 20, 2024 05:30
.editorconfig
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org
# top-most EditorConfig file
root = true
[*]
# Change these settings to your own preference
[user]
name = Ritvik Nag
[init]
defaultBranch = main
[push]
followTags = true
autoSetupRemote = true
@rnag
rnag / .Rewrite-Git-Commit-Author.md
Last active February 27, 2024 19:54
Git - Change Commit Author

Bash/Zsh Function to Change Author for Commit(s)

Based off my Answer on SO.


The below function cca (shorthand for change-commit-author) makes some assumptions:

  • The branch with commit(s) to update author for is the current branch.
  • Git User / Email (AKA New Author) is the one currently set up with git.
  • One of the following arguments is passed in:
'''
>tesla-inventory-price-scraper.py<
@Author: Maxwell Mowbray
@Email: [email protected]
@Date: April 2020
@Description:
This script scrapes Tesla's car inventory website and alerts the user if a car under a certain price appears.
It can easily be adapted to do other things with the results, such as alert you when a specific car with a specific trim/color/wheel size appears in inventory.
@rnag
rnag / main.py
Created November 27, 2024 06:55
Python: Compare `to string` conversion performance
from timeit import timeit
from dataclass_wizard.utils.type_conv import as_str
n = 100_000
print('(int) as_str():'.ljust(25), timeit('x = 42; as_str(x)', globals=globals(), number=n))
print('(int) str():'.ljust(25), timeit('x = 42; str(x)', globals=globals(), number=n))
print('(int) empty_if_none():'.ljust(25), timeit("x = 42; '' if x is None else str(x)", globals=globals(), number=n))
@rnag
rnag / perf-vs-apischema.py
Last active December 8, 2024 22:45
Dataclass Wizard vs. Other De/Serialization Libraries!
# pip install apischema
# pip install dataclass-wizard
from dataclasses import dataclass, field
from timeit import timeit
from uuid import UUID, uuid4
from apischema import deserialize, serialize
from dataclass_wizard import JSONWizard