Skip to content

Instantly share code, notes, and snippets.

View encukou's full-sized avatar

Petr Viktorin encukou

View GitHub Profile
@encukou
encukou / nazev_jednoducheho_cisla.c
Created March 21, 2024 16:21
nazev_jednoducheho_cisla.c
// vraci staticky retezec, nevolat free()
char *nazev_jednoducheho_cisla(int n) {
switch (n) {
case 0: return "nula";
case 1: return "jedna";
case 2: return "dva";
case 3: return "tri";
case 4: return "ctyri";
case 5: return "pet";

A function may be shadowed by a static inline function or macro with the same behavior. Typically, this allows better performance for C/C++.

Shadowing example

To provide a static inline equivalent to an exported function, write something like:

import unicodedata
def get_components(char):
name = unicodedata.name(char).removeprefix('BOX DRAWINGS ')
result = []
for part in name.split(' AND '):
part = part.replace(' DASH', '-DASH')
directions = []
for word in part.split():
match word:
import inspect
import sys
import functools
def trace(f):
signature = inspect.signature(f)
indent = ''
@functools.wraps(f)
def decorated(*a, **ka):

Python Vendor Configuration

Currently, several Python distributors modify the Python install layout. Making such modifications requires them to patch multiple standard library modules. The install layout is currently not meant to be a configurable option in a Python installation, but Python developers, distro packagers and module authors all have conflicting certain assumptions in this area. This has presented itself as problematic because Python distributors, understandably, fail to correctly modify all places required to satisfy all these assumptions, resulting in incoherent or straight-out broken Python distributions

# Generator for: https://youtu.be/xeL_Ifngcbo
# Save student code as obrazky/*.py and run this
import sys
import importlib
from pathlib import Path
import turtle
import time
import itertools
import dataclasses
https://github.com/encukou/piskvorky
# pip install pyglet
import pyglet
window = pyglet.window.Window(
style=pyglet.window.Window.WINDOW_STYLE_BORDERLESS,
resizable=True,
)
label = pyglet.text.Label('Zavřít ', font_name=['Fira Mono', 'Courier New'])
# Shaped clock, adapted from:
# https://doc.qt.io/qt-6/qtwidgets-widgets-shapedclock-example.html
# pip install pyside6
from PySide6 import QtWidgets, QtCore, QtGui
app = QtWidgets.QApplication([])
class ShapedClock(QtWidgets.QWidget):
def __init__(self):

Turnaj v piškvorkách - podzim 2020

Účastnice:
    drak-1o
    kocka-1
    kun-2
    liska-1
 motyl-2