Skip to content

Instantly share code, notes, and snippets.

View kontur's full-sized avatar

Johannes Neumeier kontur

View GitHub Profile
@kontur
kontur / replace-chars-with-svg.py
Created January 28, 2022 08:49
Sample script to replace glyphs in an OTF/TTF font with SVG input. (fonttools, defcon, ufo2ft, extract-ufo)
"""
Sample script to replace glyphs in an OTF/TTF font with SVG input.
- Round-trips via UFO, so not applicable to Variable fonts.
- Will subset the and remove the replaced glyphs from the resulting font.
"""
import os
import re
import sys
import click
import shutil
@kontur
kontur / cyrillic-alphabets.py
Created February 17, 2023 10:37
Cyrillic script alphabet order comparison
# The Cyrillic language comparison table from https://en.wikipedia.org/wiki/Cyrillic_alphabets#Summary_table (chruch slavonic as last line!)
table = """
А Б В Г Д Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ь Ю Я
А Б В Г Д Дж Дз Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ь Ю Я
А Б В Г Д Ѓ Ѕ Е Ж З И Ј К Л Љ М Н Њ О П Р С Т Ќ У Ф Х Ц Ч Џ Ш
А Б В Г Д Ђ Е Ж З И Ј К Л Љ М Н Њ О П Р С Т Ћ У Ф Х Ц Ч Џ Ш
А Б В Г Д Ђ Е Ж З З́ И Ј К Л Љ М Н Њ О П Р С С́ Т Ћ У Ф Х Ц Ч Џ Ш
А Б В Г Д Е Ё Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я
А Б В Г Ґ Д Е Ё Ж З І Й К Л М Н О П Р С Т У Ў Ф Х Ц Ч Ш ’ Ы Ь Э Ю Я
@kontur
kontur / middleware.py
Created October 1, 2024 10:53
Djanto Basic Auth to secure entire site with user/password protection
import base64
from django.http import HttpResponse
from django.conf import settings
from django.utils.deprecation import MiddlewareMixin
class BasicAuthMiddleware(MiddlewareMixin):
"""
Adopted from https://www.djangosnippets.org/snippets/2468/ for Django 5.1
@kontur
kontur / functions.php
Created October 17, 2024 06:31
Render CSS from PHP file with access to WP functions
// functions.php
add_action("wp_enqueue_scripts", "css_styles", 1000);
function css_styles()
{
// load previews
wp_enqueue_style( 'previews-css', '/previews');
}