Skip to content

Instantly share code, notes, and snippets.

View kontur's full-sized avatar

Johannes Neumeier kontur

View GitHub Profile
@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 / 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 / css
Created April 10, 2020 07:59
Magic Carpet... aka positioning a 100% wide element inside the layout flow
.magic-carpet {
width: 100vw;
position: relative;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right: -50vw;
// fixed height
height: 250px;
@kontur
kontur / extract_stylespace_from_designspace.py
Last active February 25, 2020 12:18
A helper script to extract the main stylespace structure from a designspace, use for with https://github.com/daltonmaag/statmake
"""
A helper script to try extract some reasonable defaults for a stylespace
document from a designspace.
You will in all likelyhood need to manually edit this generated stylespace, but
this saves a lot of the typing.
NOTE: That this assumes a well defined and valid designspace!
"""
from fontTools import designspaceLib as dsLib
@kontur
kontur / Scroller.js
Created July 27, 2017 07:44
Scroller - takes element, scroll() calls, and continues native-ish scrolling after last scroll() call
/**
* Helper class that simulates some-of-what nativish
* scrolling that continues after dragging (explicit calls to scroll())
* have stopped
*/
// libraries
import $ from "./Zepto"
export default class Scroller {
@kontur
kontur / gist:8435422
Created January 15, 2014 12:35
javascript strict boolean type casting
var something = something === true; // something will always be 'false' except for explicit 'true'
var something = something !== false; // something will always be 'true' except for explicit 'false'
@kontur
kontur / gist:6901510
Created October 9, 2013 13:43
Simple touch detection snipped
function is_touch_device() {
return 'ontouchstart' in window // works on most browsers
|| 'onmsgesturechange' in window; // works on ie10
};
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
var msViewportStyle = document.createElement("style");
msViewportStyle.appendChild(document.createTextNode("@-ms-viewport{width:auto!important}"));
document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
}
@kontur
kontur / gist:5332271
Created April 7, 2013 20:08
MySQL CLI command to create csv view from select
SELECT *
FROM test
INTO OUTFILE '/tmp/test.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
@kontur
kontur / gist:3839798
Created October 5, 2012 13:25
javascript getter for a flash object on page, for calls to external interface
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf('Microsoft') !== -1;
return (isIE) ? window[movieName] : document[movieName];
}
// with a swfobject embedding like:
var flashvars = {};
var params = {};
var attributes = {};
attributes.id = "myFlash"; // required for flash to javascript communication