This file contains hidden or 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
| @preconcurrency import Foundation | |
| extension _KeyValueCodingAndObserving { | |
| func observe<Value>( | |
| _ keyPath: KeyPath<Self, Value>, | |
| options: NSKeyValueObservingOptions = [], | |
| bufferingPolicy limit: AsyncStream<NSKeyValueObservedChange<Value>>.Continuation.BufferingPolicy = .unbounded | |
| ) -> AsyncStream<NSKeyValueObservedChange<Value>> { | |
| let (stream, continuation) = AsyncStream<NSKeyValueObservedChange<Value>>.makeStream(bufferingPolicy: limit) | |
This file contains hidden or 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 where Self: Shape { | |
| func glow( | |
| fill: some ShapeStyle, | |
| lineWidth: Double, | |
| blurRadius: Double = 8.0, | |
| lineCap: CGLineCap = .round | |
| ) -> some View { | |
| self |
This file contains hidden or 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 | |
| // MARK: - Extensions | |
| extension URL { | |
| var isDirectory: Bool { | |
| (try? resourceValues(forKeys: [.isDirectoryKey]))?.isDirectory == true | |
| } | |
| } |
This file contains hidden or 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 | |
| struct ContentView: View { | |
| @StateObject var service = ChatGPTService() | |
| @State var textResponse = "" | |
| var body: some View { | |
| VStack { | |
| Text("Bot says: \(textResponse)") | |
| Button { | |
| Task { |
This file contains hidden or 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
| Apple Docs | |
| - AVFoundation: https://developer.apple.com/documentation/avfoundation | |
| - AVAudioEngine: https://developer.apple.com/documentation/avfaudio/avaudioengine | |
| - AVAudioEngine intro, WWDC15: https://developer.apple.com/videos/play/wwdc2015/507/ | |
| - AVAudioPCMBuffer: https://developer.apple.com/documentation/avfaudio/avaudiopcmbuffer | |
| - Accelerate vDSP: https://developer.apple.com/documentation/accelerate/vdsp | |
| Talks: | |
| - Анастасия Свириденко — Аудио в iOS: время приключений!: https://www.youtube.com/watch?v=m_N3hiVuxLI |
This file contains hidden or 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 Calendar { | |
| func generateDates( | |
| inside interval: DateInterval, | |
| matching components: DateComponents | |
| ) -> [Date] { | |
| var dates: [Date] = [] | |
| dates.append(interval.start) |
This file contains hidden or 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 UIKit | |
| import AVFoundation | |
| import Photos | |
| import MobileCoreServices | |
| class ViewController: UIViewController { | |
| override func viewDidAppear(_ animated: Bool) { | |
| super.viewDidAppear(animated) | |
| startVideoToGIFProcess() |
This file contains hidden or 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
| // | |
| // GIF2MP4.swift | |
| // | |
| // Created by PowHu Yang on 2020/4/24. | |
| // Copyright © 2020 PowHu Yang. All rights reserved. | |
| // | |
| /* How to use | |
| let data = try! Data(contentsOf: Bundle.main.url(forResource: "gif", withExtension: "gif")!) | |
| let tempUrl = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("temp.mp4") |