Skip to content

Instantly share code, notes, and snippets.

View helje5's full-sized avatar

Helge Heß helje5

View GitHub Profile
@helje5
helje5 / GridApp.swift
Created October 20, 2024 16:33
GridApp.swift
import SwiftUI
import Charts
// Required entitlement:
// <key>com.apple.security.network.client</key><true/>
enum Signal: Int { case red, yellow, green }
struct Value {
let date : Date
@helje5
helje5 / ZzCompression.swift
Created July 15, 2024 11:44
Compression in Swift on Darwin Platforms
//
// ZzCompression.swift
// Core/S
//
// Created by Helge Heß on 25.10.19.
//
import Compression
public extension Data {
@helje5
helje5 / Bindable produces Binding.txt
Created July 2, 2024 21:43
What a Binding produced by Bindable looks like
▿ SwiftUI.Binding<Swift.Bool>
▿ transaction: SwiftUI.Transaction
▿ plist: []
- elements: nil
▿ location: SwiftUI.LocationBox<SwiftUI.Binding<Swift.Bool>.(unknown context at $1c460b9d4).ScopedLocation> #0
- super: SwiftUI.AnyLocation<Swift.Bool>
- super: SwiftUI.AnyLocationBase
▿ location: SwiftUI.Binding<Swift.Bool>.(unknown context at $1c460b9d4).ScopedLocation
▿ base: SwiftUI.LocationBox<SwiftUI.(unknown context at $1c3c342f4).ObjectLocation<TestGroup.Option, Swift.Bool>> #1
- super: SwiftUI.AnyLocation<Swift.Bool>
@helje5
helje5 / 2024-06-30-CoreData-SimpleUsers.txt
Created June 30, 2024 13:07
CoreData Simple Object Insert
💽 ===============
💽 CoreData: 1 Simple Objects
===============
CoreData: annotation: Connecting to sqlite database file at "/var/mobile/Containers/Data/Application/556D618D-E701-4FCC-A879-D62AB3747F0F/Library/Application Support/CoreUserDB"
CoreData: annotation: creating schema.
CoreData: sql: pragma page_size=4096
CoreData: sql: pragma auto_vacuum=2
CoreData: sql: BEGIN EXCLUSIVE
CoreData: sql: SELECT TBL_NAME FROM SQLITE_MASTER WHERE TBL_NAME = 'Z_METADATA'
CoreData: sql: CREATE TABLE ZCOREUSER ( Z_PK INTEGER PRIMARY KEY, Z_ENT INTEGER, Z_OPT INTEGER, ZAGE INTEGER, ZFIRSTNAME VARCHAR, ZSURNAME VARCHAR, ZID BLOB )
@helje5
helje5 / RustWasm.md
Last active April 7, 2024 13:38
Compile a Sum Rust Function

Install rust using rustup

brew install rustup
rustup-init
# new shell for env (or source .cargo/env), then:
rustup target add wasm32-wasi

Compile Cowsay

@helje5
helje5 / ListCellSizingFlicker.swift
Last active October 16, 2023 21:30
ListCellSizingFlicker
import SwiftUI
struct Item: Identifiable {
let id = UUID()
let title = "Hello"
}
let items = [
Item(), Item(), Item(), Item(), Item(), Item(), Item(), Item(), Item(), Item(), Item(),
Item(), Item(), Item(), Item(), Item(), Item(), Item(),
@helje5
helje5 / StateObservable.swift
Created September 16, 2023 13:16
An `Observable` property wrapper that only creates the observable value once
/**
* An Observable property wrapper that only creates the observable
* value once.
*
* Example:
* ```swift
* @Observable class Item {
* }
*
* struct MyView: View {
@helje5
helje5 / RepeatedModelInits.swift
Last active September 16, 2023 11:34
Repeated Model Inits w/ State
import SwiftUI
@Observable class Tester {
init() { print("INIT:", ObjectIdentifier(self)) }
deinit { print("DEINIT:", ObjectIdentifier(self)) }
}
struct ContentView: View {
struct Nested: View {
@helje5
helje5 / SwiftData Inverse Relationships.swift
Created September 13, 2023 21:36
SwiftData Inverse Relationships
import SwiftUI
import SwiftData
@Model final class Address {
let street = "Am Geldspeicher 1"
var contact : Contact?
init() {}
}
@Model final class Contact {
@helje5
helje5 / SwiftUIDataUnitTest.swift
Created August 17, 2023 16:19
Unit Testing a SwiftUI Query
//
// Created by Helge Heß.
// Copyright © 2023 ZeeZide GmbH.
//
import XCTest
import UIKit
import SwiftData
import SwiftUI