Skip to content

Instantly share code, notes, and snippets.

View gohanlon's full-sized avatar

Galen O’Hanlon gohanlon

  • Portland, OR
  • 19:42 (UTC -07:00)
View GitHub Profile
@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.
~ % 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 / 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 {
#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,
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

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
% /opt/homebrew/bin/ctags --version                                                                                                                                                                                  
Universal Ctags 6.1.0, Copyright (C) 2015-2023 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Nov 30 2024, 05:11:31
  URL: https://ctags.io/
  Output version: 0.0
  Optional compiled features: +wildcards, +regex, +gnulib_fnmatch, +gnulib_regex, +iconv, +option-directory, +xpath, +json, +interactive, +yaml, +case-insensitive-filenames, +packcc, +optscript, +pcre2