Skip to content

Instantly share code, notes, and snippets.

:octocat:

Tim Kersey tkersey

:octocat:
Block or report user

Report or block tkersey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tkersey
tkersey / UnitTestingSceneDelegateGist.md
Created Jan 25, 2020 — forked from HiddenJester/UnitTestingSceneDelegateGist.md
Mocking SceneDelegate for Unit Tests on iOS 13
View UnitTestingSceneDelegateGist.md

Replacing the SceneDelegate When Running Unit Tests

Overview

I've been working through the exercises in the excellent iOS Unit Testing by Example book by Jon Reid, which I highly recommend. However, the book is in beta at the moment and there are some curveballs thrown by iOS 13 that aren't handled in the text yet. Specifically, when I hit the section about using a testing AppDelegate class I thought "This is very good. But what about the SceneDelegate?"

In Chapter 4 the recommendation is to remove the @UIApplicationMain decoration and make a manual top-level call to UIApplicationMain. To wit:

import UIKit
View Prelude.kt
// Identity
fun <A> id(): (A) -> A = { a: A -> a }
// Const
fun <A, B> const(a: A): (B) -> A = { _: A -> a }
View Deduplicated.swift
//
// Deduplicated.swift
// CountriesSwiftUI
//
// Created by Alexey Naumov on 17.12.2019.
// Copyright © 2019 Alexey Naumov. All rights reserved.
//
import Foundation
import Combine
View Fibonacci.hs
{-# LANGUAGE DeriveFunctor #-}
module Main where
type Algebra f a = f a -> a
type Coalgebra f a = a -> f a
newtype Fix f = In { out :: f (Fix f) }
@tkersey
tkersey / PagerView.swift
Created Dec 25, 2019 — forked from mecid/PagerView.swift
PagerView in SwiftUI
View PagerView.swift
//
// PagerView.swift
//
// Created by Majid Jabrayilov on 12/5/19.
// Copyright © 2019 Majid Jabrayilov. All rights reserved.
//
import SwiftUI
struct PagerView<Content: View>: View {
let pageCount: Int
@tkersey
tkersey / UIView+Tooltips.h
Created Sep 13, 2019 — forked from steventroughtonsmith/UIView+Tooltips.h
WIP tooltips for Mac Catalyst
View UIView+Tooltips.h
//
// UIView+Tooltips.h
// Crossword
//
// Created by Steven Troughton-Smith on 13/09/2019.
// Copyright © 2019 Steven Troughton-Smith. All rights reserved.
//
#import <UIKit/UIKit.h>
@tkersey
tkersey / Bindings.swift
Created Jun 8, 2019 — forked from AliSoftware/Bindings.swift
Re-implementation of @binding and @State (from SwiftUI) myself to better understand it
View Bindings.swift
// This is a re-implementation of the @Binding and @State property wrappers from SwiftUI
// The only purpose of this code is to implement those wrappers myself just to understand how they work internally and why they are needed
// Re-implementing them myself has helped me understand the whole thing better
//: # A Binding is just something that encapsulates getter+setter to a property
@propertyDelegate
struct XBinding<Value> {
var value: Value {
get { return getValue() }
View TimeFormat.swift
public enum TimeFormat: String {
case twentyFourHour = "HH:mm"
case twelveHour = "h:mm a"
public init(_ locale: Locale = Locale.current) {
let is24Hour = DateFormatter
.dateFormat(fromTemplate: "j", options: 0, locale: locale)
.map { $0.contains("a") } ?? false
self = is24Hour ? .twentyFourHour : .twelveHour
}
View seemingly-impossible-swift-programs.swift
/*:
# Seemingly Impossible Swift Programs
*/
/*:
# 1.) Completely possible programs
*/
[1, 2, 3]
.allSatisfy { $0 >= 2 }
[1, 2, 3]
@tkersey
tkersey / ScrollDirection.swift
Created Dec 4, 2018
Use within scrollViewDidScroll
View ScrollDirection.swift
import UIKit
enum ScrollDirection: Int {
case up = -1
case none = 0
case down = 1
}
// MARK: - Determine
extension ScrollDirection {
You can’t perform that action at this time.