Skip to content

Instantly share code, notes, and snippets.

View antranapp's full-sized avatar

An Tran antranapp

View GitHub Profile
@Priva28
Priva28 / VisionOSUniformSizedWindow.swift
Created February 22, 2024 10:12
A window in visionOS with a changeable aspect ratio.
import SwiftUI
public struct UniformWindowGroup<Content: View>: Scene {
var id: String?
var maxWidth: CGFloat
var maxHeight: CGFloat
var aspectRatio: CGFloat
var content: Content
@State private var setSize: CGSize?
@MarcoEidinger
MarcoEidinger / findRequiredReasonAPIUsage.sh
Created August 21, 2023 19:55
A shell script to find if any "required reason API" are used in Swift or Objective-C files within that folder or subfolders
#!/bin/bash
# https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api
searchTerms=(
# File timestamp APIs
"creationDate"
"modificationDate"
"fileModificationDate"
"contentModificationDateKey"
"creationDateKey"
@gdavis
gdavis / ThreadSafe.swift
Last active March 18, 2024 14:17
ThreadSafe is a property wrapper that can be used to control atomic access to the underlying property while allowing concurrent access to reading the value.
//
// ThreadSafe.swift
// GDICore
//
// Created by Grant Davis on 1/2/21.
// Updated to support `_modify` accessor on 12/5/21.
//
// Copyright © 2021 Grant Davis Interactive, LLC. All rights reserved.
//
import Foundation
JSON:
https://unpkg.com/emoji.json@13.1.0/emoji.json
class EmojiManager: ObservableObject {
@Published var emojis: [EmojiObject] = []
init() {
decodeJSON()
@zarghol
zarghol / gist:3c0f29bdbe7a6317536bf0a8c76a7380
Created June 8, 2021 22:58
Experiment with new SwiftUI Canvas View
import SwiftUI
enum TrigonometricFunction: CaseIterable {
case sinus
case cosinus
func apply(_ value: Double) -> Double {
switch self {
case .cosinus:
return cos(value)
@MapaX
MapaX / makeXCFamework.sh
Created April 26, 2021 10:45
Shell script to create xcframeworks from MLKit frameworks
#!/bin/zsh
makeXCFramework () {
BASEDIR=$(pwd)
echo "Script location: ${BASEDIR}"
LIBNAME=$(basename $BASEDIR)
echo "lib is: $LIBNAME"
cd Frameworks
// Don't forget to add to the project:
// 1. DeepLabV3 - https://developer.apple.com/machine-learning/models/
// 2. CoreMLHelpers - https://github.com/hollance/CoreMLHelpers
enum RemoveBackroundResult {
case background
case finalImage
}
extension UIImage {
@matiaskorhonen
matiaskorhonen / ffmpeg-pad-and-overlay.sh
Last active March 12, 2024 08:57
Add a device frame to an iOS screen recording (specifically an iPhone 12 Pro)
# Record screen from simulator:
xcrun simctl io booted recordVideo appVideo.mov
# Full size screen recording
ffmpeg -i screen-recording.mp4 -i iPhone12ProOverlay.png \
-filter_complex "scale=-1:2532,pad=width=3656:height=2057:x=(ow-iw)/2:y=(oh-ih)/2,overlay=x=0:y=0" \
output.mp4
# Screen recording resized to 1920px height
ffmpeg -i screen-recording.mp4 -i iPhone12ProOverlay-3656.png \
@johnno1962
johnno1962 / InjectionInjection.md
Last active November 23, 2022 02:58
Injection Injection

InjectionIII is an app available that provides "code injection" functionality allowing you to update the implementation of functions, memeber function and SwiftUI content body properties without having to restart your application. This can be useful to iterate over code or design without having to rebuild and restart your application continuously.

https://github.com/johnno1962/InjectionIII

Part of the implementation of injection is that it requires a user to add the following line somewhere in their code:

Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle")?.load()
@ConfusedVorlon
ConfusedVorlon / HSHostingController.swift
Created April 11, 2020 10:03
HSHostingController, easily present fullscreen modals, safari, email, etc from SwiftUI
//
// HSHostingController.swift
// PuppySounds
//
// Created by Rob Jonson on 09/04/2020.
// Copyright © 2020 HobbyistSoftware. All rights reserved.
//
//HSHostingController.swift
import Foundation