Skip to content

Instantly share code, notes, and snippets.

@mikeger
mikeger / Collection+FirstMap.swift
Created November 8, 2023 14:30
Return first element that passes the mapping
extension Collection {
public func firstMap<T>(where predicate: (Element) throws -> T?) rethrows -> T? {
for element in self {
if let value = try predicate(element) {
return value
}
}
return nil
}
}
@mikeger
mikeger / find-slow-tests.swift
Last active March 2, 2023 12:32
Parse Xcode tests runtime, show top 25 tests
#!/usr/bin/swift
import Foundation
import RegexBuilder
var lines: [String] = []
while let line = readLine() {
lines.append(line)
}
@mikeger
mikeger / AttributedString.swift
Created March 1, 2016 09:01
Swift custom operators
import Foundation
import UIKit
extension String {
var attributedString: NSAttributedString {
return NSAttributedString(string: self)
}
}
@mikeger
mikeger / UIView+WR_ExtendedBlockAnimations.h
Created October 29, 2015 10:07
WireExtendedBlockAnimation
//
// UIView+WR_ExtendedBlockAnimations.h
// Wire
//
// Created by Jacob Persson on 29/07/15.
// Copyright (c) 2015 Wire Swiss GmbH. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <RBBAnimation/RBBEasingFunction.h>