This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# When you let copilot go.. | |
defmodule Sayings do | |
@hello "Hello" | |
@goodbye "Goodbye" | |
@thanks "Thanks" | |
@bye "Bye" | |
@see_you "See you" | |
@see_you_later "See you later" | |
@see_you_soon "See you soon" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Equatable+nil.swift | |
struct Model: Equatable { } | |
let model = Model() | |
print(model == nil) // This compiles and produces a warning | |
print(model == .none) // This compiles with no warning |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import YPImagePicker | |
struct NewPost { | |
/// YPMediaItem translates to either a UIImage for photo or Data/URL for video | |
var media: Either<[YPMediaItem], [NewPost.Medium]> | |
struct Medium { | |
let url: String | |
let thumbnailUrl: String? | |
let mediumType: Post.Medium.MediumType |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// RxDataSources+SkeletonView.swift | |
// | |
// Created by mack on 4/7/20. | |
// | |
import Foundation | |
import UIKit | |
import RxSwift | |
import RxDataSources |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// hanoi.swift | |
struct Tower: OptionSet { | |
static let all: Tower = [.a, .b, .c] | |
static let a = Tower(rawValue: 1 << 0) | |
static let b = Tower(rawValue: 1 << 1) | |
static let c = Tower(rawValue: 1 << 2) | |
let rawValue: Int | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.swift | |
// Mad | |
// | |
// Created by Mack on 10/13/19. | |
// Copyright © 2019 Mack. All rights reserved. | |
// | |
import Foundation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Inspired by rails `StringInquirer` | |
https://github.com/rails/rails/blob/master/activesupport/lib/active_support/string_inquirer.rb | |
**/ | |
@dynamicMemberLookup | |
struct StringInquirer { | |
let string: String | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
import UIKit | |
func ward<T: AnyObject, A, Return>(_ object: T?, _ keyPath: KeyPath<T, (A) -> Return>, else defaultValue: Return) -> ((A) -> Return) { | |
return { [weak object] a in | |
guard let object = object else { | |
return defaultValue | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
/* attempt 1 */ | |
protocol HasApply { } | |
extension HasApply { | |
func apply(_ applying: (Self) -> Void) -> Self { | |
applying(self) |