Skip to content

Instantly share code, notes, and snippets.

View AvdLee's full-sized avatar
👇
avanderlee.com

Antoine van der Lee AvdLee

👇
avanderlee.com
View GitHub Profile
@AvdLee
AvdLee / Flattener Playground
Created August 7, 2019 15:24
A Flattener written in Swift
/// - We have multiple files with a X amount of chunks
/// - Each batch request can contain a max of 50 chunks from possibly multiple files
///
/// Challenge: Distribute the chunk requests over as less batch requests as possible
import UIKit
import Foundation
typealias PublicIdentifier = String
Type of code Xcode Unit Test Playground Terminal
For loop if 0.026 26.052 0.030
Filter forEach 0.043 2.116 0.047
@AvdLee
AvdLee / ForPerformance.playground
Created October 4, 2018 07:42
For each vs for loop performance
//: Playground - noun: a place where people can play
import XCTest
class MyTests: XCTestCase {
lazy var testData: [Int] = {
return (0..<1000).map { Int($0) }
}()
@AvdLee
AvdLee / MutableProgress.swift
Last active February 13, 2024 10:05
Adding children to a Progress instance is easy, but removing is not possible by default. This could have been useful when you want to use a single Progress instance which can have different children over time. Using this custom class MutableProgress makes this possible. See: https://www.avanderlee.com/general/controlling-progress-children/
import UIKit
/// An additional class build on top of `Progress` to make it possible to also remove children from progress.
public final class MutableProgress: Progress {
public override var totalUnitCount: Int64 {
get {
return Int64(children.count)
}
set {
@AvdLee
AvdLee / XCTestCaseExtensions.swift
Last active June 7, 2023 07:28
This extension should make it fairly easy to test your Share Extension. Read more about it here: https://www.avanderlee.com/swift/ui-test-share-extension/
//
// XCTestCaseExtensions.swift
//
// Useful extension to UI Test the Share Extension of apps.
//
//
// Created by Antoine van der Lee on 18/05/2018.
// Copyright © 2018. All rights reserved.
//
@AvdLee
AvdLee / Proposal.md
Last active February 9, 2018 13:56
Sustainable codebase proposal

This talk in 3 words

  • Sustainable
  • Rabbit
  • Codebase

This talk in 1 sentence

How to create and reap the benefits of a sustainable codebase without necessarily spending more time, as explained by a rabbit.

This talk in 5 sentences

Within projects you often don’t have the time to write tests – or at least that’s what you think. Refactoring turns out to be hard as you can’t validate your code, and your new code turns out to be quite buggy. Fixing those bugs costs even more time. Creating a sustainable codebase with tests prevents this and doesn’t need to eat up lots of time. I’ll be sharing learnings from more than eight years of iOS development experience and banging the drum for sustainability.

@AvdLee
AvdLee / XCTestExtensions.swift
Last active May 20, 2017 14:21
Wait for a callback to be a given value in Xcode unit tests. As pure Swift objects can't be used with NSPredicate, this can help to test simple results.
//
// XCTestExtensions.swift
//
// Created by Antoine van der Lee on 20/05/2017.
// Copyright © 2017 AvdLee. All rights reserved.
//
import XCTest
extension XCTestCase {
//
// ALLogger.swift
//
// Created by Antoine van der Lee on 21/06/16.
// Copyright © 2016 Antoine van der Lee. All rights reserved.
//
import Foundation
import UIKit
@AvdLee
AvdLee / ALSwiftyBeaverCLLogger
Last active April 19, 2017 03:04
CocoaLumberjack logger for SwiftyBeaver
//
// ALSwiftyBeaverCLLogger.swift
//
// Created by Antoine van der Lee on 09/05/16.
// Copyright © 2016 Antoine van der Lee. All rights reserved.
//
import Foundation
import CocoaLumberjack
import SwiftyBeaver
@AvdLee
AvdLee / SignalProducerReloaderType
Created May 8, 2016 19:23
Create a reloading system with ReactiveCocoa
//
// SignalProducerReloaderType.swift
// Buienradar
//
// Created by Antoine van der Lee on 07/03/16.
// Copyright © 2016 Triple. All rights reserved.
//
import ReactiveCocoa
import CocoaLumberjack