Skip to content

Instantly share code, notes, and snippets.

View encukou's full-sized avatar

Petr Viktorin encukou

View GitHub Profile
encukou / nazev_jednoducheho_cisla.c
Created March 21, 2024 16:21
// 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 ='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 = ''
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:
# 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
# pip install pyglet
import pyglet
window = pyglet.window.Window(
label = pyglet.text.Label('Zavřít ', font_name=['Fira Mono', 'Courier New'])
# Shaped clock, adapted from:
# 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