Skip to content

Instantly share code, notes, and snippets.

View narciszait's full-sized avatar

Narcis narciszait

  • App developer
  • Copenhagen, Denmark
View GitHub Profile
//
// LikeView.swift
// lottie-first
//
// Created by Matthew Young on 12/31/22.
//
import SwiftUI
import Lottie
@alexito4
alexito4 / Task.swift
Created October 12, 2022 21:21
SwiftUI View.task backwards compatibility
import Foundation
import SwiftUI
public extension View {
@available(iOS, obsoleted: 15.0, message: "SwiftUI.View.task is available on iOS 15.")
@_disfavoredOverload
@inlinable func task(
priority: _Concurrency.TaskPriority = .userInitiated,
@_inheritActorContext _ action: @escaping @Sendable () async -> Swift.Void
) -> some SwiftUI.View {
import UIKit
// Reference Video: https://youtu.be/iqpAP7s3b-8
struct AnchoredConstraints {
var top, leading, bottom, trailing, width, height: NSLayoutConstraint?
}
let DeviceSize = UIScreen.main.bounds.size
@doozMen
doozMen / LocalNetworkAuthorization.swift
Created February 25, 2022 15:44
Uses bonjour networking to relialby check if user has granted local network access with async await as of iOS14
import Foundation
import Network
/// Uses bonjour networking to relialby check if user has granted local network access
/// How to use:
/// Add LocalNetworkAuthorization class to your project
/// Open .plist file and add "_bonjour._tcp", "_lnp._tcp.", as a values under "Bonjour services"
/// Call requestAuthorization() to trigger the prompt or get the authorization status if it already been approved/denied
/// about the author: https://stackoverflow.com/a/67758105/705761
@ktustanowski
ktustanowski / VNClassifyImageRequest.Supportedidentifiers.txt
Last active January 12, 2022 19:39
Contains a list of supported identifiers for VNClassifyImageRequest (VNClassifyImageRequestRevision1).
▿ 1303 elements
- 0 : "abacus"
- 1 : "accordion"
- 2 : "acorn"
- 3 : "acrobat"
- 4 : "adult"
- 5 : "adult_cat"
- 6 : "agriculture"
- 7 : "aircraft"
- 8 : "airplane"
@tkhelm
tkhelm / CoreDataWithCombine.swift
Last active December 27, 2023 08:37
CoreDataWithCombine
//******* STORAGE MODEL ****************
import CoreData
import Combine
class URLMetadataStorage: NSObject, ObservableObject {
static let shared = URLMetadataStorage()
let parentContext = PersistenceController.shared.container.viewContext
// Author: SwiftUI-Lab (www.swiftui-lab.com)
// Description: This code is part of the "Advanced SwiftUI Animations - Part 5"
// Article: https://swiftui-lab.com/swiftui-animations-part5/
import SwiftUI
struct ContentView: View {
var body: some View {
DigitalRain()
}
@helje5
helje5 / Tows.swift
Last active June 12, 2022 06:33
An 82-liner SwiftUI script similar to CodeCows 🐮
import SwiftUI
import cows // @AlwaysRightInstitute
struct ContentView: View {
@State var searchString = ""
@State var matches = allCows
@State var selectedCow : String?
let font = Font(NSFont
@zhuowei
zhuowei / Ensemble.plist
Last active September 18, 2023 06:26
Put this file as /Library/Preferences/FeatureFlags/Domain/Ensemble.plist and reboot to (hopefully) turn on Universal Control on macOS 12
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- not sure which one it is, so set both -->
<key>Ensemble</key>
<dict>
<key>Enabled</key>
<true/>
</dict>