Skip to content

Instantly share code, notes, and snippets.

View shvms's full-sized avatar
💭
learning

Shuvam Shah shvms

💭
learning
View GitHub Profile
@shvms
shvms / broken.py
Created March 28, 2025 07:16 — forked from justinvanwinkle/broken.py
Every python rate-limiting library (that I can find) is broken, at least a little.
# I was looking for a rate limiting library to call rate limited apis as closely
# as possible to their enforced limits. I looked at the first few python libraries
# that I found, and when I glanced at the source, they were all clearly broken.
# Curious how this could be, I took all the top google and pip search results for: python rate limiting
# and tried to get them to do the wrong thing and fail to rate limit in situations that could come up
# in normal use (though in some cases very specific use)
# https://github.com/tomasbasham/ratelimit
# Where broken:
@shvms
shvms / QueueLinkedList.kt
Created July 23, 2019 19:59
Queue implementation using singly linked list on Kotlin
class Queue<T> {
data class Node<T>(var item: T) {
var next: Node<T>? = null
}
private var size: Int = 0
private var first: Node<T>? = null
private var last: Node<T>? = null
fun getSize(): Int {
@shvms
shvms / StackLinkedList.kt
Created July 23, 2019 19:58
Stack implementation using singly linked list on Kotlin.
class Stack<T> {
data class Node<T>(var item: T) {
var next: Node<T>? = null
}
private var size: Int = 0
private var first: Node<T>? = null
fun getSize(): Int {
return size
@shvms
shvms / QuickFindUF.py
Created July 4, 2019 22:15
Implementation of the quick-find algorithm (including weighting & path compression) to solve dynamic connectivity problem.
'''
Implementation of the QuickUnion approach to the Union-Find problem.
Improvements like weighting and path compression has also been implemented.
Author: Shuvam Shah
'''
class QuickUnionUF(object):
def __init__(self, N, weighting=True):
self.ids = [i for i in range(N)]
self.size = [1] * N