Skip to content

Instantly share code, notes, and snippets.

View marcprux's full-sized avatar
🔆

Marc Prud'hommeaux marcprux

🔆
  • New England
  • 11:20 (UTC -04:00)
View GitHub Profile
/**
```
Thread 1 Queue : com.apple.main-thread (serial)
#0 0x00007fff2cb8dead in swift_retain ()
#1 0x00007fff2cb90e55 in swift::metadataimpl::ValueWitnesses<swift::metadataimpl::SwiftRetainableBox>::initializeWithCopy(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*) ()
#2 0x00007fff2cbaf29d in swift::metadataimpl::ValueWitnesses<swift::metadataimpl::OpaqueExistentialBox<1u> >::initializeWithCopy(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*) ()
#3 0x00007fff421b8f10 in outlined init with copy of ViewList? ()
#4 0x00007fff421b8e1a in TransformedList.TransformItem.apply(sublist:) ()
#5 0x00007fff421b8e3e in TransformedList.TransformItem.apply(sublist:) ()
#6 0x00007fff421b8783 in closure #1 in ViewList.visitChildNodes(from:transform:applying:) ()
@marcprux
marcprux / FormDemoApp.swift
Created February 17, 2021 22:54
Example of aligning labels in SwiftUI.Form on macOS
//
// FormDemoApp.swift
// FormDemo
//
// Created by Marc Prud'hommeaux
//
import SwiftUI
@main
@marcprux
marcprux / AlignmentGuides.swift
Created February 28, 2020 17:57
Example of how to use `alignmentGuide` to align components along two dimensions
//
// ContentView.swift
// AlignDemo
//
// Created by Marc Prud'hommeaux on 2/28/20.
// Copyright © 2020 Glimpse I/O. All rights reserved.
//
import SwiftUI
//
// Demonstration of how to use `anchorPreference` to mimic the floating selection
// behavior of `SegmentedPickerStyle`.
//
// Created by Marc Prud'hommeaux on 12/10/19.
//
import SwiftUI
public extension View {
@marcprux
marcprux / ExpressibleByColorComponents.swift
Last active August 15, 2024 21:19
Color constants that can be declared in a single place and used for all of UIColor, NSColor, CIColor, CGColor, and SwiftUI.Color
/// A color instance that can be expressed by red, green, blue, and alpha components.
///
/// Conformed to by:
/// - `CoreGraphics.CGColor`
/// - `CoreImage.CIColor`
/// - `UIKit.UIColor`
/// - `AppKit.NSColor`
/// - `SwiftUI.Color`
public protocol ExpressibleByColorComponents {
/// Create an instance of this color from the given color components.
@marcprux
marcprux / SFSymbols.swift
Created June 6, 2019 01:27
All the SFSymbol images as extensions of UIImage & NSImage
#if os(macOS)
import AppKit
public typealias UXImage = NSImage
#elseif os(iOS)
import UIKit
public typealias UXImage = UIImage
#endif
/// Extensions for system images included in SF Symbols
@available(macOS 10.15, iOS 13.0, *)
@marcprux
marcprux / SHA1.swift
Created May 1, 2018 16:13
A single-file SHA1 hash function, modified from the CryptoSwift project
//
// SHA1.swift
// Glib
//
// Created by Marc Prud'hommeaux on 5/1/18.
// Copyright © 2018 Marc Prud'hommeaux. All rights reserved.
//
// A single-file conversion of the SHA1 code from: CryptoSwift
//
// Copyright (C) 2014-2017 Marcin Krzyżanowski <[email protected]>
@marcprux
marcprux / NSURL+Zip.swift
Created September 22, 2015 17:23
Categories on NSURL and NSData to create a zip archive without any external dependencies
public extension NSURL {
/// Creates a zip archive of the file/folder represented by this URL and returns a references to the zipped file
///
/// - parameter dest: the destination URL; if nil, the destination will be this URL with ".zip" appended
func zip(dest: NSURL? = nil) throws -> NSURL {
let destURL = dest ?? self.URLByAppendingPathExtension("zip")
let fm = NSFileManager.defaultManager()
var isDir: ObjCBool = false
//
// Demonstration of using a channel to receive and dispatch IOHIDManager events using the ChannelZ framework.
//
// Created by Marc Prud'hommeaux on 3/8/15.
//
import Cocoa
import IOKit
import ChannelZ
@NSApplicationMain
@marcprux
marcprux / InversionOfExecution.swift
Last active August 29, 2015 14:16
Inversion of Execution in Swift
/// InversionOfExecution.swift – Marc Prud'hommeaux <[email protected]>
///
/// Demonstration of an *Inversion of Execution* (**IoE**) technique for how the same function
/// can be executed either synchronously with a return value or asynchronously with a
/// callback block depending on an optional trailing `iex` (inverted executor closure.
///
/// • When executed without a trailing closure, the result is provided as a return value:
///
/// `let result: Int = sum([1, 2])`
///