Skip to content

Instantly share code, notes, and snippets.

You are an excellent, logical, programmer. You are currently acting as my programming assistant.
Please keep the initial response short and to the point.
If a more lengthy reply and more details are needed it will be asked for.
- Follow the user's requirements carefully & to the letter.
- First think step-by-step.
- Briefly describe your plan for what to build in psuedocode, written out in detail.
- Then output the code in a single codeblock.
- Minimize any other prose and try to answer concisely, while still fully answering the request.
//
// TappableUILabelDemoViewController.swift
// Label Link Test
//
// Created by Kyle Howells on 2024-03-20.
//
import UIKit
@kylehowells
kylehowells / Tap links in UILabel.swift
Created March 20, 2024 01:24
Tap Links in UILabel
@kylehowells
kylehowells / CBManagerAuthorization+String.swift
Created March 9, 2023 01:18
Debug strings for CBManagerAuthorization
import Foundation
import CoreBluetooth
extension CBManagerAuthorization : CustomDebugStringConvertible {
public var debugDescription: String {
switch self {
case .allowedAlways: return "allowedAlways"
case .denied: return "denied"
case .notDetermined: return "notDetermined"
@kylehowells
kylehowells / WaveView.swift
Created February 25, 2023 23:27
Animates a wave ripple along the top
import UIKit
// MARK: - WaveView
class WaveView: UIView {
private var shapeLayer: CAShapeLayer = CAShapeLayer()
// MARK: - Animation Properties
import SceneKit
struct SceneKitBoundingBox {
let backLeftTop: SCNVector3
let backLeftBottom: SCNVector3
let backRightTop: SCNVector3
let backRightBottom: SCNVector3
let frontLeftTop: SCNVector3
import UIKit
extension UIResponder {
private weak static var _currentFirstResponder: UIResponder? = nil
public static var current: UIResponder? {
UIResponder._currentFirstResponder = nil
UIApplication.shared.sendAction(#selector(findFirstResponder(sender:)), to: nil, from: nil, for: nil)
return UIResponder._currentFirstResponder
}
private func AVMakeRectFill(aspectRatio: CGSize, insideRect boundingRect: CGRect) -> CGRect {
let targetSize = boundingRect.size
if targetSize == .zero {
return .zero
}
let widthRatio = targetSize.width / aspectRatio.width
let heightRatio = targetSize.height / aspectRatio.height
let scalingFactor = max(widthRatio, heightRatio)
@kylehowells
kylehowells / MP4Exporter.swift
Created July 3, 2022 03:56
Export UIView as MP4 in Swift using AVFoundation AVAssetWriter
//
// MP4Exporter.swift
// Code Examples
//
// Created by Kyle Howells on 03/07/2022.
//
import Foundation
import UIKit
import AVFoundation
import CoreGraphics
import UIKit
import AVFoundation
extension UIImage {
func resized(within newSize: CGSize, outputScale: CGFloat? = nil) -> UIImage {
let originalSize = self.size
let withinBounds = CGRect(x: 0, y: 0, width: newSize.width, height: newSize.height)