Skip to content

Instantly share code, notes, and snippets.

View kingnight's full-sized avatar
🎯
Focusing

jinkai kingnight

🎯
Focusing
View GitHub Profile
@kingnight
kingnight / StopJumpingTableViewOnInsertRows.swift
Created July 7, 2022 06:19 — forked from joshdholtz/StopJumpingTableViewOnInsertRows.swift
Used when loading more data into UITableView for a smooth "infinite scroll" feel
// I dont want my table jumping/animation when appending new rows
// for an infinite scroll feel
//
// Some of this might not be needed but it works
//
// TODO: Possibly garbage
extension UITableView {
func reloadDataSmoothly() {
UIView.setAnimationsEnabled(false)
@kingnight
kingnight / xcframework_realm.sh
Created May 15, 2022 08:42 — forked from leemaguire/xcframework_realm.sh
Remove naming collisions in swiftinterface. Run this script in the root of the RealmSwift.xcframework folder
#!/bin/bash
set -o pipefail
set -e
find . -name "*.swiftinterface" -exec sed -i -e 's/Realm\.//g' {} \;
find . -name "*.swiftinterface" -exec sed -i -e 's/import Private/import Realm.Private/g' {} \;
find . -name "*.swiftinterface" -exec sed -i -e 's/RealmSwift.Configuration/RealmSwift.Realm.Configuration/g' {} \;
find . -name "*.swiftinterface" -exec sed -i -e 's/extension Configuration/extension Realm.Configuration/g' {} \;
find . -name "*.swiftinterface" -exec sed -i -e 's/RealmSwift.Error/RealmSwift.Realm.Error/g' {} \;
find . -name "*.swiftinterface" -exec sed -i -e 's/extension Error/extension Realm.Error/g' {} \;
Incident Identifier: 99b0c74e-b9a1-4499-a062-013b6d4eb33a
CrashReporter Key: 7862DD8B-9A2B-438B-A9D2-5499ABA916D5
Hardware Model: iPhone11,8
Process: sohuhy [16580]
Path: /private/var/containers/Bundle/Application/381112DE-2082-468B-A3E2-451408B885E2/sohuhy.app/sohuhy
Identifier: com.sohu.sohuhy
Version: 5.20.0 (5)
Code Type: arm64
Parent Process: [1]
@kingnight
kingnight / sendmail_setup.md
Created January 15, 2021 11:29 — forked from kany/sendmail_setup.md
Setup SENDMAIL on Mac OSX Yosemite
@kingnight
kingnight / errorcodes.m
Created June 18, 2020 02:41 — forked from samirahmed/errorcodes.m
NSURLErrorDomain codes
kCFURLErrorUnknown = -998,
kCFURLErrorCancelled = -999,
kCFURLErrorBadURL = -1000,
kCFURLErrorTimedOut = -1001,
kCFURLErrorUnsupportedURL = -1002,
kCFURLErrorCannotFindHost = -1003,
kCFURLErrorCannotConnectToHost = -1004,
kCFURLErrorNetworkConnectionLost = -1005,
kCFURLErrorDNSLookupFailed = -1006,
kCFURLErrorHTTPTooManyRedirects = -1007,
@kingnight
kingnight / demo-imp.swift
Created November 17, 2019 11:29
sil file,demo include protocol define
sil_stage raw
import Builtin
import Swift
import SwiftShims
protocol ListDataProtocol {
func testFunc()
}
@kingnight
kingnight / demo-no-imp.swift
Last active November 17, 2019 11:20
sil file without protocol function define
sil_stage raw
import Builtin
import Swift
import SwiftShims
protocol ListDataProtocol {
}
class TestClass : ListDataProtocol {
@kingnight
kingnight / protocol-demo.swift
Created November 17, 2019 11:15
sil protocol demo
protocol ListDataProtocol {
func testFunc()
}
class TestClass:ListDataProtocol {
func testFunc() {
print("ahaha")
}
}
// orogin swift protocol and calling
protocol aProtocol {
func testFunc()
}
class aStruct: aProtocol {
func testFunc() {} // override defualt implementation
}
class bStruct: aProtocol {
func testFunc() {} // override defualt implementation
}
import Foundation
protocol StateType: Hashable {}
protocol EventType: Hashable {}
struct Transition<S: StateType, E: EventType> {
let event: E
let fromState: S
let toState: S