Skip to content

Instantly share code, notes, and snippets.

@pilgwon
pilgwon / TCA_README_KR.md
Last active July 18, 2024 11:52
TCA README in Korean

The Composable Architecture

The Composable Architecture(TCA)는 일관되고 이해할 수 있는 방식으로 어플리케이션을 만들기 위해 탄생한 라이브러리입니다. 합성(Composition), 테스팅(Testing) 그리고 인체 공학(Ergonomics)을 염두에 둔 TCA는 SwiftUI, UIKit을 지원하며 모든 애플 플랫폼(iOS, macOS, tvOS, watchOS)에서 사용 가능합니다.

// 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 {
@JCSooHwanCho
JCSooHwanCho / FileIO.swift
Last active June 20, 2024 02:26
ps할 때 입력을 한꺼번에 받기 위한 유틸리티 클래스. fread의 swift 버전.
import Foundation
final class FileIO {
private let buffer:[UInt8]
private var index: Int = 0
init(fileHandle: FileHandle = FileHandle.standardInput) {
buffer = Array(try! fileHandle.readToEnd()!)+[UInt8(0)] // 인덱스 범위 넘어가는 것 방지
@darrarski
darrarski / FetchedResultsPublisher.swift
Last active June 6, 2024 18:40
Swift-Combine-CoreData-Fetched-Results-Publisher
import Combine
import CoreData
public final class FetchedResultsPublisher
<ResultType>
: Publisher
where
ResultType: NSFetchRequestResult
{
struct LazyView<Content: View>: View {
let build: () -> Content
init(_ build: @autoclosure @escaping () -> Content) {
self.build = build
}
var body: Content {
build()
}
}
@AliSoftware
AliSoftware / Bindings.swift
Last active July 9, 2024 22:02
Re-implementation of @binding and @State (from SwiftUI) myself to better understand it
/*:
This is a concept re-implementation of the @Binding and @State property wrappers from SwiftUI
The only purpose of this code is to implement those wrappers myself
just to understand how they work internally and why they are needed,
⚠️ This is not supposed to be a reference implementation nor cover all
subtleties of the real Binding and State types.
The only purpose of this playground is to show how re-implementing
them myself has helped me understand the whole thing better
@Azoy
Azoy / syscall.swift
Last active August 25, 2023 21:49
Raw system calls in Swift
// macOS x86_64 syscall works as follows:
// Syscall id is moved into rax
// 1st argument is moved into rdi
// 2nd argument is moved into rsi
// 3rd argument is moved into rdx
// ... plus some more
// Return value is stored in rax (where we put syscall value)
// Mac syscall enum that contains the value to correctly call it
enum Syscall: Int {
// swift/stdlib/public/runtime/Metadata.cpp をプリプロセッサのみ実行した結果から抜粋
struct ValueWitnessTable;
namespace value_witness_types {
typedef OpaqueValue * (*initializeBufferWithCopyOfBuffer) (ValueBuffer *, ValueBuffer *, const Metadata *);
typedef void (*destroy) (OpaqueValue *, const Metadata *);
typedef OpaqueValue * (*initializeWithCopy) (OpaqueValue *, OpaqueValue *, const Metadata *);
typedef OpaqueValue * (*assignWithCopy) (OpaqueValue *, OpaqueValue *, const Metadata *);
typedef OpaqueValue * (*initializeWithTake) (OpaqueValue *, OpaqueValue *, const Metadata *);
@fuxingloh
fuxingloh / UILabelSize.swift
Last active March 29, 2024 07:26
iOS Swift: How to find text width, text height or size of UILabel.
extension UILabel {
func textWidth() -> CGFloat {
return UILabel.textWidth(label: self)
}
class func textWidth(label: UILabel) -> CGFloat {
return textWidth(label: label, text: label.text!)
}
class func textWidth(label: UILabel, text: String) -> CGFloat {
@ninanung
ninanung / forMe.md
Last active July 25, 2023 00:35
사실은 내가 보기위한 마크다운 문법설명서 - 1. 제목과 호라이즌

너와 나를 위한 마크다운 문법정리!

마크다운 문법, 정말 간단하지만 구글링을 해도 뭔가 좀 애매합니다. 설명이 다르거나 부족하거나 저 같은 초보자가 보고 배우기 애매한 경우가 좀 있었습니다. 그래서 저 스스로의 마크다운 문법 공부를 위한 실습 겸 가이드를 위해 문법정리를 작성해 보고자 합니다. 참고로 이 정리는 깃허브에서 사용하는 것을 전제로 합니다.

1.제목과 호라이즌 - html의 h1테그와 hr테그

1-1.제목

먼저 제목입니다. 제목을 쓰는 방법은 두 가지로 나눌 수 있습니다.

  • 제목과 함께 hr, 즉 호라이즌을 명시적으로 같이 쓴다.