Skip to content

Instantly share code, notes, and snippets.

View gkhackers's full-sized avatar

Kyongjin Seo gkhackers

View GitHub Profile
@dankamel
dankamel / BottomSheetDesign.swift
Last active September 15, 2025 09:15
Native iOS 15 Adjustable Bottom Sheet In SwiftUI (half bottom sheet)
import SwiftUI
struct BottomSheetDesign: View {
@State var showSheet: Bool? = nil
var body: some View {
Button(action: { showSheet = true }) {
@npu3pak
npu3pak / fix_twitter_warnings.sh
Last active August 20, 2023 16:39
This script fixes all TwitterKit related warnings in XCode 10.1. Add new run script build phase with this code:
readonly MODULEMAP="${PODS_ROOT}/TwitterCore/iOS/TwitterCore.framework/Modules/module.private.modulemap"
readonly HEADER="${PODS_ROOT}/TwitterCore/iOS/TwitterCore.framework/Headers/TwitterCore.h"
if ! grep -q "TwitterCore_Private" "${MODULEMAP}"; then
cat >"${MODULEMAP}" <<EOL
module TwitterCore_Private {
}
EOL
fi
@fousa
fousa / FairPlayer.swift
Last active June 1, 2023 12:28
Integrate HLS with FairPlay.
class FairPlayer: AVPlayer {
private let queue = DispatchQueue(label: "com.icapps.fairplay.queue")
func play(asset: AVURLAsset) {
// Set the resource loader delegate to this class. The `resourceLoader`'s delegate will be
// triggered when FairPlay handling is required.
asset.resourceLoader.setDelegate(self, queue: queue)
// Load the asset in the player.
@Hardtack
Hardtack / FunctionalReactiveMVC.md
Last active August 1, 2019 07:54
순수 ν•¨μˆ˜ν˜• μƒνƒœ 전이와 Functional Reactive ν”„λ‘œκ·Έλž˜λ°μ„ μ΄μš©ν•œ Reactive Model View Controller 섀계 νŒ¨ν„΄ (1)

순수 ν•¨μˆ˜ν˜• μƒνƒœ 전이와 Functional Reactive ν”„λ‘œκ·Έλž˜λ°μ„ μ΄μš©ν•œ Reactive Model View Controller 섀계 νŒ¨ν„΄ (1)

졜근 λ§Žμ€ ν”„λ‘œκ·Έλž˜λ° μ–Έμ–΄μ—μ„œλŠ” ν•¨μˆ˜ν˜• ν”„λ‘œκ·Έλž˜λ°μ„ μ§€μ›ν•˜κΈ° μœ„ν•œ λ‹€μ–‘ν•œ 도ꡬ듀을 μ œκ³΅ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. 그쀑 SwiftλŠ” μ΅œμ‹  νŠΈλ Œλ“œκ°€ 많이 반영된 μ–Έμ–΄λ‘œμ¨, 슀λͺ°ν† ν¬ν˜• 객체지ν–₯ ν”„λ‘œκ·Έλž˜λ°κ³Ό ν•¨μˆ˜ν˜• ν”„λ‘œκ·Έλž˜λ°μ„ ν•¨κ»˜ μ§€μ›ν•¨μœΌλ‘œμ¨ κ°œλ°œμžλ“€μ—κ²Œ ν•¨μˆ˜ν˜• ν”„λ‘œκ·Έλž˜λ°μ— λŒ€ν•œ 접근성을 μ¦κ°€μ‹œμΌ°μŠ΅λ‹ˆλ‹€.

그리고 Reactive ν”„λ‘œκ·Έλž˜λ°μ΄ μ‘°λͺ…을 λ°›κΈ° μ‹œμž‘ν•˜λ©°, Reactive Extensionκ³Ό 같은 ν›Œλ₯­ν•œ λ¦¬μ•‘ν‹°λΈŒ ν”„λ‘œκ·Έλž˜λ°μ„ μœ„ν•œ 도ꡬλ₯Ό μ œκ³΅ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. Reactive Extension은 Reactive ν”„λ‘œκ·Έλž˜λ°μ„ μ§€ν–₯ν•˜κ³  있으며, 이λ₯Ό 기반으둜 Functional Reactive ν”„λ‘œκ·Έλž˜λ°μ„ μ‹€ν˜„ν•  수 μžˆμŠ΅λ‹ˆλ‹€. λ˜ν•œ, λ‹€μ–‘ν•œ 언어에 ν¬νŒ…μ΄ λ˜μ–΄μžˆμ–΄ μ„œλ‘œ λ‹€λ₯Έ μ–Έμ–΄μ—μ„œ 일괄적인 νŒ¨ν„΄μ„ μ μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

이 글에선 순수 ν•¨μˆ˜μ  μƒνƒœ 전이에 λŒ€ν•΄ κ°„λ‹¨ν•˜κ²Œ μ•Œμ•„λ³΄κ³ , 이λ₯Ό 기반으둜 Functional Reactive ν”„λ‘œκ·Έλž˜λ°μ΄ μ§€ν–₯ν•˜λŠ”λ°”μ™€, μ΄λŸ¬ν•œ κΈ°λ²•λ“€μ˜ μž₯점을 κ·ΉλŒ€ν™” ν•  수 μžˆλŠ” 섀계에 λŒ€ν•œ κΈ°λ³Έ 원칙, 그리고 그에 λ”°λ₯Έ μ„€κ³„μ˜ 예λ₯Ό λ‹€λ£° 것 μž…λ‹ˆλ‹€.

@sooop
sooop / StreamReader.swift
Last active June 23, 2024 22:49
Read a large text file line by line - Swift 3
import Foundation
class StreamReader {
let encoding: String.Encoding
let chunkSize: Int
let fileHandle: FileHandle
var buffer: Data
let delimPattern : Data
var isAtEOF: Bool = false
@dfrib
dfrib / DictionaryKeyPath.swift
Last active April 14, 2023 12:45
Swift: Reading and writing to (possible) nested dictionaries for a given key path, using a recursive approach
// For details, see
// http://stackoverflow.com/questions/40261857/remove-nested-key-from-dictionary
import Foundation
extension Dictionary {
subscript(keyPath keyPath: String) -> Any? {
get {
guard let keyPath = Dictionary.keyPathKeys(forKeyPath: keyPath)
else { return nil }
return getValue(forKeyPath: keyPath)
@rayfix
rayfix / fiindsize.swift
Created February 7, 2016 05:30
Getting the Size of a file or directory in Swift
//
// main.swift
// findsize
//
// Created by Ray Fix on 2/6/16.
// Copyright Β© 2016 Neko Labs. All rights reserved.
//
import Foundation
@speaktoalvin
speaktoalvin / IAPHelper.txt
Last active April 29, 2021 04:07
In App Purchase in Swift, with Receipt Validation
import UIKit
import StoreKit
//MARK: SKProductsRequestDelegate
extension IAPHelpers : SKProductsRequestDelegate
{
func productsRequest(request: SKProductsRequest, didReceiveResponse response: SKProductsResponse)
{
@plutovman
plutovman / TimeLapseBuilder.swift
Created August 16, 2015 00:07
UIImages to Video Swift files
//
// TimeLapseBuilder.swift
//
// Created by Adam Jensen on 5/10/15.
// Copyright (c) 2015 Adam Jensen. All rights reserved.
//
import AVFoundation
import UIKit