Skip to content

Instantly share code, notes, and snippets.

Book Ideas

  • Preview Power: AKA free, fun, no fotoshop. If you've taken my webinar on this, you pretty much know what's involved. Lots of stuff with a surprisingly powerful features that not a lot of people know about.
  • ed-ucation: Write a book on using ed because it's the best editor ever and it's more or less guaranteed to be available on every *nix ever. g/re/p for life. Plus nods to sed, vi, etc.
  • hidden macOS gems: uncovering the coolness that's already there on your machine.
  • Swift at the Command Line: from emitting proper exit codes to using the argument parser, input and output streams, etc. More involved than the webinar, and can extend to coloring text at the command line, curses, etc depending on how obscure I get. Or I can pull back and focus just on the argument parser.
  • Xcode Power Up: If you've attended my webinar, you know what this is. Twists and secrets.
  • Zero to SwiftPM: If you've attended my webinar, you know what this is.
  • **N Unix Obscurities (BSD and GN
import Foundation
let string = """
Wordle 204 6/6
⬜⬜⬜⬜🟨
🟨🟨⬜⬜⬜
⬜🟩🟩🟨⬜
⬜🟩🟩⬜🟩
⬜🟩🟩⬜🟩

Last login: Wed Jul 15 09:29:59 on ttys002 /bin/bash -c 'arch -arch x86_64 '/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/darwin-debug' --unix-socket=/tmp/V4f5hE --arch=x86_64 --working-dir '/Users/ericasadun/Library/Developer/Xcode/DerivedData/Test-gwehknnihlcsiucsovtbnlrdtfun/Build/Products/Debug' --disable-aslr --env='__XCODE_BUILT_PRODUCTS_DIR_PATHS=/Users/ericasadun/Library/Developer/Xcode/DerivedData/Test-gwehknnihlcsiucsovtbnlrdtfun/Build/Products/Debug' --env='MallocNanoZone=0' --env='CA_DEBUG_TRANSACTIONS=0' --env='NSUnbufferedIO=YES' --env='CA_ASSERT_MAIN_THREAD_TRANSACTIONS=0' --env='PWD=/Users/ericasadun/Library/Developer/Xcode/DerivedData/Test-gwehknnihlcsiucsovtbnlrdtfun/Build/Products/Debug' --env='DYLD_LIBRARY_PATH=/Users/ericasadun/Library/Developer/Xcode/DerivedData/Test-gwehknnihlcsiucsovtbnlrdtfun/Build/Products/Debug:/usr/lib/system/introspection' --env='LD_LIBRARY_PATH=/Applications/Xcode.app/Contents/Developer/../SharedFrameworks/' --env='_XPC_DYLD_LIBRARY

import Foundation
import Combine
// Mapping
// Arrays are sequences.
// Adding a transform (here, map) after it affects the output values sent to a subscriber/sink
print("as tens")
[6, 9, 4, 2].publisher.map({ $0 * 10 }).sink { print($0) }
import Cocoa
import Combine
import ObjectiveC
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
enum Action {
static func run(after delay: Double, action: @escaping () -> Void) {
let delayTime = UInt64(delay * Double(NSEC_PER_SEC))
import Cocoa
import Combine
// ## Subjects
// A `Subject` is a special publisher that enables you to inject values into a stream.
// Just call the `send(_:)` method.
// "This can be useful for adapting existing imperative code to the Combine model."
// WHAT'S THERE:
import Foundation
import Combine
// # PUBLISHERS
//
// Publishers are a namespace for types that serve as publishers.
// "The various operators defined as extensions on ``Publisher`` implement their functionality as classes or structures that extend this enumeration. For example, the `contains(_:)` operator returns a `Publishers.Contains` instance."
// ```
// public enum Publishers {
// }
Olivier: I think that's one of the rare cases where fallthough is acceptable
import XCTest
class Tester: XCTestCase {
func testit() {
XCTAssertEqual("a", switchTheFallthroughOrder(foo: .a))
XCTAssertEqual("b", switchTheFallthroughOrder(foo: .b("x")))
XCTAssertEqual("c", switchTheFallthroughOrder(foo: .b("cx")))
XCTAssertEqual("c", switchTheFallthroughOrder(foo: .c))
@erica
erica / pirate.txt
Last active November 29, 2020 20:39
********This Text Adventure is Copyright 1993, by Erica Sadun********
ALL RIGHTS RESERVED. Known bugs and differences from Infocom games? say ‘news’. Unfamiliar with certain words? say ‘jargon’
PIRATING
To hack and to slash with the best of the best
Means you must have a spirit which is steely and cold
You must fight without mercy, from earliest dawn
The heart of a pirate is ruthless and bold.
Richard T. Pettyheart, Scholar
Treatise on Pirates, 1638