Skip to content

Instantly share code, notes, and snippets.

@mdiep
mdiep / diff-values.swift
Created February 4, 2020 13:02
Diff values with Mirror and AnyHashable
import Foundation
// Diff values for better test assertions.
//
// Enums and collections left as an exercise for the reader.
// A difference between two values
struct Difference: CustomStringConvertible {
let path: String
let actual: String
@mdiep
mdiep / diff-values.swift
Last active February 13, 2024 21:01
Diff values with Codable, CaseIterable, and KeyPaths
import Foundation
// Diff objects for better test assertions.
//
// Implemented in a way that:
// 1. The compiler generates as much code as possible
// 2. You'll get a compiler error if you forget a property
//
// Nested support and collections left as an exercise for the reader.
@mdiep
mdiep / Sunset (Dark).xccolortheme
Last active December 2, 2021 08:23
Sunset (Dark) Xcode Theme - Install in ~/Library/Developer/Xcode/UserData/FontAndColorThemes/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.75 0.75 0.75 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>SFMono-Bold - 12.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0.75 0.75 0.75 1</string>
@mdiep
mdiep / wat.swift
Created August 3, 2018 01:24
Swift Tuple Wat
struct S<Args, Return> {}
infix operator ~
func ~ <A, T>(lhs: (A) -> T, rhs: String) -> S<(A), T> {
return S()
}
func ~ <A, B, T>(lhs: (A, B) -> T, rhs: String) -> S<(A, B), T> {
return S()
}