Skip to content

Instantly share code, notes, and snippets.

View 0xLeif's full-sized avatar
🇺🇦
Updating projects to Swift 6

Leif 0xLeif

🇺🇦
Updating projects to Swift 6
  • 🏔️
  • 06:05 (UTC -06:00)
View GitHub Profile
@0xLeif
0xLeif / fb.swift
Created February 1, 2020 21:15
@_functionBuilder example
import UIKit
@_functionBuilder
public struct StringBuilder {
public static func buildBlock(_ string: String) -> String { string }
public static func buildBlock(_ strings: String...) -> String {
strings.joined(separator: "")
}
@0xLeif
0xLeif / DynamicTable.swift
Created January 20, 2020 23:04
DynamicTable
//
// DynamicTable.swift
// SwiftUIKit
//
// Created by Zach Eriksen on 1/19/20.
//
import UIKit
@available(iOS 9.0, *)
@0xLeif
0xLeif / LazyTable.swift
Created January 17, 2020 23:20
LazyTable
class LazyTable: UITableView {
fileprivate var loadThreshold: CGFloat = 0.75 // 75%
fileprivate var loadAmount: Int = 25
fileprivate var loadCount: Int = 1
fileprivate var batchCount: Int {
return loadAmount * loadCount
}
fileprivate var elements: [UIView] = [] {
didSet {
//
// NSMutableAttributedString+Swift.swift
//
//
// Created by Zach Eriksen on 12/11/19.
//
import Foundation
public typealias AttributedString = NSMutableAttributedString
public typealias AttributedStringKey = NSAttributedString.Key
//
// NSObjectProtocol+Swift.swift
//
//
// Created by Zach Eriksen on 10/30/19.
//
import Foundation
public extension NSObjectProtocol {
@discardableResult
@0xLeif
0xLeif / use.swift
Created November 29, 2019 18:08
Optional Use
import Foundation
public extension Optional {
func use(_ closure: (Wrapped) -> Void) {
guard let unwrappedSelf = self else {
return
}
closure(unwrappedSelf)
}
}
@0xLeif
0xLeif / keybase.md
Last active February 19, 2020 17:16
keybase

Keybase proof

I hereby claim:

  • I am 0xLeif on github.
  • I am l_eif (https://keybase.io/l_eif) on keybase.
  • I have a public key ASDxGDsRglqF5yBeAx4l6hLrEzjDrk6kVIz4S44CQ_GU4wo

To claim this, I am signing this object:

@0xLeif
0xLeif / UI.swift
Created October 28, 2019 16:34
UIBuildable
import UIKit
postfix operator ...
protocol UIConfigurable {
func configure<T>(_ configure: (inout T) -> Void) -> T
static func ...<T>(_ lhs: Self, _ block: (inout T) -> Void) -> T
}
extension UIView: UIConfigurable {
@0xLeif
0xLeif / KP.swift
Last active August 21, 2020 22:21
KeyPath
import UIKit
precedencegroup KeyPathPrecedence {
associativity: right
higherThan: MultiplicationPrecedence
}
infix operator ...: KeyPathPrecedence
@0xLeif
0xLeif / bool.swift
Created March 16, 2019 02:45
Conditional
extension Bool {
func `if`(_ block: () -> Bool) -> Bool {
return self ? block() : self
}
func `true`(_ block: () -> Void) -> Bool {
if self {
block()
}