Skip to content

Instantly share code, notes, and snippets.

View pkutaj's full-sized avatar

pavol kutaj pkutaj

View GitHub Profile
@pkutaj
pkutaj / SSAP-44.03-State-Machine-for-Log-Reducer3.md
Created April 17, 2023 05:42
SSAP-44.03-State-Machine-for-Log-Reducer3.md
STEP description technical implementation
#1 an input arrives /triggers event event_listener or iteration over file, etc.
#2 event identification EVENTS table lookup (mapping function (input > event))
#3 action identification TRANSITION table lookup (mapping function event + cur_state > action)
#4 action is performed case analysis > action (function call)
#5 state is switched TRANSITION table lookup
@pkutaj
pkutaj / 2023-03-08-How-to-Create-a-Simple-Menu-in-Python-Scripts3.py
Created March 8, 2023 07:04
2023-03-08-How-to-Create-a-Simple-Menu-in-Python-Scripts3.py
# schema_patcher.py
if selection == "Delete":
delete_schema(schema_data)
elif selection == "Patch":
patch_schema(schema_data)
elif selection == "List":
list_schemas(schema_data)
@pkutaj
pkutaj / 2023-03-08-How-to-Create-a-Simple-Menu-in-Python-Scripts2.py
Created March 8, 2023 07:04
2023-03-08-How-to-Create-a-Simple-Menu-in-Python-Scripts2.py
# schema_patcher.py
from menu_maker import *
menu_items = ["Delete", "Patch", "List"]
menu = Terminal_Menu(menu_items)
menu.print_menu()
selection = menu.select_menu_item()
@pkutaj
pkutaj / 2023-03-08-How-to-Create-a-Simple-Menu-in-Python-Scripts1.py
Created March 8, 2023 07:03
2023-03-08-How-to-Create-a-Simple-Menu-in-Python-Scripts1.py
# menu_maker.py
class Terminal_Menu:
def __init__(self, menu_items: list):
self.menu_items = menu_items
def print_menu(self):
for i, single_item in enumerate(self.menu_items, start=1):
print(i, single_item)
def select_menu_item(self):
@pkutaj
pkutaj / 2023-02-23-How-to-Ask-AI-from-Command-Line.py
Created February 23, 2023 08:49
2023-02-23-How-to-Ask-AI-from-Command-Line.py
import os
import sys
import openai
import pyperclip as clipboard
def main(prompt):
openai.api_key = os.environ["OPENAI_KEY"]
model_engine = "text-davinci-003"
completion = openai.Completion.create(
@pkutaj
pkutaj / 2021-05-27-Mutable-vs-Immutable-Common-Data-Structures-in-Python.md
Created February 16, 2023 07:40
Mutable VS Immutable Built-In Data Objects in Python
MUTABLE IMMUTABLE
#1 list ~
#2 dict ~
#3 set ~
#4 byte array ~
~ #1 int
~ #2 float
~ #3 complex
~ #4 string
@pkutaj
pkutaj / BAC-02.14-File-test-operators.md
Created February 10, 2023 07:57
Reference for Bash File Test Operators
FLAG MEANING
-e file exists
-a file exists (deprecated, don't use)
-f file is a regular file (not a directory or /dev - device file)
-s file is not zero size
-d file is a directory
-b file is a block device (see below)
-c file is a character device (see below)
-p file is a pipe
@pkutaj
pkutaj / RC1-16.02-Towers-of-Hanoi.py
Created December 26, 2022 13:08
RC1-16.02-Towers-of-Hanoi.py
move_count = 0
def move_disk(remaining_disks, source, target):
global move_count
print(f"STEP#{move_count+1}\n"
f"\t~~> Disk #{remaining_disks}; {source} > {target}")
def count_move():
@pkutaj
pkutaj / 2020-12-05-the-trim-horizon-of-AWS-Kinesis-and-the-concept-of-checking.md
Last active August 3, 2022 11:23
2020-12-05-the-trim-horizon-of-AWS-Kinesis-and-the-concept-of-checking.md
TYPE NAME DESCRIPTION
AT_SEQUENCE_NUMBER Start reading from the position denoted by a specific sequence number, provided in the value StartingSequenceNumber.
AFTER_SEQUENCE_NUMBER Start reading right after the position denoted by a specific sequence number, provided in the value StartingSequenceNumber.
AT_TIMESTAMP Start reading from the position denoted by a specific timestamp, provided in the value Timestamp.
TRIM_HORIZON Start reading at the last untrimmed record in the shard in the system, which is the OLDEST data record in the shard.
LATEST Start reading just after the most recent record in the shard, so that you always read the NEWEST data record in the shard.
@pkutaj
pkutaj / 2021-04-14-On-The-Lease-Table-as-a-State-Maintenance-of-AWS-Kinesis.md
Last active September 30, 2022 02:57
2021-04-14-On-The-Lease-Table-as-a-State-Maintenance-of-AWS-Kinesis.md
FIELD COMMENT
checkpoint The most recent checkpoint sequence number for the shard. This value is unique across all shards in the data stream.
checkpointSubSequenceNumber When using the Kinesis Producer Library's aggregation feature, this is an extension to checkpoint that tracks individual user records within the Kinesis record.
leaseCounter Used for lease versioning so that workers can detect that their lease has been taken by another worker.
leaseKey A unique identifier for a lease. Each lease is particular to a shard in the data stream and is held by one worker at a time.
leaseOwner The worker that is holding this lease.
ownerSwitchesSinceCheckpoint How many times this lease has changed