Skip to content

Instantly share code, notes, and snippets.

@hyvyys
hyvyys / CaseFilter.js
Created September 22, 2019 18:21
Remove lowercase or uppercase letters from a string, using `grapheme-splitter` to handle languages using combining diacritical marks.
import GraphemeSplitter from "grapheme-splitter";
export default {
lower(str) {
let splitter = new GraphemeSplitter();
let graphemes = splitter.splitGraphemes(str);
return graphemes.filter(g => g.toLowerCase() === g).join("");
},
upper(str) {
let splitter = new GraphemeSplitter();
@hyvyys
hyvyys / Chord line regex.txt
Last active September 29, 2019 20:16
Regular expression to match lines with guitar chords in a guitar tab
^ *([A-Z\.majdimsusaug()b#1-9/]+ +)*([A-Z\.majdimsusaug()b#1-9/]+)\r\n
@hyvyys
hyvyys / SyllableRegex.js
Last active October 6, 2019 00:17
Syllable regular expression (English)
function syllableRegex() {
const consonants = "[bcdfghjklmnpqrstvwxyz']";
const vowels = "[aeiouy]";
const separators = "[ \\.,:;!?]|$";
const wordSep = `(?=${separators})`;
const wordSepOrConsonant = `(?=${separators}|${consonants})`;
return new RegExp(
`${consonants}*${vowels}{1,3}` +
`(${consonants}*e${wordSep}|${consonants}*${wordSepOrConsonant})`,
@hyvyys
hyvyys / ChordRegex.js
Created October 14, 2019 11:59
Regular expression to match Chord symbol / name
function chordRegex() {
const note = '[A-G][b#]?';
const altered = `(?:5|dim(5|7)?|aug5?|\\+5?|-5?)`;
const minor = '(?:mi?n?)';
const major = '(?:maj?|Ma?j?)';
const majorableExt = `(?:6|7|9|11|13)`;
const ext = `(?:4|6|7|9|11|13|6\\/9)`;
const _mod = '(?:[b-](5|6|9|13)|[#+](4|5|9|11))';
const mod = `(?:\\(${_mod}\\)|${_mod})`
const sus = '(?:sus(2|4|24|2sus4)?)';
@hyvyys
hyvyys / MarkToLigature.py
Last active February 10, 2020 14:43
Generate lookups for mark feature from anchors in ligature glyphs named "top.1", "top.2", etc.
#FLM: Mark to ligature
from FL import *
classes = [ 'top', 'bottom', 'ogonek', 'right' ];
f = fl.font
glyphs = f.glyphs
for anchorClass in classes:
print ''
@hyvyys
hyvyys / CSS_KEYWORD_COLORS.js
Last active September 13, 2020 18:05
List of CSS color keywords and corresponding hex values
const CSS_KEYWORD_COLORS = {
"AliceBlue": "#f0f8ff",
"AntiqueWhite": "#faebd7",
"Aqua": "#00ffff",
"Aquamarine": "#7fffd4",
"Azure": "#f0ffff",
"Beige": "#f5f5dc",
"Bisque": "#ffe4c4",
"Black": "#000000",
"BlanchedAlmond": "#ffebcd",
@hyvyys
hyvyys / fontlab.ahk
Last active November 13, 2020 16:50
AutoHotKey script for FontLab
; prevent Alt-zooming from triggering top menu
Alt::
KeyWait, Alt
return
LAlt Up::
if (A_PriorKey = "Alt")
return
return
@hyvyys
hyvyys / typographic.ahk
Created November 11, 2020 10:29
Extend Windows keyboard layout with typographic quotes, dashes and others
; print endash
!-::
Send {Asc 0150}
return
; print emdash
+!-::
Send {Asc 0151}
return