Skip to content

Instantly share code, notes, and snippets.

@mattt
mattt / crash.log
Created June 12, 2018 10:12
Crash log resulting from use of CRF algorithm when training text classifier in Xcode 10.0 beta (10L176w)
0 swift 0x00000001109fac5a PrintStackTraceSignalHandler(void*) + 42
1 swift 0x00000001109fa066 SignalHandler(int) + 966
2 libsystem_platform.dylib 0x00007fff65e29d9a _sigtramp + 26
3 libsystem_malloc.dylib 0x00007fff65e09ed4 tiny_malloc_should_clear + 289
4 CoreNLP 0x00007fff4d7948eb invocation function for block in CoreNLP::NLModelTrainer::readSample(__CFString const*, std::__1::vector<CFRange, std::__1::allocator<CFRange> > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, CoreNLP::NLTrainerDataType) + 1010
5 CoreNLP 0x00007fff4d751fd7 CoreNLP::CompositeTagger::enumerateTokens(NLTokenizerUnit, CFRange, unsigned long, void (NLToken, bool*) block_pointer) + 567
6 CoreNLP 0x00007fff4d7944c0 CoreNLP::NLModelTrainer::readSample(__CFString
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) })
import Foundation
extension UnitConcentrationMass {
class var microgramsPerCubicMeter: UnitConcentrationMass {
let converter = UnitConverterLinear(coefficient: 1e-9)
return .init(symbol: "µg/m³", converter: converter)
}
}
protocol Calendar {
typealias Unit: BidirectionalIndexType
typealias Era: Unit
typealias Year: Unit
typealias Month: Unit
typealias Week: Unit
typealias Day: Unit
typealias Weekday: Unit
typealias Hour: Unit

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:

@mattt
mattt / Sieve.swift
Last active January 27, 2019 20:35
Sieve of Eratosthenes with Accelerate
// Calculate prime numbers in a given range
// using Sieve of Eratosthenes
import Accelerate
var primes: [Int] = []
let range = 0...999
var numbers = range.map(Float.init)

A number of tech news outlets, including WIRED, GigaOm, and MIT Technology Review, have recently started writing about Multipeer Connectivity ("one weird trick that the NSA hates"). Since the NSHipster article on the subject has been linked to in a lot of this coverage, I wanted to share some additional thoughts on the matter:

Multipeer Connectivity(http://nshipster.com/multipeer-connectivity/) represents a significant shift in the opposite direction of how we conventionally think about mobile applications. Nearly every app on your phone operates in a client-server model, with the device making requests to remote cloud services to send and receive messages, photos, and videos. The [

public struct BoundedSequence<Base>: Sequence, IteratorProtocol where Base: Sequence {
public struct Boundary: Equatable {
public let isStart: Bool
public let isEnd: Bool
}
private var _iterator: Base.Iterator
private var _previous: Base.Element?
private var _current: Base.Element?
private var _next: Base.Element?
import Darwin
extension Int {
static func random() -> Int {
return Int(arc4random())
}
static func random(range: Range<Int>) -> Int {
return Int(arc4random_uniform(UInt32(range.endIndex - range.startIndex))) + range.startIndex
}
@mattt
mattt / undocumented-symbol-urls-2019-09-20.txt
Created October 19, 2019 17:13
Undocumented Apple API symbols according to nooverviewavailable.com (as of 2019-09-20)
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"
"https://developer.apple.com/documentation/accelerate/vdsp/radix/3240761"