Skip to content

Instantly share code, notes, and snippets.

View horvatha's full-sized avatar

Árpád Horváth horvatha

View GitHub Profile
#!/usr/bin/python3
from pathlib import Path
from string import ascii_letters
fs = "🌼🌺🌷🪻🌹🥀🪷🌸🌻🍄🎂🎹"
text = Path("MARTI.txt").read_text()
text = text.replace(".", fs[4]).replace("\\", fs[0]).replace("?", fs[4])
chars = set(ascii_letters + "öéűáőüíóúÖÉŰÁŐÜÍÓÚ!")
from openpyxl import Workbook
text = "￿" # Including three bytes: hexadecimal FFBFBF resulting ValueError
# text = '\x16' # resulting IllegalCharacterError
wb = Workbook()
ws = wb.active
ws.append([text])
wb.save("test.xlsx")
I've just returned from EuroPython Conference, and there was a good presentation: "From Jupyter Notebooks to a Python Package: The Best of Both Worlds". If I'm correct the video is not (yet?) on youtube, but the repo and the slides are here.
https://github.com/sesise0307/europython2023-package
I've used to use a similar setup, but I'll do the same (just w/ PyCharm instead of VSCode).
Creating packag(es) from frequently used functionalities.
%load_ext autoreload%autoreload 2
in Jupyter, and then from Jupyter (starting with !) or from commandline
pip install --editable <path>
import fnmatch
import os
import sys
from pathlib import Path
eleresi_ut = Path.home() / "Documents"
minta = 'Co*t*.*'
# good old walk
for root, dirs, files in os.walk(eleresi_ut):
from test_cases import cases
from irish_possessive_golf import f
def test_all():
for i, (x, y, result) in enumerate(cases):
my_result = f(x, y)
assert my_result == result, f"{x}, {y} should give {result}, not {my_result} ({i+1})"
print("All succeeded")
import argparse
from pathlib import Path
import os
def get_latest_file(directory: Path) -> Path:
"""
Finds the most recently modified file in a directory and its subdirectories.
Args:
"""
Solution for
https://adventofcode.com/2022/day/2
first and second half
"""
from typing import List, Callable
RESULT_SCORES = {"draw": 3, "win": 6, "loose": 0}
from functools import partial
import turtle
window = turtle.Screen()
def draw_polygon(sides, color):
turtle.color(color)
angle = 360/sides
for i in range(sides):
@horvatha
horvatha / mozgas_egyenlo_o_haromszog.py
Last active September 2, 2022 19:38
Egy egyenlő oldalú háromszöget nagyít. Az egyik oldalfelező van mindig középen, és két csúcs az egyik átló mentén helyezkedik el. Egy olyan koordinátarendszert használok, ahol a közepe az origó, a tengelyek -1-től egyig mennek. A háromszög csúcsa 1-szeres nagyítás esetén: [(1, 1), (-1, -1), (-sqrt(3), sqrt(3))]. A nagyítást 0.01 és 1.21 között v…
from math import sqrt
from microbit import *
s3 = sqrt(3)
pattern0 = [(1, 1), (-1, -1), (-s3, s3)]
def magnify_by(n):
def transf(x, y):
@horvatha
horvatha / eredmeny.txt
Last active August 6, 2022 13:08
A földhivatal fájljából adatok kinyerése
Ebből indulva https://pastebin.com/raw/nPbzGFmu
az eredmény:
Szakasz: Tulajdonosi adatok
{'Tul.hányad': '1/2', 'Szerz.jogcím': 'adásvétel', 'Név': 'Gipsz Csaba', 'Anyja neve': 'Próba Katalin', 'Jogállás': 'tulajdonos', 'Cím': '4965 MINTA, Kölcsey utca 105'}
{'Tul.hányad': '1/2', 'Szerz.jogcím': 'adásvétel', 'Név': 'Gipsz Csabáné', 'Szül.név': 'Gipsz Éva', 'Anyja neve': 'Minta Borbála', 'Jogállás': 'tulajdonos', 'Cím': '4965 MINTA, Kölcsey utca 105'}
Szakasz: Jogok-tények jogosultjai
{'Jog-tény neve': 'Önálló szöveges bejegyzés', 'Szöveg': 'Lakcímváltozás átvezetése.'}
{'Jog-tény neve': 'Jelzálogjog', 'Név': 'MAGYAR ÁLLAM', 'Cím': '-,'}
{'Jog-tény neve': 'Elidegenítési és terhelési tilalom', 'Név': 'MAGYAR ÁLLAM', 'Cím': '-,', 'Utalások': 'III/14'}