Skip to content

Instantly share code, notes, and snippets.


Sven A. Schmidt finestructure

View GitHub Profile
View enums Swift book
enum Barcode {
case upc(Int, Int, Int, Int)
case qrCode(String)
var productBarcode = Barcode.upc(8, 85909, 51226, 3)
productBarcode = .qrCode("ABCDEFGHIJKLMNOP")
switch productBarcode {
finestructure / compare.swift
Created Feb 23, 2021
NSImage diff speed test
View compare.swift
import Cocoa
func context(for cgImage: CGImage) -> CGContext? {
let space = cgImage.colorSpace,
let context = CGContext(
data: nil,
width: cgImage.width,
height: cgImage.height,
bitsPerComponent: cgImage.bitsPerComponent,
View Multi-version swift build Makefile
@# just delete specific directories instead of .builds so we don't
@# have to re-fetch dependencies
@rm -f .build/debug
@rm -rf .build/x86_64-apple-macosx/
@rm -rf .build/x86_64-unknown-linux/
@rm -rf .build/x86_64-unknown-linux-gnu/
macos-spm-4.2: clean
View Wrap.swift
// See:
import SwiftUI
#if os(iOS)
public struct Wrap<Wrapped: UIView>: UIViewRepresentable {
public typealias Updater = (Wrapped, Context) -> Void
var makeView: () -> Wrapped
finestructure / test_run.swift
Created Apr 9, 2020
Test for adapting a progress handler to Effect.subject
View test_run.swift
import Combine
import ComposableArchitecture
import ComposableArchitectureTestSupport
import XCTest
class MainViewTests: XCTestCase {
func test_run() throws {
// Setup
struct State: Equatable {
var busy = false
finestructure / CAProtocols.swift
Last active Apr 14, 2020
"Guidance protocols" for Composable Architecture
View CAProtocols.swift
// CAProtocols.swift
// RequirementEditor
// Created by Sven A. Schmidt on 29/03/2020.
// Copyright © 2020 finestructure. All rights reserved.
import SwiftUI
View gist:a9dcda2b5c05ce287925428f13a857d6
// Playground generated with 🏟 Arena (
// ℹ️ If running the playground fails with an error "no such module ..."
// go to Product -> Build to re-trigger building the SPM package.
// ℹ️ Please restart Xcode if autocomplete is not working.
// Created by running
// arena -n text-field
import ComposableArchitecture
import ComposableArchitectureTestSupport
finestructure /
Last active Jun 23, 2020
Homebrew app release
finestructure / dispatchMain.swift
Created Feb 10, 2020
Swift scripting example use of dispatchMain
View dispatchMain.swift
#!/usr/bin/env swift
import Foundation
import Dispatch
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
finestructure /
Last active Aug 12, 2020
Make a playground with access to an SPM library ready for importing
#!/usr/bin/env bash
set -eux