Instantly share code, notes, and snippets.

View raw.md
View UserDefaults+Codable.swift
//
// UserDefaults+Codable.swift
// Converter UltraLight
//
// Created by Brent Royal-Gordon on 8/31/17.
// Copyright © 2017 Architechies. All rights reserved.
// MIT-licensed, go nuts with it.
//
import Foundation
View UICollectionViewLayout+indexPaths.swift
//
// UICollectionViewLayout+indexPaths.swift
// Converter Calc
//
// Created by Brent Royal-Gordon on 7/26/17.
// Copyright © 2017 Architechies. All rights reserved.
//
import UIKit
View Example.swift
import Foundation
import ExplicitlyConvertible
let i8: Int8 = 8
let i64: Int64 = 64
i64 + ^i8 // => 72
struct Person {
var name: String
View Tuple.swift
// First, let's test out the basic design. This is basically just an
// HList.
// This recurses to the right because that makes subscripting simpler,
// at the cost of making appending impossible to generalize.
public protocol TupleProtocol: RandomAccessCollection
where Index == Int, IndexDistance == Int, Element == Any
{
associatedtype First
associatedtype Rest //: TupleProtocol
View JSONFeed.swift
import Foundation
let feedURL = URL(string: "https://daringfireball.net/feeds/json")!
// MARK: Basic models
// We do not model the `userComment` field because it is not supposed to be used by
// machines. We do not model extensions because they should be ignored unless
// supported anyway.
struct Feed {
View gist:daa9e2112f9c6aa4a5720cf5e81febb6
print("""
<?xml version="1.0"?>
<catalog>
\(bookTuples.map(xmlForBookTuple).joined(separator: "")
)</catalog>
""")
typealias ChapterTuple = (heading: String)
typealias BookTuple = (id: String, author: String, title: String, genre: String, price: String, chapters: [ChapterTuple])
View Formatter.swift
protocol Formatter {
associatedtype Input
associatedtype Output
func format(_ input: Input) -> Output
}
protocol CombiningFormatter: Formatter where
InnerFormatter.Output == CombinedFormatter.Input
{
View LocalizableString-new-interpolation.swift
import Foundation
public protocol LocalizableArgument {
var localizableFormat: String { get }
var localizableFormatArguments: [CVarArg] { get }
}
extension LocalizableArgument where Self: CVarArg {
public var localizableFormatArguments: [CVarArg] {
return [self]
View NNNN-fix-expressible-by-string-interpolation.md

Fix ExpressibleByStringInterpolation

Introduction

String interpolation is a simple and powerful feature for expressing