Skip to content

Instantly share code, notes, and snippets.

View gohanlon's full-sized avatar

Galen O’Hanlon gohanlon

View GitHub Profile

Swift’s memberwise initializer and the extension dance

Swift's automatically provided memberwise initializer is a powerful feature. However, when an explicit initializer is present, Swift omits its memberwise initializer:

struct Person: Decodable {
  let name: String

  enum CodingKeys: CodingKey {
    case name
import ComposableArchitecture
import Dependencies
import SwiftUI
// Based on Isowords's `ComposableGameCenter.LiveKey.LocalPlayerClient.live`:
// https://github.com/pointfreeco/isowords/blob/main/Sources/ComposableGameCenter/LiveKey.swift#L80
struct AuthClient {
enum AuthStatus {
case loggedIn
#if canImport(UIKit)
import SnapshotTesting
import SwiftUI
public func assertCurrentDeviceSnapshot<SnapshotContent: View>(
for view: SnapshotContent,
precision: Float = 1,
record: Bool = false,
file: StaticString = #file,
testName: String = #function,
@gohanlon
gohanlon / FocusStateTCA.swift
Last active April 4, 2022 20:16
TCA and new SwiftUI focus APIs from WWDC21
import Combine
import ComposableArchitecture
import SwiftUI
struct LoginFormState: Equatable {
var username: String = ""
var password: String = ""
var focusedField: Field?
enum Field: Hashable {
~ % brew list
autoconf imagemagick mono qt the_silver_searcher
cmake jpeg node rbenv tmux
ctags libevent openssl rcm tree
freetype libpng pcre readline vim
gdbm libtiff pkg-config reattach-to-user-namespace xz
git libtool postgresql redis youtube-dl
heroku-toolbelt libyaml python ruby-build z
hub llvm python3 sqlite zsh
@gohanlon
gohanlon / gist:cdffc1fb6c38fd3e1fc4
Created October 1, 2014 00:05
OS 10.10 GM Candidate 1.0: laptop.log
# Laptop install from master, as of: https://github.com/thoughtbot/laptop/commit/8066ffa1b3f56e6b571d91979c30c0e2ba61498d
Changing your shell to zsh ...
Changing shell for wm.
Fixing OSX zsh environment bug ...
WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.
@gohanlon
gohanlon / gist:f8362334b92e4ddfa62b
Created September 5, 2014 19:43
OS 10.10 DP7: postgresql/config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by PostgreSQL configure 9.3.5, which was
generated by GNU Autoconf 2.63. Invocation command line was
$ ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.3.5_1 --datadir=/usr/local/Cellar/postgresql/9.3.5_1/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.3.5_1/share/doc/postgresql --enable-thread-safety --with-bonjour --with-gssapi --with-ldap --with-openssl --with-pam --with-libxml --with-libxslt --with-perl --with-tcl --with-ossp-uuid
## --------- ##
## Platform. ##
@gohanlon
gohanlon / gist:8e755daefe5de7e4037b
Created September 5, 2014 19:42
OS 10.10 DP7: postgresql/01.configure.cc
clang called with: -E -
superenv executed: clang -E - -isystem/usr/include/libxml2 -isystem/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers -I/usr/local/opt/ossp-uuid/include -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include
clang called with: --version
superenv executed: clang -pipe -Os -march=native --version -isystem/usr/include/libxml2 -isystem/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers -I/usr/local/opt/ossp-uuid/include -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -L/usr/local/opt/ossp-uuid/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries -Wl,-headerpad_max_install_names
clang called with: -v
superenv executed: clang -v
clang called with: -V
@gohanlon
gohanlon / gist:f77ee55f860ae151610a
Created September 5, 2014 19:41
OS 10.10 DP7: postgresql/01.configure
2014-09-05 11:45:59 -0700
./configure
--disable-debug
--prefix=/usr/local/Cellar/postgresql/9.3.5_1
--datadir=/usr/local/Cellar/postgresql/9.3.5_1/share/postgresql
--docdir=/usr/local/Cellar/postgresql/9.3.5_1/share/doc/postgresql
--enable-thread-safety
--with-bonjour
--with-gssapi
@gohanlon
gohanlon / gist:c71eedef28a89508a7f8
Created September 5, 2014 19:39
OS 10.10 DP 7: brew install -v postgresql
$ brew --config
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew
HEAD: cd33c4ba2fac5c67edd6360508e25e8d9703203f
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: dual-core 64-bit haswell
OS X: 10.10-x86_64
CLT: 6.0.0.0.1.1409104523
Clang: 6.0 build 600