Skip to content

Instantly share code, notes, and snippets.

View tkersey's full-sized avatar
:octocat:

Tim Kersey tkersey

:octocat:
View GitHub Profile
@tkersey
tkersey / HowTo use xcconfig or plist with SPM.md
Created November 30, 2022 15:39 — forked from 4np/HowTo use xcconfig or plist with SPM.md
How to use a .xcconfig file and a .plist with a Swift Package Manager based project.

How to use a .xcconfig file and a .plist file with SPM

Worth a read for some more context.

Create a Package.xcconfig file

Create the file in the root of the project (where your Package.swift file lives as well), and use the following contents:

/// Package.xcconfig
@tkersey
tkersey / Combinators.swift
Created November 28, 2022 15:41 — forked from danielt1263/Combinators.swift
A list of combinators
func apply<A, B>(fn: (A) -> B, a: A) -> B {
fn(a)
}
func bluebird<A, B, C>(fn1: (A) -> B, fn2: (C) -> A, c: C) -> B {
fn1(fn2(c))
}
func blackbird<A, B, C, D>(fn1: (C) -> D, fn2: (A, B) -> C, a: A, b: B) -> D {
@tkersey
tkersey / xcode-vim.markdown
Created November 16, 2022 16:40 — forked from gdavis/xcode-vim.markdown
Notes for working with Xcode VIM mode

Xcode VIM

This document is a scratchpad for helping me learn commonly used actions in Xcode's VIM mode.

Commands are case-sensitive. A command of N means pressing shift + n on the keyboard.

[Formatting is a WIP]


Normal Mode Commands

Basic Navigation

@tkersey
tkersey / equals.swift
Created October 26, 2022 17:00
Existential equality
public func equals(_ lhs: Any, _ rhs: Any) -> Bool {
func open<A: Equatable>(_ lhs: A, _ rhs: Any) -> Bool {
type(of: rhs) == A.self && lhs == (rhs as? A)
}
guard let lhs = lhs as? any Equatable else { return false }
return open(lhs, rhs)
}
@tkersey
tkersey / cli.md
Created July 14, 2022 15:24
Useful macOS command line commands

Download full installer

softwareupdate --fetch-full-installer --full-installer-version 13.0

Create USB installer

sudo /Applications/Install\ macOS\ Ventura\ beta.app/Contents/Resources/createinstallmedia --volume /Volumes/Installer --nointeraction

@tkersey
tkersey / CoW.swift
Created July 8, 2022 02:12
Reducing stack costs of structs by using Copy on Write (CoW)
@dynamicMemberLookup
struct CoW<T> {
init(_ value: T) {
_storage = Storage(value)
}
public subscript<V>(dynamicMember keyPath: WritableKeyPath<T, V>) -> V {
get { value[keyPath: keyPath] }
set { value[keyPath: keyPath] = newValue }
}
var value: T {
@tkersey
tkersey / Moore.hs
Created March 6, 2022 23:31 — forked from ekmett/Moore.hs
Moore for Less
{-# LANGUAGE GADTs #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE RankNTypes #-}
import Control.Applicative
import Control.Comonad
import Data.Bifunctor
@tkersey
tkersey / alltheflags.md
Created November 29, 2021 19:05 — forked from CodaFi/alltheflags.md
Every Option and Flag /swift (1.2) Accepts Ever

#Every Single Option Under The Sun

  • optimization level options
  • automatic crashing options
  • debug info options
  • swift internal options
  • swift debug/development internal options
  • linker-specific options
  • mode options
@tkersey
tkersey / Continuations.swift
Created November 29, 2021 18:46 — forked from CodaFi/Continuations.swift
A Swift Continuation Monad
// Playground - noun: a place where people can play
public func id<A>(x : A) -> A {
return x
}
public func error<A>(x : String) -> A {
assert(false, x)
}
@tkersey
tkersey / Y.swift
Created November 29, 2021 18:19 — forked from CodaFi/Y.swift
The Y Combinator in Swift
public func unsafeCoerce<A, B>(_ x : A) -> B {
return unsafeBitCast(x, to: B.self)
}
func Y<A>(_ f : @escaping (A) -> A) -> A {
return { (x : @escaping (A) -> A) in
return f((x(unsafeCoerce(x))))
}({ (x : A) -> A in
let fn : (A) -> A = unsafeCoerce(x)
return f(fn(x))