Skip to content

Instantly share code, notes, and snippets.

View keitaito's full-sized avatar

Keita Ito keitaito

View GitHub Profile
@milseman
milseman / Swift5StateOfString.md
Created January 10, 2018 19:49
State of String: ABI, Performance, Ergonomics, and You!

State of String: ABI, Performance, Ergonomics, and You!

Hello, I’ve been working on implementing, optimizing, and improving String in preparation for ABI stability, and I thought I’d share the current status of String in Swift 5 and some potential directions to go. This is the product of conversations with open source contributors and my colleagues on the Swift standard library team at Apple.

The primary area of focus is stabilizing String’s ABI, but we’d be remiss if we couldn’t also fit in performance and ergonomic improvements. String’s ergonomics in particular is one area where we think the status quo is woefully inadequate, and over half of this email is devoted to that topic. At the end, there’s a section about a community initiative that we hope can help users of String as well as guide future development.

(Note: I’m sending this to swift-dev because much of the contents revolve around implementation concerns. I’ll also cross-reference on swift-evolution and swift-users. See also the [StringManife

@inamiy
inamiy / typed-error-poem.md
Last active November 8, 2018 13:58
Swift Poem: Why I prefer typed error (for https://github.com/apple/swift-evolution/pull/757)

Typed error can be useful in certain cases, especially when accompanied with NoError type.

For example, in reactive programming, https://github.com/ReactiveCocoa/ReactiveSwift (typed error) allows us to create UI bindings only if Error is NoError, i.e.:

static func <~ <Source: BindingSource> (provider: Self, source: Source) -> Disposable? 
    where Source.Value == Value, Source.Error == NoError { ... }
    
// example
let alphaSignal: Signal = ...
@shunirr
shunirr / criminal_jc.md
Last active June 21, 2025 08:07
女子中学生チケット詐欺事件

criminal_jc

@0xmachos
0xmachos / Keychain.md
Last active July 28, 2025 06:29
Useful resources for working with iOS/ macOS Keychain API

Keychain API

kSecAttrAccessible Mapping

Protection Domain (pdmn) Keychain Accessibility Values
ck kSecAttrAccessibleAfterFirstUnlock
cku kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
dk kSecAttrAccessibleAlways
akpu kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly
@tayvano
tayvano / gist:6e2d456a9897f55025e25035478a3a50
Created February 19, 2017 05:29
complete list of ffmpeg flags / commands
Originall From: Posted 2015-05-29 http://ubwg.net/b/full-list-of-ffmpeg-flags-and-options
This is the complete list that’s outputted by ffmpeg when running ffmpeg -h full.
usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfile}…
Getting help:
-h — print basic options
-h long — print more options
-h full — print all options (including all format and codec specific options, very long)
let str = "acxz"
func isFunny(_ s: AnySequence<UInt8>) -> Bool {
let n1: [Int] = zip(s.dropFirst(), s).map { Int($0)-Int($1) }
let n2: [Int] = zip(s.reversed().dropFirst(), s.reversed()).map { Int($1)-Int($0) }
return n1 == n2
}
isFunny(AnySequence(str.utf8))
@yaakov-h
yaakov-h / ReadingListReader.swift
Last active January 10, 2021 08:17
Read your Safari Reading List and dump to plain text
import Foundation
func fatalerror(_ text : String) {
fputs(text, __stderrp)
exit(-1)
}
struct ReadingListItem {
init(title: String?, previewText: String?, url: URL, dateAdded: Date) {
self.title = title
@brennanMKE
brennanMKE / HTTPStatusCodes.swift
Last active June 5, 2023 15:19
Swift Enums for HTTP Status Codes
enum HTTPStatusCodes: Int {
// 100 Informational
case Continue = 100
case SwitchingProtocols
case Processing
// 200 Success
case OK = 200
case Created
case Accepted
case NonAuthoritativeInformation
@mrh-is
mrh-is / SantaArrivalCalculator.swift
Created December 23, 2016 10:41
When will Santa be at my house?
extension Location {
func closestLocationOnPath(start: Location, end: Location) -> (location: Location, t: Double, distance: Double) {
let pathVector = (latitude: end.latitude - start.latitude, longitude: end.longitude - start.longitude)
var t = (self.latitude * pathVector.latitude - start.latitude * pathVector.latitude + self.longitude * pathVector.longitude - start.longitude * pathVector.longitude) / (pow(pathVector.latitude,2) + pow(pathVector.longitude,2))
t = min(max(t, 0), 1)
let closestLocation = Location(latitude: start.latitude + t * pathVector.latitude, longitude: start.longitude + t * pathVector.longitude)
return (location: closestLocation, t: t, distance: distance(to: closestLocation))
}
func distance(to other: Location) -> Double {
@nazywamsiepawel
nazywamsiepawel / UICollectionView + NSFetchedResultsController.swift
Created October 17, 2016 13:18
UICollectionView + NSFetchedResultsController Swift 3 / iOS 10
var blockOperations: [BlockOperation] = []
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
if type == NSFetchedResultsChangeType.insert {
print("Insert Object: \(newIndexPath)")
blockOperations.append(
BlockOperation(block: { [weak self] in