Skip to content

Instantly share code, notes, and snippets.

View lhoward's full-sized avatar

Luke Howard lhoward

View GitHub Profile
@lhoward
lhoward / IORingOSCServer.swift
Last active January 3, 2026 00:08
IORingSwift + OSCKit
import FoundationEssentials
#else
import Foundation
#endif
import OSCKitCore
import SocketAddress
import IORing
import IORingUtils
actor IORingOSCServer {
@lhoward
lhoward / rfc2459.swift
Created November 14, 2022 06:35
Swift types generated by asn1compile + ASN1CodingKit
/// HeimASN1Translator generated 2022-11-14 06:23:27 +0000
import Foundation
import BigNumber
import AnyCodable
import ASN1CodingKit
// ASN.1 module RFC2459 with explicit tagging
typealias Version = Int
let rfc3280_version_1: Version = 0
@lhoward
lhoward / SCExtras.c
Created March 7, 2022 01:30
SCDynamicStoreCreateWithHandler
#include <SystemConfiguration/SystemConfiguration.h>
#include "SCExtras.h"
static void
__SCDynamicStoreBlockCallBack(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info)
{
void (^block)(SCDynamicStoreRef store, CFArrayRef changedKeys) = info;
block(store, changedKeys);
}
import SwiftUI
struct AttributedTextView: TextView, UIViewRepresentable {
let content: NSAttributedString
@Binding var height: CGFloat
var font: UIFont? = nil
var textAlignment: NSTextAlignment = .left
var lineBreakMode: NSLineBreakMode = .byWordWrapping
var textColor: UIColor = UIColor.label
import SwiftUI
public protocol TextView {
var font: UIFont? { get set }
func font(_ font: Font?) -> Self
var textAlignment: NSTextAlignment { get set }
func multilineTextAlignment(_ alignment: TextAlignment) -> Self
var lineBreakMode: NSLineBreakMode { get set }
import SwiftUI
struct IsVisibleModifier: ViewModifier {
@Binding var isVisible: Bool
func body(content: Content) -> some View {
content
.onAppear {
self.isVisible = true
}
private struct ReselectTabViewModifier: ViewModifier {
@Environment(\.didReselectTab) private var didReselectTab
let visibleAction: (() -> Void)
let hiddenAction: (() -> Void)?
@State var isVisible = false
init(ifVisible visibleAction: @escaping (() -> Void),
else hiddenAction: (() -> Void)?) {
import SwiftUI
final class NavigationManager: ObservableObject {
var canPopToRootView: Bool // NB: this must not be @Published
init() {
self.canPopToRootView = true
}
}
import SwiftUI
private struct ScrollableModifier: ViewModifier {
func body(content: Content) -> some View {
ScrollView {
content
}
}
}
import SwiftUI
import Combine
private let motionShaked = PassthroughSubject<Void, Never>()
extension UIWindow {
open override func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) {
if motion == .motionShake {
motionShaked.send()
}