Skip to content

Instantly share code, notes, and snippets.

Avatar

pavol kutaj pkutaj

View GitHub Profile
@pkutaj
pkutaj / 2020-12-05-the-trim-horizon-of-AWS-Kinesis-and-the-concept-of-checking.md
Last active Aug 3, 2022
2020-12-05-the-trim-horizon-of-AWS-Kinesis-and-the-concept-of-checking.md
View 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 Sep 30, 2022
2021-04-14-On-The-Lease-Table-as-a-State-Maintenance-of-AWS-Kinesis.md
View 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
@pkutaj
pkutaj / 2022-07-17-How-to-Share-a-Global-Variable-Across-Files-and-Modules-in-Python.md
Created Jul 17, 2022
2022-07-17-How-to-Share-a-Global-Variable-Across-Files-and-Modules-in-Python.md
View 2022-07-17-How-to-Share-a-Global-Variable-Across-Files-and-Modules-in-Python.md

USECASE

The aim of this page📝 is to share how I make certain variables accessible for different modules/files in Python.

  • I do this not to repeat myself (DRY principle)
  • I am not using global keyword (no help here)
  • I am simplifying the approach from stack overflow
  • My use is in my short Jirc (Jira Card from Terminal) script
  • My global variable is a path to a config file that I need on various occasions in various places
@pkutaj
pkutaj / 101.02-CP-Traditional-Data-Centers.md
Last active Jul 6, 2022
CCCDFFR: 7 Advantages of Cloud over On Prem
View 101.02-CP-Traditional-Data-Centers.md
ATTRIBUTE ON PREM CLOUD
COSTS_INIT great / CAPEX (capital expenses) small / OPEX (operational/variable expense)
COSTS_MAINTENANCE expensive / need to staff data center (DC) elastic / cheaper (economies of scale)
COMPLIANCE own responsibility shared responsibility model / less risk
DEPLOYMENT_PACE slow fast / efficient (economies of scale) / go global in minutes
FORECASTING difficult / imprecise elastic scaling
FINANCING no money no honey speed and agility / test capacity against real users with minimal costs
RELIABILITY additional dimension / failovers required global infra built with reliability in mind
@pkutaj
pkutaj / 2020-07-14-ignore-files-in-gitignore-using-globbing-patterns.md
Created Jul 5, 2022
2020-07-14-ignore-files-in-gitignore-using-globbing-patterns.md
View 2020-07-14-ignore-files-in-gitignore-using-globbing-patterns.md
@pkutaj
pkutaj / 50.04-FP-Combining-Map-and-Reduce_2.py
Created Jun 6, 2022
50.04-FP-Combining-Map-and-Reduce_2.py
View 50.04-FP-Combining-Map-and-Reduce_2.py
documents = [
"Each in the cell of himself is almost convinced of his freedom",
"You know I like that violence that you get around here, that kind of ready steady violence",
"Yes that is right punk is dead it is another cheap product for the consumers head",
"To be or not to be that is the question"
]
counts = map(count_words,documents)
# OUTPUT IS LAZY OBJECT
# <map object at 0x01F2F610>
@pkutaj
pkutaj / 2022-05-30-How-to-Run-Custom-Code-Upon-Hitting-Ctrl-C-in-Python.py
Created May 30, 2022
2022-05-30-How-to-Run-Custom-Code-Upon-Hitting-Ctrl-C-in-Python.py
View 2022-05-30-How-to-Run-Custom-Code-Upon-Hitting-Ctrl-C-in-Python.py
def main():
try:
# DO SOMETHING....
except KeyboardInterrupt:
# UPON CTRL+C ASK IF A FILE CONTENTS SHOULD BE DROPPED
if input("~~> Interrupted ! Clean-up 'output.txt'? (y/N): ") == "y":
# RUN DROPPING FUNCTION IF YES
delete_output_content()
# AND SAY GOOD BYE
sys.exit("bye")
@pkutaj
pkutaj / 2021-01-09-7-values-that-test-false-in-Python.md
Created May 6, 2022
2021-01-09-7-values-that-test-false-in-Python.md
View 2021-01-09-7-values-that-test-false-in-Python.md
NO DESCRIPTION VALUE
1 Boolean False
2 None keyword None
3 The number zero 0
4 An empty string ''
5 An empty list []
6 An empty tuple ()
7 An empty dictionary {}
@pkutaj
pkutaj / 2022-03-01-PowerShell-Wrapper-for-OpenSSL-to-Test-Certificate.ps1
Created Mar 1, 2022
PowerShell Wrapper for OpenSSL to Test Certificates Fast with Extended Functionality
View 2022-03-01-PowerShell-Wrapper-for-OpenSSL-to-Test-Certificate.ps1
function test-certificate([string[]]$domains, $contextLength = 10, [switch]$download) {
$cacertPath = "${env:USERPROFILE}\cacert.pem"
if (-not(Test-Path $cacertPath)) {
Invoke-WebRequest "https://curl.se/ca/cacert.pem" -OutFile "${env:USERNAME}\cacert.pem"
}
foreach ($domain in $domains) {
$connectDomain = $domain + ":443"
if ($download) {
echo "q" |
openssl s_client -servername $domain -connect $connectDomain -CAfile $cacertPath |
@pkutaj
pkutaj / The-Twelve-Modes-of-Python-File-Handling.md
Created Feb 5, 2022
The-Twelve-Modes-of-Python-File-Handling.md
View The-Twelve-Modes-of-Python-File-Handling.md
MODE MEANING STREAM POSITION COMMENT
r reading beginning of the file default
r+ reading and writing beginning of the file
w writing only Overwrites / creates a new file for writing
w+ writing and reading Overwrites / creates a new file for reading and writing
rb reading in binary beginning of the file
rb+ reading and writing binary
wb+ writing and reading binary Overwrites / creates a new file for reading and writing
a appending end of the file if exists If the file does not exist, it creates a new file for writing.