This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// Airdrop Demo | |
// | |
// Created by Daniel Kuntz on 7/30/23. | |
// | |
import SwiftUI | |
struct ContentView: View { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
/** | |
### Exercises for the viewer | |
- Phase interrupt handling. | |
- Use Swift concurrency. | |
- Color scheme awareness. | |
- Rework animations to be more spring-like à la what shipped in `0.90.0`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import PlaygroundSupport | |
// constants | |
let cardWidth: CGFloat = 343 | |
let cardHeight: CGFloat = 212 | |
let spacing = 36 | |
let animation = Animation.spring() | |
let cardColors = [ | |
Color(UIColor.systemRed), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let jsonString = """ | |
{ | |
"S001": { | |
"firstName": "Tony", | |
"lastName": "Stark" | |
}, | |
"S002": { | |
"firstName": "Peter", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
extension View { | |
func eraseToAnyView() -> AnyView { | |
AnyView(self) | |
} | |
} | |
struct SizePreferenceKey: PreferenceKey { | |
typealias Value = CGSize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// PagerView.swift | |
// | |
// Created by Majid Jabrayilov on 12/5/19. | |
// Copyright © 2019 Majid Jabrayilov. All rights reserved. | |
// | |
import SwiftUI | |
struct PagerView<Content: View>: View { | |
let pageCount: Int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import simd | |
static func interpolate(desiredX: inout [Float], y: inout [Float]) -> [Float] { | |
let n = desiredX.count - 1 | |
let stride = vDSP_Stride(1) //Int Type Alias | |
let denominator = Float(n) / Float(y.count - 1) | |
let control: [Float] = desiredX.map { | |
let x = Float($0) / denominator | |
let smoothStep = Float(simd_smoothstep(0, 1, simd_fract(x))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Combine | |
enum APIError: Error, LocalizedError { | |
case unknown, apiError(reason: String), parserError(reason: String) | |
var errorDescription: String? { | |
switch self { | |
case .unknown: | |
return "Unknown error" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is how to automatically delete cached image previews from your Mastodon instance if they are older than 7 days. | |
Log in as your "mastodon" User or log in as root and then change to the "mastodon" user, who runs Mastodon: | |
# su - mastodon | |
Open crontab: | |
$ crontab -e | |
... and add these lines to your crontab: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
``` | |
// Encode a model with properties of type [String : Any] | |
var propertiesContainer = container.nestedContainer(keyedBy: DynamicKey.self, forKey: .properties) | |
if let properties = properties { | |
try propertiesContainer.encodeDynamicKeyValues(withDictionary: properties) | |
} | |
``` | |
*/ | |
struct DynamicKey: CodingKey { |
NewerOlder