Skip to content

Instantly share code, notes, and snippets.

View frankrausch's full-sized avatar

Frank Rausch frankrausch

View GitHub Profile
@frankrausch
frankrausch / Font+HighLegibilityFigures.swift
Created November 24, 2023 19:01
A Swift modifier to get the monospaced high legibility figures
import UIKit
import SwiftUI
extension View {
func highLegibilityFigures(forStyle style: UIFont.TextStyle, tableFigures: Bool = false) -> some View {
modifier(HighLegibilityFigures(style: style, tableFigures: tableFigures))
}
}
private struct HighLegibilityFigures: ViewModifier {
@frankrausch
frankrausch / build_html_from_md.sh
Last active November 13, 2023 14:11
Convert Markdown to HTML with a custom template
pandoc -o index_temp.html index.md
cat header.html index_temp.html footer.html > index.html
rm index_temp.html
@frankrausch
frankrausch / SFUI-HighLegibilityFontDescriptor.swift
Created May 26, 2020 20:42
UIFontDescriptor for SF UI high-legibility figures
func fontDescriptorWithHighLegibilityMonospacedFigures(for fontDescriptor: UIFontDescriptor) -> UIFontDescriptor {
return fontDescriptor.addingAttributes(
[
UIFontDescriptor.AttributeName.featureSettings:
[
[ // High legibility 6 and 9
UIFontDescriptor.FeatureKey.featureIdentifier: kStylisticAlternativesType,
UIFontDescriptor.FeatureKey.typeIdentifier: kStylisticAltOneOnSelector,
],
[ // High legibility 4
@frankrausch
frankrausch / gist:572a3368c50b77be854265a8c91a77b2
Created May 13, 2020 21:26
Convert UIKeyCommand from deprecated init syntax to iOS 13 SDK syntax
# Regex:
UIKeyCommand\(input: (.+)\, modifierFlags: (.+), action: #selector\((.+)\), discoverabilityTitle: (.+)\),
# Replace:
UIKeyCommand(title: $4,
image: nil,
action: #selector($3),
input: $1,
modifierFlags: $2,
propertyList: nil,

Typesetting Libraries and Plugins

These are tools that improve typographic details like microtypography and typographic syntax automatically.

Additions welcome!

Name Language/Platform
Detergent JavaScript (ESM)
JoliTypo PHP
@frankrausch
frankrausch / FR.alfredappearance
Created March 22, 2019 14:02
My Alfred Appearance
{
"alfredtheme" : {
"result" : {
"textSpacing" : 4,
"subtext" : {
"size" : 12,
"colorSelected" : "#FFFFFFFF",
"font" : "CamingoCode",
"color" : "#7F7F7FFF"
},
@frankrausch
frankrausch / Alfred Create New File.scpt
Last active March 22, 2019 15:26
Alfred Workflow AppleScript to create an empty file in the current Finder window
on alfred_script(q)
set title to "Untitled.txt"
if q is not equal to "" then set title to q
tell application "Finder" to make new file at (the target of the front window) as alias with properties {name: title}
end alfred_script
@frankrausch
frankrausch / change-speed-of-mp3.sh
Last active November 4, 2024 15:14
Slow down or speed up all MP3 files in a folder with FFmpeg.
#/bin/sh
speed="0.7"
mkdir "speed-${speed}x"
for f in *.mp3
do ffmpeg -i "$f" -filter:a "atempo=${speed}" "./speed-${speed}x/$f"
done
@frankrausch
frankrausch / CustomDocumentWindow.swift
Last active September 4, 2018 06:43
Prevent NSPopover from stealing an NSTextField’s focus when using the popover to display live search results. Swift adaption of Wil Shipley’s solution (https://stackoverflow.com/a/21111462)
protocol PopoverFirstResponderStealingSuppression {
var suppressFirstResponderWhenPopoverShows: Bool { get }
}
class CustomDocumentWindow: NSWindow {
override func makeFirstResponder(_ responder: NSResponder?) -> Bool {
if responder != self.firstResponder,
let newFirstResponder = responder as? NSView {
let newFirstResponderWindow = newFirstResponder.window
@frankrausch
frankrausch / make-icons.sh
Last active December 16, 2017 15:35
Compile individual SVG icons into one SASS file as data URIs
sourceFiles="../assets/icons/*.svg"
destFile="../assets/sass/_icons.svg.scss"
classPrefix=".icon-"
echo "Compiling icons from "$sourceFiles" into "$destFile" …"
echo "" > $destFile
for fileWithPath in ../assets/icons/*.svg;
do
contents=$(cat $fileWithPath)