Skip to content

Instantly share code, notes, and snippets.

View TheSithPadawan's full-sized avatar

rongromi_est TheSithPadawan

  • United States
View GitHub Profile
@TheSithPadawan
TheSithPadawan / variadic_func.py
Created April 15, 2022 15:23
CFLT onsite prep -- variadic function
# variadic function call
"""
Note:
If a function is marked as isVariadic=true, then the last argument can occur one or more number of times.
Example:
FuncA: [String, Integer, Integer]; isVariadic = false
FuncB: [String, Integer]; isVariadic = true
FuncC: [Integer]; isVariadic = true
FuncD: [Integer, Integer]; isVariadic = true
FuncE: [Integer, Integer, Integer]; isVariadic = false
@TheSithPadawan
TheSithPadawan / window_key_v1.py
Created April 16, 2022 21:54
CLFT onsite prep -- window_key_map
"""
windowed k, v map
first version with t for debug
"""
class Node:
def __init__(self, time=0, val=0, key=0):
self.time = time
self.val = val
self.key = key
self.next = None
@TheSithPadawan
TheSithPadawan / window_key_v2.py
Created April 17, 2022 00:57
CFLT onsite prep -- windowed time map
"""
windowed k, v map
"""
import time
class Node:
def __init__(self, time=0, val=0, key=0):
self.time = time
self.val = val
self.key = key
@TheSithPadawan
TheSithPadawan / task_scheduler.py
Created April 17, 2022 01:47
CFLT onsite prep -- task scheduler
# delayed scheduler
"""
write a function schedule(task, delay) to schedule a task that will be run after some delay
(1) first normal version
(2) thread safe version
"""
import heapq
import time
class Task:
def __init__(self, name):