Skip to content

Instantly share code, notes, and snippets.

View aivarsk's full-sized avatar
🏠
Working from home

Aivars Kalvāns aivarsk

🏠
Working from home
View GitHub Profile
//
// CHALLENGE (work in pairs):
// Move from f(o) -> o.f() and sure that the code is CQS compliant.
//
// 1
class CsvParser<T extends Lines> {
Collection<T> parse(File location) {
}
@aivarsk
aivarsk / solve_me.py
Last active May 31, 2025 04:55
solve_me() for Python3.11+
def solve_me(solution):
res = solution()
del res
if res:
print("Solved")
solution = lambda: [
g.write(b"\x09\x09\x09\x09")
for x, y, g in [
import json
import timeit
def nested_list(depth):
l = [True]
for _ in range(depth - 1):
l = [l]
return l
import json
import timeit
def nested_list(depth):
l = [True]
for _ in range(depth - 1):
l = [l]
return l
@aivarsk
aivarsk / README.md
Last active August 27, 2025 13:41
Gunicorn active/busy worker count

Run it in one shell:

gunicorn -c config.py --workers=32 test:app

Test it from another:

while `true`; do curl http://127.0.0.1:8000 & done
@aivarsk
aivarsk / snippets.py
Created September 28, 2025 08:56
Talking with contactless cards
# For Debian/Ubuntu:
# Needed for the pyscard
# sudo apt-get install libpcsclite-dev
# Install dependencies. DO NOT install smartcard - it's a different package.
# pip install ber_tlv pyscard
# Use https://paymentcardtools.com/emv-tlv-parser to decode DATA
#
# IMPORTANT! All examples are hard-coded for specific test cards I had.
# List and size of fields for AC generation may differ.
#
import re
speach = "Youᅠexpectㅤofㅤmeㅤaᅠspeech?ᅠIᅠhaveᅠonlyᅠoneㅤtoㅤgiveㅤ-ᅠandᅠitㅤisᅠtheᅠsameㅤoneㅤI'dᅠgiveㅤwereᅠweᅠnotㅤstandingᅠonㅤtheㅤbrimᅠofㅤaㅤbattlefield.ㅤItᅠisᅠtheㅤsameㅤoneㅤI'dᅠgiveㅤwereᅠweᅠtoᅠmeetᅠinㅤtheᅠstreetㅤbyᅠchance!ᅠIᅠhaveᅠonlyᅠeverㅤhopedᅠforᅠoneᅠthing...ㅤtoᅠseeᅠthisㅤkingdomᅠunitedᅠunderᅠthisㅤEnglishᅠcrown!ㅤAllᅠmenㅤareㅤbornᅠtoㅤdie.ㅤWeㅤknowᅠit.ᅠWeㅤcarryㅤitᅠwithᅠusㅤalways.ㅤIfㅤyourᅠdayㅤbeㅤtoday,ᅠsoㅤbeㅤit!ᅠMineᅠwillᅠbeㅤtomorrow!ㅤOrᅠmineᅠtodayᅠandᅠyoursㅤtomorrow.ᅠItㅤmattersㅤnot.ᅠWhatㅤmattersㅤisㅤthatᅠyouᅠknow,ㅤinㅤyourᅠhearts,ᅠthatㅤtodayᅠyouᅠareᅠthatᅠkingdomㅤunited.ᅠYouᅠareᅠEngland.ㅤEachᅠandᅠeveryᅠoneㅤofᅠyouㅤ-ᅠEnglandᅠisㅤyou! And it is the space between you. Fight not for yourselves, fight for that space! Fill that space! Make it tissue! Make it mass! Make it impenetrable! Make it yours! Make it England! Make it England! Great men to it. Captains, Lords, great men to it!"
eval(
"".join(
chr(int(i, 2))
for i in re.findall(
r".{8}", "".join("".join(str(int(c < "ᅠ")) for c in
@aivarsk
aivarsk / tbcp
Last active December 15, 2025 11:58
TigerBeetle as a file storage
#!/usr/bin/env python3
import argparse
import mmap
import os
from itertools import batched
import tigerbeetle as tb
client = tb.ClientSync(cluster_id=0, replica_addresses=os.getenv("TB_ADDRESS", "3000"))