This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
import UIKit | |
/// A finite state machine | |
final class FSM<State, Transition>: ObservableObject where State: Hashable, Transition: Hashable { | |
/// current state | |
@Published private(set) var state: State | |
/// state transition graph |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
import Cocoa | |
import XCPlayground | |
// Let asynchronous code run | |
XCPSetExecutionShouldContinueIndefinitely() | |
public func log<T>(x: T) { | |
print("\(x)") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MaterialIcons for Cocoa | |
import Cocoa | |
import CoreText | |
public enum MaterialIcon: String { | |
case ThreeDRotation = "\u{e84d}" | |
case Accessibility = "\u{e84e}" | |
case AccountBalance = "\u{e84f}" | |
case AccountBalanceWallet = "\u{e850}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
/** | |
EventType serves as a strongly typed alternative to NSNotification and its name property. | |
To create the equivalent of a simple notification with no associated information, declare | |
an empty struct conforming to EventType: | |
struct AppDataDidRefreshEvent: EventType {} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DraggingStackView.swift | |
// Analysis | |
// | |
// Created by Mark Onyschuk on 2017-02-02. | |
// Copyright © 2017 Mark Onyschuk. All rights reserved. | |
// | |
import Cocoa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct DecimalString { | |
var value: String | |
private init(_ value: String) { | |
self.value = value | |
} | |
init(digits string: String) { | |
let digits = CharacterSet.decimalDigits | |
self.value = string.unicodeScalars.filter { digits.contains($0) } .map { String($0) } .joined() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// RLE.swift | |
// RLE | |
// | |
// Created by Mark Onyschuk on 2017-08-31. | |
// Copyright © 2017 Mark Onyschuk. All rights reserved. | |
// | |
import Foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// RunLengthEncoding | |
// RLE | |
// | |
// Created by Mark Onyschuk on 2017-08-31. | |
// Copyright © 2017 Mark Onyschuk. All rights reserved. | |
// | |
import Foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSPopover_OverrideAnimation.h | |
// scrl (macOS) | |
// | |
// Created by Mark Onyschuk on 2022-02-07. | |
// | |
#import <Cocoa/Cocoa.h> | |
NS_ASSUME_NONNULL_BEGIN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
#if canImport(Cocoa) | |
import Cocoa | |
#elseif canImport(UIKit) | |
import UIKit | |
#endif | |
public struct EdgeInsets { | |
var top, bottom, leading, trailing: CGFloat |