Skip to content

Instantly share code, notes, and snippets.

Avatar
🐍
<-Python

Makarov Andrey Winand

🐍
<-Python
View GitHub Profile
@Winand
Winand / .python-version
Last active January 6, 2023 22:35
poetry interpreter detection issue
View .python-version
3.9.13
3.10.9
3.8.10
@Winand
Winand / example.py
Last active January 6, 2023 11:55
Nox in docker example
View example.py
import os
def Main():
x = os.getpid()
print(f"{x=}")
if __name__ == '__main__':
Main()
@Winand
Winand / typer_abbr_args.py
Last active December 15, 2022 14:43
Allow abbreviated argument names (see also allow_abbrev=True in argparse)
View typer_abbr_args.py
import typer
def main(
hello: int = typer.Option(None),
there: int = typer.Option(None),
infinite: bool = typer.Option(False),
) -> None:
print(hello, there, infinite)
if __name__=='__main__':
View read_link.py
@Winand
Winand / table_split_w_headers.bas
Last active October 27, 2022 11:58
Split table on page breaks and add header row to each new part
View table_split_w_headers.bas
Sub tableSplitWithHeaders()
'https://stackoverflow.com/questions/8668311/current-row-in-vba-word
'https://www.tek-tips.com/viewthread.cfm?qid=1610014
'https://stackoverflow.com/questions/37999841/how-can-i-determine-the-page-number-of-a-table-in-ms-word-macro
'https://learn.microsoft.com/en-us/office/vba/api/word.selection.insertbreak
Const TITLE_CONTINUE As String = "Продолжение таблицы"
Const TITLE_END As String = "Окончание таблицы"
Dim t As Table, t2 As Table, r As row
@Winand
Winand / compare.bas
Created September 8, 2022 07:43
Сравнение книг Excel
View compare.bas
Sub compare()
Dim sh1 As Worksheet, sh2 As Worksheet
Set wb1 = ThisWorkbook
Set wb2 = Workbooks("Map B00 XP__20210617_.XLSX")
For Each sh1 In wb1.Worksheets
Set sh2 = wb2.Worksheets(sh1.Name)
If sh1.UsedRange.Address <> sh2.UsedRange.Address Then
Debug.Print sh1.Name
Else
For Each c In sh1.UsedRange
@Winand
Winand / pyarrow_repack_groups.py
Created July 26, 2022 12:04
Load parquet dataset and save with new partitioning
View pyarrow_repack_groups.py
"""
https://stackoverflow.com/questions/68708477/repartition-large-parquet-dataset-by-ranges-of-values
"""
import pyarrow as pa
import pyarrow.dataset as ds
import pyarrow.compute as pc
import pyarrow.parquet as pq
from pathlib import Path
View requests_timeout_retry.py
# r = read_timeout_handler(self.session.get, self.url_card, params=params, timeout=[10, 20, 30])
def read_timeout_handler(func, url, timeout, retries=None, params={}, **kw):
"Retries on read timeout"
if not hasattr(timeout, '__iter__'):
timeout = [timeout] * (retries or 1)
elif retries is not None:
raise ValueError("retries specified along with list of timeouts")
for retry, tm in enumerate(timeout):
try:
@Winand
Winand / docker-compose-kafka.yml
Created June 21, 2022 09:15
Пример: кластер Kafka
View docker-compose-kafka.yml
# https://dimosr.github.io/kafka-docker/
version: '3.4'
services:
zookeeper:
image: 'bitnami/zookeeper:3.8'
ports:
- '2181:2181'
environment:
View extension_jupyter_test.md

Scenario (general):

1.1 Start code-server:

WORKON_HOME=~ code-server --cert --cert-host 172.30.15.137 --disable-telemetry --disable-update-check ~/_railcars

2.1 Open https://172.30.15.137:8080 in Google Chrome

3.1 Open Untitled.ipynb, run three cells: import pandas, create DataFrame, sum dataframe values