Skip to content

Instantly share code, notes, and snippets.

View heestand-xyz's full-sized avatar

Anton Heestand heestand-xyz

View GitHub Profile
func csv(named name: String) -> [[String]]? {
guard let url: URL = Bundle.main.url(forResource: name, withExtension: "csv") else { return nil }
return csv(url: url)
}
func csv(url: URL) -> [[String]]? {
guard let text: String = try? String(contentsOf: url) else { return nil }
return csv(text: text)
}
@heestand-xyz
heestand-xyz / blur_view.swift
Created April 5, 2020 15:00
SwiftUI - View - Blur
import SwiftUI
struct BlurView: UIViewRepresentable {
let style: UIBlurEffect.Style
func makeUIView(context: UIViewRepresentableContext<BlurView>) -> UIVisualEffectView {
UIVisualEffectView(effect: UIBlurEffect(style: style))
}
public extension UIDevice {
static let modelName: String = {
var systemInfo = utsname()
uname(&systemInfo)
let machineMirror = Mirror(reflecting: systemInfo.machine)
let identifier = machineMirror.children.reduce("") { identifier, element in
guard let value = element.value as? Int8, value != 0 else { return identifier }
return identifier + String(UnicodeScalar(UInt8(value)))
}
@heestand-xyz
heestand-xyz / highlight-js_xcode-dark-mode.css
Last active December 23, 2023 05:13
Highlight.js - Style Sheet - Xcode Dark Mode
/*
//
// xcode-dark-mode.css
// Xcode Dark Mode
//
// Created by Hexagons on 2020-06-11.
// http://hexagons.net/
//
*/
@heestand-xyz
heestand-xyz / ClampedValue.swift
Created June 12, 2020 07:09
Swift - Property Wrapper - Clamped Value
@propertyWrapper
struct ClampedValue<F: FloatingPoint> {
var value: F
let min: F?
let max: F?
init(wrappedValue: F, min: F? = nil, max: F? = nil) {
value = wrappedValue
self.min = min
self.max = max
}
#if os(macOS)
import AppKit
#else
import UIKit
#endif
import SwiftUI
#if os(macOS)
typealias SomeImage = NSImage
#else
@heestand-xyz
heestand-xyz / Animator.swift
Last active November 30, 2023 01:09
Animator with Easing
import Foundation
import CoreGraphics
#if os(iOS)
import UIKit
#endif
struct Animator {
enum AnimationEase {
case linear
@heestand-xyz
heestand-xyz / maskPath.swift
Last active August 26, 2022 17:04
SwiftUI Path to Image Mask
import SwiftUI
import TextureMap
extension Path {
public func maskImage(size: CGSize) -> TMImage! {
guard let context = CGContext(data: nil,
width: Int(size.width),
height: Int(size.height),
@heestand-xyz
heestand-xyz / SplineDemo.swift
Last active August 27, 2022 17:20
Spline Demo in SwiftUI
//
// ContentView.swift
// Spline Demo
//
// Created by Anton Heestand on 2022-08-27.
//
import SwiftUI
struct ContentView: View {
@heestand-xyz
heestand-xyz / video-stabilization.swift
Last active April 28, 2023 08:53
Video Stabilization in Swift with AsyncGraphics
// Created by Anton Heestand with the help of GPT-4
// AsyncGraphics: https://github.com/heestand-xyz/AsyncGraphics
import SwiftUI
import AsyncGraphics
import Vision
struct ContentView: View {
@State var graphic: Graphic?