Skip to content

Instantly share code, notes, and snippets.

Mattt mattt

Block or report user

Report or block mattt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mattt
mattt / undocumented-symbol-urls-2019-09-20.txt
Created Oct 19, 2019
Undocumented Apple API symbols according to nooverviewavailable.com (as of 2019-09-20)
View undocumented-symbol-urls-2019-09-20.txt
This file has been truncated, but you can view the full file.
"https://developer.apple.com/documentation/accelerate/vimagecvimageformat/chromasiting/3241430"
"https://developer.apple.com/documentation/accelerate/vdsp/dcttransformtype/3240713"
"https://developer.apple.com/documentation/accelerate/vdsp/dfttransformtype/3240728"
"https://developer.apple.com/documentation/accelerate/vimage/error/3241360"
"https://developer.apple.com/documentation/accelerate/quadrature/error/3240672"
"https://developer.apple.com/documentation/accelerate/vimagecvimageformat/format/3241442"
"https://developer.apple.com/documentation/accelerate/vdsp/fouriertransformdirection/3240744"
"https://developer.apple.com/documentation/accelerate/vdsp/integrationrule/3240753"
"https://developer.apple.com/documentation/accelerate/vimage/options/3241388"
@mattt
mattt / UIViewControllerPreview.swift
Last active Nov 20, 2019
Generic structures to host previews of UIView and UIViewController subclasses.
View UIViewControllerPreview.swift
import UIKit
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable {
let viewController: ViewController
init(_ builder: @escaping () -> ViewController) {
viewController = builder()
}
View recent-emoji.swift
import Foundation
extension Character {
var isEmoji: Bool {
return unicodeScalars.allSatisfy { $0.properties.isEmoji }
}
}
func recentlyUsedEmoji() -> [Character]? {
#if os(iOS)
@mattt
mattt / bridge.swift
Last active Sep 2, 2019
Example usage of @mxcl's swift-sh
View bridge.swift
#!/usr/bin/swift sh
import DeckOfPlayingCards // @NSHipster ~> 4.0.0
import PlayingCard
import Cycle // @NSHipster == bb11e28
class Player {
var name: String
var hand: [PlayingCard] = []
View unicode-character-name-escape-sequence-pitch.md

Pitch: Unicode Named Character Escape Sequence

Introduction

This proposal adds a new \N{name} escape sequence to Swift string literals, where name is the name of a Unicode character.

Discussion

The Unicode named character escape sequence was previously discussed here:

View Comparator.swift
import Foundation
extension Collection where Element: Comparable {
func sorted(ascending: Bool = true, using comparator: (Element) -> (Element) -> ComparisonResult) -> [Element] {
return self.sorted { lhs, rhs in
comparator(lhs)(rhs) == (ascending ? .orderedAscending : .orderedDescending)
}
}
}
View UnitConcentrationMass+MicrogramsPerCubicMeter.swift
import Foundation
extension UnitConcentrationMass {
class var microgramsPerCubicMeter: UnitConcentrationMass {
let converter = UnitConverterLinear(coefficient: 1e-9)
return .init(symbol: "µg/m³", converter: converter)
}
}
View unzip.swift
func unzip<S: Sequence, T, U>(_ sequence: S) -> (AnySequence<T>, AnySequence<U>)
where S.Element == (T, U)
{
return (
AnySequence(sequence.lazy.map{ $0.0 }),
AnySequence(sequence.lazy.map{ $0.1 })
)
}
let fibonacci = sequence(first: (0, 1), next: { ($1, $0 + $1) })
View swift-unicode-name-escape-pre-pitch.swift
/*
# Problem
In Swift, it can be cumbersome to work with Unicode characters that are
non-printing, confusable, or have difficulty rendering in the editor.
For example, to generate the "Family: Woman, Girl" emoji:
*/
// Option 1: Unicode Scalar Value Escapes
View TruthyValue.swift
import Foundation
struct TruthyValue {
var value: Bool?
init(_ value: Bool?) {
self.value = value
}
init(_ value: Int) {
switch value {
You can’t perform that action at this time.