Skip to content

Instantly share code, notes, and snippets.

View jaekong's full-sized avatar

Jae Kong jaekong

View GitHub Profile
@jaekong
jaekong / iPhoneSensorDimensions.swift
Created October 23, 2024 05:32
iPhone supported by iOS 18 and their respective Face ID sensor array - notches, or dynamic islands - dimensions (in pts)
import Foundation
import RegexBuilder
/// iPhone supported by iOS 18 and their respective Face ID sensor array dimensions (in pts)
/// (Notches or Dynamic Islands)
enum iOSDevice: Comparable {
case iPhoneSE(generation: Int) // 2nd, 3rd
case iPhoneXR
case iPhoneXS(size: iOSDeviceSize, globalModel: Bool) // normal, max
case iPhone11(moniker: iOSDeviceMoniker?, size: iOSDeviceSize) // normal, pro, promax
@jaekong
jaekong / cli.swift
Last active September 19, 2024 12:18
cli.swift - A collection of small snippets for easy Swift command-line scripting
#!/usr/bin/env swift
import Foundation
@discardableResult
func run(_ command: String, shell: String = "zsh", passthrough: Bool = false, stdInContent: String? = nil) throws -> String {
let process = Process()
let stdOut = Pipe()
let stdErr = Pipe()
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Process: Godot [30717]
Path: /Applications/Godot.app/Contents/MacOS/Godot
Identifier: org.godotengine.godot
Version: 4.2.1 (4.2.1)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]

Privacy Policy

Jaewon Choi built the Isotope app as a Commercial app. This SERVICE is provided by Jaewon Choi and is intended for use as is.

This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service.

If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy.

The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which are accessible at Isotope unless otherwise defined in this Privacy Policy.

최재원(이하 '개발자')은(는) 「개인정보 보호법」 제30조에 따라 정보주체의 개인정보를 보호하고 이와 관련한 고충을 신속하고 원활하게 처리할 수 있도록 하기 위하여 다음과 같이 개인정보 처리방침을 수립·공개합니다.

○ 이 개인정보처리방침은 2023년 1월 1부터 적용됩니다.

제1조(개인정보의 처리 목적)

최재원(이하 '개발자')은(는) 다음의 목적을 위하여 개인정보를 처리합니다. 처리하고 있는 개인정보는 다음의 목적 이외의 용도로는 이용되지 않으며 이용 목적이 변경되는 경우에는 「개인정보 보호법」 제18조에 따라 별도의 동의를 받는 등 필요한 조치를 이행할 예정입니다.

  1. 재화 또는 서비스 제공
@jaekong
jaekong / CRUDController.swift
Last active April 16, 2021 15:26
CRUD Controller protocol for Vapor 4 and Swift 5.2. It adds basic REST API for CRUD-ing any model with an UUID identifier. It is based on the default controller example, but has not been tested yet. A controller struct can conform to this protocol by adding typealias M for your Model, and adding a variable called path that determines subpath of …
import Fluent
import Vapor
protocol CRUDController: RouteCollection {
associatedtype M: Model, Content where M.IDValue == UUID
var path: [PathComponent] { get set }
init()
}
@jaekong
jaekong / RequestOK.swift
Created January 20, 2021 09:04
A simple extension for Vapor 4 to tell if the request was accepted or not.
import Vapor
extension ClientResponse {
var ok: Bool {
get {
return self.status.code >= 200 && self.status.code < 300
}
}
}
@jaekong
jaekong / ByteToString.swift
Created August 18, 2020 16:39
Small Swift extension for getting proper binary representation of UInt8.
extension UInt8 {
var binaryRepresentation: String {
get {
let number = String(self, radix: 2)
let padding = String(repeating: "0", count: leadingZeroBitCount)
return String(padding + number)
}
}
}
@jaekong
jaekong / CollectionSplitInto.swift
Last active August 22, 2021 09:16
Info: This is now irrelevant since Swift Algorithms package now contains a chunks(ofCount:) method. A simple Swift extension to extend Collection protocol to have a split(into:) function. It is useful when you have to chunk an array or data to equal sized pieces.
// Info: This is now irrelevant since Swift Algorithms package now contains a chunks(ofCount:) method.
extension Collection where Index == Int {
func split(into size: Int) -> [Self.SubSequence] {
return stride(from: 0, to: count, by: size).map {
self[$0 ..< Swift.min($0 + size, count)]
}
}
}
@jaekong
jaekong / AudioBufferConversion.swift
Created August 10, 2019 14:38
AudioBuffer (or AVAudioPCMBuffer) to array of float / Float array to AudioBuffer (or AVAudioPCMBuffer)
import AVFoundation
extension AudioBuffer {
func array() -> [Float] {
return Array(UnsafeBufferPointer(self))
}
}
extension AVAudioPCMBuffer {
func array() -> [Float] {