Skip to content

Instantly share code, notes, and snippets.


Last login: Wed Jul 15 09:29:59 on ttys002 /bin/bash -c 'arch -arch x86_64 '/Applications/' --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/' --env='_XPC_DYLD_LIBRARY

View combine4.swift
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]{ $0 * 10 }).sink { print($0) }
View combine3.swift
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))
View combine2.swift
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."
View combine1.swift
import Foundation
import Combine
// 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 {
// }
View attempts.swift
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))
View pirate.txt
********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’
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