Skip to content

Instantly share code, notes, and snippets.

<h1>Types</h1>
<ul>
<li><a href="./DeclarationCollector">DeclarationCollector</a>:​
A Swift syntax visitor that collects declarations.</li>
<li><a href="./AssociatedType">AssociatedType</a>:​
An associated type declaration.</li>
<li><a href="./Class">Class</a>:​
A class declaration.</li>
<li><a href="./ConditionalCompilationBlock">ConditionalCompilationBlock</a>:​
A conditional compilation block declaration.</li>
@mattt
mattt / registry.bash
Created June 18, 2020 15:44
An example of how Git can be used as a transparent log for a package registry
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
# Returns the SHA-256 checksum of a string or file
function checksum() {
if [ -f "$1" ]; then
shasum -a 256 "$1" | cut -d ' ' -f1
@mattt
mattt / Rakefile
Last active June 10, 2020 14:18
A benchmark comparing various methods of downloading popular Swift packages
require 'benchmark'
require 'tmpdir'
require 'json'
include Benchmark
namespace :benchmark do
task all: %i[full_clone shallow_clone curl_unzip]
task full_clone: ['packages.json'] do
@mattt
mattt / CTExposureDetectionSession+Extensions.swift
Last active April 27, 2020 23:51
Theoretical convenience API for working with Apple's ContactTracing framework
import ContactTracing
extension CTExposureDetectionSession {
func addPositiveDiagnosisKeys(batching keys: [CTDailyTracingKey], completion: CTErrorHandler) {
if keys.isEmpty {
completion(nil)
} else {
let cursor = keys.index(keys.startIndex, offsetBy: maxKeyCount, limitedBy: keys.endIndex) ?? keys.endIndex
let batch = Array(keys.prefix(upTo: cursor))
let remaining = Array(keys.suffix(from: cursor))
@mattt
mattt / cc.css
Last active April 9, 2020 07:29
Creative Commons Symbols @font-face CSS
@font-face {
font-family: "Creative Commons Symbols";
src: url(font_path("CreativeCommonsSymbols.woff2")) format("woff2"),
url(font_path("CreativeCommonsSymbols.woff")) format("woff");
font-weight: normal;
font-style: normal;
unicode-range: U+1F10D-1F10F, U+1F16D-1F16F;
}
i {
import Foundation
extension Locale {
func localizedCurrencySymbol(forCurrencyCode currencyCode: String) -> String? {
guard let languageCode = languageCode, let regionCode = regionCode else { return nil }
/*
Each currency can have a symbol ($, £, ¥),
but those symbols may be shared with other currencies.
For example, in Canadian and American locales,
@mattt
mattt / main.swift
Last active May 4, 2024 11:22
NaturalLanguage Framework - NLTagger Language Support Matrix
import NaturalLanguage
let languages: [NLLanguage] = [
.amharic, .arabic, .armenian, .bengali, .bulgarian,
.burmese, .catalan, .cherokee, .croatian, .czech,
.danish, .dutch, .english, .finnish, .french,
.georgian, .german, .greek, .gujarati, .hebrew,
.hindi, .hungarian, .icelandic, .indonesian, .italian,
.japanese, .kannada, .khmer, .korean, .lao,
.malay, .malayalam, .marathi, .mongolian, .norwegian,
@mattt
mattt / swift-802.0.31.3.json
Last active December 9, 2019 20:32
Early Swift Doc output JSON for Swift standard library
This file has been truncated, but you can view the full file.
{
"files" : [
{
"enumerations" : [
{
"documentation" : [],
"declaration" : {
"attributes" : [],
"modifiers" : [
{
@mattt
mattt / Alamofire.json
Last active April 9, 2020 07:29
Extremely early proof-of-concept Markdown document generation output for swift-doc
{
"/Users/mattt/Desktop/Alamofire.swift" : {
"deinitializers" : [],
"functions" : [
{
"declaration" : {
"name" : "request",
"genericRequirements" : [],
"signature" : {
"output" : "DataRequest",
@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"