Skip to content

Instantly share code, notes, and snippets.

@dvclmn
dvclmn / PreviewableSheetModifier.swift
Last active March 2, 2025 10:37
A thin(ish) wrapper around SwiftUI's `sheet(item:onDismiss:content:)` modifier, that's previewable on macOS.
/// > Note: You'll see I've referenced `isPreview` below.
/// > To run code for Previews only, place this somewhere,
/// > either as a global method, or anywhere close at hand.
///
/// ```swift
/// public var isPreview: Bool {
/// return ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1"
/// }
/// ```
@dvclmn
dvclmn / GridCanvas.swift
Last active December 10, 2024 10:18
Brief overview of GridCanvas data models
// MARK: - Canvas
struct GridCanvas: Equatable, Sendable {
var font: GridFont
var dimensions: Dimensions
/// Note: This array is a 'long straight line' of every Cell in the artwork.
/// Previously I was using a 2D array, as this better matched my mental
/// model for a typical Grid layout, but performance impact of iterating
/// over nested arrays became a concern.
import AppKit
import Neon
import TreeSitterMarkdown
import TreeSitterMarkdownInline
import SwiftTreeSitter
import TreeSitterClient
extension MarkdownViewController {
static func makeHighlighter(for textView: MarkdownTextView) throws -> TextViewHighlighter {
/*
See LICENSE folder for this sample’s licensing information.
Abstract:
The extension of CircleTextViewController that handles glyph substitution.
*/
import UIKit
extension CircleTextViewController {
import math
canvas = 2000
frameRate = 24
duration = 1400 # in milliseconds
txt = "snape"
tulipPath = "/Library/Application Support/Adobe/Fonts/Tulip3GX.ttf"
fontName = installFont(tulipPath)
var headings = document.getElementsByTagName('h1');
headings.onclick = function() {
console.log('You clicked on a heading!');
}
#MenuTitle: Task Launcher
# -*- coding: utf-8 -*-
#!/usr/bin/env python
# Created by Dave
__doc__="""
Task launcher
"""
### Modules
from vanilla import FloatingWindow, SquareButton
#MenuTitle: Toggle variant labels
# -*- coding: utf-8 -*-
# Created by Dave
__doc__="""
Toggle variant labels
"""
import vanilla
import GlyphsApp
def glyphListv1():
thisFont = Glyphs.font # frontmost font
thisGlyph = Glyphs.font.glyphs
v1 = "v1"
v1List = []
try:
def ToggleVariantLabelsOFF( self, sender ):
try: