Skip to content

Instantly share code, notes, and snippets.

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

Zach 0xLeif

🇺🇦
Updating projects to Swift 6
View GitHub Profile
@0xLeif
0xLeif / Core-TCA-Example.swift
Last active December 15, 2021 02:30
An example of the basic core functionality behind Reducer and Store. (Not including pullback or higher order reducers)
// MARK: - Reducable
protocol Reducable {
associatedtype State
associatedtype Action
associatedtype Environment
associatedtype Effect
func reduce(
state: inout State,
@0xLeif
0xLeif / Protocols.swift
Last active April 1, 2021 15:15
Swift Property Requirements
/**
[Swift Protocols](https://docs.swift.org/swift-book/LanguageGuide/Protocols.html#ID269)
# Property Requirements
A protocol can require any conforming type to provide an instance property or
type property with a particular name and type. The protocol doesn’t specify
whether the property should be a stored property or a computed property it
only specifies the required property name and type. The protocol also specifies
whether each property must be gettable or gettable and settable.
@pilgwon
pilgwon / TCA_README_KR.md
Last active October 11, 2024 08:15
TCA README in Korean

The Composable Architecture

The Composable Architecture(TCA)는 일관되고 이해할 수 있는 방식으로 어플리케이션을 만들기 위해 탄생한 라이브러리입니다. 합성(Composition), 테스팅(Testing) 그리고 인체 공학(Ergonomics)을 염두에 둔 TCA는 SwiftUI, UIKit을 지원하며 모든 애플 플랫폼(iOS, macOS, tvOS, watchOS)에서 사용 가능합니다.

@0xLeif
0xLeif / metal_01_swiftui.swift
Last active May 6, 2023 11:47
Metal + SwiftUI
//
// ContentView.swift
// MetalSwiftUI
//
// Created by Zach Eriksen on 9/8/20.
// Copyright © 2020 oneleif. All rights reserved.
//
// Inspired [MetalUI](https://github.com/0xLeif/MetalUI)
import SwiftUI
@0xLeif
0xLeif / BrandedLoadingView.swift
Created February 18, 2020 16:11
SwiftUIKit Custom Loading View
class BrandedLoadingView: UIView {
fileprivate var spinnerView = View()
fileprivate var topLeftSpinnerView = View()
.layer { $0.addSublayer(dotLayer()) }
fileprivate var bottomRightSpinnerView = View()
.configure {
$0.transform = $0.transform.rotated(by: .pi)
}
.layer { $0.addSublayer(dotLayer()) }
@IanColdwater
IanColdwater / twittermute.txt
Last active November 17, 2024 02:37
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@0xLeif
0xLeif / KP.swift
Last active August 21, 2020 22:21
KeyPath
import UIKit
precedencegroup KeyPathPrecedence {
associativity: right
higherThan: MultiplicationPrecedence
}
infix operator ...: KeyPathPrecedence
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active November 15, 2024 01:56
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@cprovatas
cprovatas / BlockBasedSelector.h
Last active June 9, 2024 13:08
Block-Based Selectors in Swift
//
// BlockBasedSelector.h
//
// Created by Charlton Provatas on 11/2/17.
// Copyright © 2017 CharltonProvatas. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface BlockBasedSelector : NSObject
@lattner
lattner / TaskConcurrencyManifesto.md
Last active November 15, 2024 05:45
Swift Concurrency Manifesto