Skip to content

Instantly share code, notes, and snippets.

@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)
import SwiftUI
extension View where Self: Shape {
func glow(
fill: some ShapeStyle,
lineWidth: Double,
blurRadius: Double = 8.0,
lineCap: CGLineCap = .round
) -> some View {
self
import Foundation
// MARK: - Extensions
extension URL {
var isDirectory: Bool {
(try? resourceValues(forKeys: [.isDirectoryKey]))?.isDirectory == true
}
}
@MatthewWaller
MatthewWaller / SwiftUI+ChatGPT.swift
Last active August 9, 2023 03:19
SwiftUI Meets ChatGPT
import SwiftUI
struct ContentView: View {
@StateObject var service = ChatGPTService()
@State var textResponse = ""
var body: some View {
VStack {
Text("Bot says: \(textResponse)")
Button {
Task {
@HannaYakusevych
HannaYakusevych / Resources.txt
Last active June 2, 2025 22:20
A trip beyond AVPlayer
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
@mecid
mecid / Calendar.swift
Last active February 20, 2026 21:38
SwiftUI Calendar view using LazyVGrid
import SwiftUI
extension Calendar {
func generateDates(
inside interval: DateInterval,
matching components: DateComponents
) -> [Date] {
var dates: [Date] = []
dates.append(interval.start)
import UIKit
import AVFoundation
import Photos
import MobileCoreServices
class ViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
startVideoToGIFProcess()
@powhu
powhu / GIF2MP4.swift
Last active April 20, 2026 09:06
Swift 5.0 GIF to MP4
//
// 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")