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 / response
Created May 29, 2023 07:45
서버 응답
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
Sec-WebSocket-Protocol: chat
@gaeng2y
gaeng2y / response
Created May 29, 2023 07:44
서버 응답
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
Sec-WebSocket-Protocol
@gaeng2y
gaeng2y / request
Created May 29, 2023 07:44
웹소켓 요청
GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 13
Origin: http://example.com
@gaeng2y
gaeng2y / request
Created May 29, 2023 07:43
클라이언트 요청
GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 13
Origin: http://example.com
@gaeng2y
gaeng2y / Graph.swift
Last active May 6, 2023 15:45
Graph protocol
public enum EdgeType {
case directed
case undirected
}
public protocol Graph {
associatedtype Element
func createVertex(data: Element) -> Vertex<Element>
@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 / SerialExample.swift
Created November 27, 2022 09:42
Serial Example
print("start")
DispatchQueue.main.async {
for _ in 0...4 {
print("async")
}
}
for _ in 0...4 {
print("sync")
}
print("end")