Skip to content

Instantly share code, notes, and snippets.

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

Jan Kučera hclivess

🏠
Working from home
View GitHub Profile
@hclivess
hclivess / dotmaze.py
Last active August 29, 2023 18:01
dotted maze with dict representation
from PIL import Image, ImageDraw
import random
def generate_maze(width, height):
maze = [['wall' for _ in range(width)] for _ in range(height)]
# Generate maze using binary tree algorithm
for y in range(1, height, 2):
for x in range(1, width, 2):
maze[y][x] = 'path'
from PIL import Image, ImageDraw
import random
class Cell:
wall_pairs = {'N': 'S', 'S': 'N', 'E': 'W', 'W': 'E'}
def __init__(self, x, y):
self.x, self.y = x, y
self.walls = {'N': True, 'S': True, 'E': True, 'W': True}
@hclivess
hclivess / input.txt
Created February 4, 2023 12:46
babicka
Babička měla syna a dvě dcery. Nejstarší žila mnoho let ve Vídni u přátel, od nichž se vdala. Druhá dcera šla pak na její místo. Syn řemeslník též byl již samostatným a přiženil se do městského domku. Babička bydlela v pohorské vesničce na slezských hranicích, žila spokojeně v malé chaloupce se starou Bětkou, která byla její vrstevnice a již u rodičů sloužila.
Nežila osamotnělá ve své chaloupce; všickni obyvatelé vesničtí byli bratřími jí a sestrami, ona jim byla matkou, rádkyní, bez ní se neskončil ani křest, ani svatba, ani pohřeb.
Tu najednou přišel babičce list z Vídně od nejstarší dcery, v němž jí vědomost dávala, že manžel její službu přijal u jedné kněžny, která má velké panství v Čechách, a sice jen několik mil vzdálenosti od pohorské vesničky, kde babička bydlí. Tam že se nyní s rodinou odstěhuje, manžel pak vždy jen přes léto že tam bude, když i paní kněžna se tam zdržuje. Ke konci listu stála vroucí prosba, aby babička k nim se odebrala navždy a živobytí svoje u dcery a vnoučat strávila, kteří se
@hclivess
hclivess / arw_to_tiff
Created January 29, 2023 12:58
Convert ARW to TIFF
import sys
import rawpy, imageio
files = sys.argv[1:]
for file in files:
with rawpy.imread(file) as raw:
rgb = raw.postprocess()
imageio.imsave(f'{file}.tiff', rgb)
@hclivess
hclivess / whydevslovedyna.json
Last active January 28, 2023 13:46
Why Devs Love Dynatrace Dashboard
{
"metadata": {
"configurationVersions": [
6
],
"clusterVersion": "1.258.87.20230120-140924"
},
"id": "a630b218-1648-4efb-82d4-71e41b859695",
"dashboardMetadata": {
"name": "Best Practices Overview",
@hclivess
hclivess / raise_inheritance.py
Created January 5, 2023 04:15
Python raise inheritance to never forget
try:
try:
try:
print(1/0)
except Exception as e:
raise(e)
except:
print("I will not raise")
except:
print("I never trigger")
@hclivess
hclivess / async_gather.py
Created December 11, 2022 20:35
Simple asynchronous gather function
import asyncio
pets = ["aliens", "cats", "dogs", "ostriches"]
def print_pet(pet):
print(pet)
async def main():
await asyncio.gather(print_pet(pet) for pet in pets)
@hclivess
hclivess / sync_to_async.py
Created November 27, 2022 15:19
minimalistic asyncio on synchronous functions that do not support it
import asyncio
def static_hi(this):
"""this function is not asynchronous"""
return this
async def printer():
"""notice arguments are not passed directly"""
"D:\Hry\steamcmd\steamcmd.exe" +login anonymous +app_update 1110390 +exit
start "" "%~dp0ServerHelper.bat" +InternetServer/Ostrava
from numpy.random import seed
from numpy.random import normal
import matplotlib.pyplot as plt
def get_ndist_list(loc=0, scale=1, size=100):
return list(normal(loc=loc, scale=scale, size=size))
def define_x_axis(y_axis):
x_axis = []