Skip to content

Instantly share code, notes, and snippets.

View gaeng2y's full-sized avatar
🦍
Keep slow & steady

Kyeongmo(Kyle) Yang gaeng2y

🦍
Keep slow & steady
View GitHub Profile
@gaeng2y
gaeng2y / Combine+Cooldown.swift
Created November 14, 2023 05:24 — forked from JCSooHwanCho/Combine+Cooldown.swift
Combine operator that mimics RxSwift's throttle when latest: false
extension Publisher {
func coolDown<S: Scheduler>(for cooltime: S.SchedulerTimeType.Stride,
scheduler: S) -> some Publisher<Self.Output, Self.Failure> {
return self.receive(on: scheduler)
.scan((S.SchedulerTimeType?.none, Self.Output?.none)) {
let eventTime = scheduler.now
let minimumTolerance = scheduler.minimumTolerance
guard let lastSentTime = $0.0 else {
return (eventTime, $1)
}
@gaeng2y
gaeng2y / BackgroundTransferSample.swift
Created September 27, 2023 01:47 — forked from toddhopkinson/BackgroundTransferSample.swift
Upload Very Large Files In Background on iOS - Alamofire.upload multipart in background
// You have a very very large video file you need to upload to a server while your app is backgrounded.
// Solve by using URLSession background functionality. I will here use Alamofire to enable multipart upload.
class Networking {
static let sharedInstance = Networking()
public var sessionManager: Alamofire.SessionManager // most of your web service clients will call through sessionManager
public var backgroundSessionManager: Alamofire.SessionManager // your web services you intend to keep running when the system backgrounds your app will use this
private init() {
self.sessionManager = Alamofire.SessionManager(configuration: URLSessionConfiguration.default)
self.backgroundSessionManager = Alamofire.SessionManager(configuration: URLSessionConfiguration.background(withIdentifier: "com.lava.app.backgroundtransfer"))
@gaeng2y
gaeng2y / pod_init.sh
Created February 2, 2023 05:51 — forked from iamchiwon/pod_init.sh
Xcode behavior 용: pod init 하기
#!/bin/bash
# move project dir
PROJECT_HOME=`pwd`
echo "cd $PROJECT_HOME" > /tmp/tmp.sh
# search .xcodeproj file and strip filename
PROJECT_NAME=""
for f in *.xcodeproj; do
PROJECT_NAME="${f%.*}"
@gaeng2y
gaeng2y / pod_update.sh
Created February 2, 2023 05:51 — forked from iamchiwon/pod_update.sh
Xcode behavior 용: pod 업데이트 하기
#!/bin/bash
# move project dir
PROJECT_HOME=`pwd`
echo "cd $PROJECT_HOME" > /tmp/tmp.sh
# pod init & update
echo "pod update" >> /tmp/tmp.sh
chmod +x /tmp/tmp.sh
@gaeng2y
gaeng2y / FileIO.swift
Created November 27, 2022 08:39 — forked from JCSooHwanCho/FileIO.swift
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)] // 인덱스 범위 넘어가는 것 방지