View gist:777c5b9e004122ba7930
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Dispatch | |
@_silgen_name("dispatch_sync") private func os_dispatch_sync(queue: dispatch_queue_t, @noescape _ block: dispatch_block_t) | |
@_silgen_name("dispatch_barrier_sync") private func os_dispatch_barrier_sync(queue: dispatch_queue_t, @noescape _ block: dispatch_block_t) | |
private func dispatch_sync_rethrow_wrapper<Return>(queue: dispatch_queue_t, @noescape dispatcher: (dispatch_queue_t, dispatch_block_t) -> Void, @noescape body: () throws -> Return, @noescape onError: ErrorType throws -> Void) rethrows -> Return { | |
var ret: Return! | |
var innerError: ErrorType? | |
os_dispatch_sync(queue) { |
View ChunkSequence.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Derived from http://blog.krzyzanowskim.com/2015/10/24/chunksequence-have-cake-and-eat-it/ | |
struct ChunkSequence<Element>: SequenceType { | |
typealias Collection = AnyForwardCollection<Element> | |
let collection: Collection | |
let chunkSize: Collection.Index.Distance | |
private init<C: CollectionType where C.Index: ForwardIndexType, C.Generator.Element == Element>(_ base: C, chunkSize: C.Index.Distance) { | |
self.collection = AnyForwardCollection(base) | |
self.chunkSize = chunkSize.toIntMax() |
View DynamicTypeLabel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DynamicTypeLabel.swift | |
// | |
// Created by Indragie on 10/16/14. | |
// Copyright (c) 2014 Indragie Karunaratne. All rights reserved. | |
// | |
import UIKit | |
class DynamicTypeLabel : UILabel { |
View XCDFakeCarrier.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Copyright (c) 2012-2013 Cédric Luthi / @0xced. All rights reserved. | |
// | |
#if TARGET_IPHONE_SIMULATOR | |
@interface NSObject () | |
- (void)setItem:(int)item enabled:(BOOL)enabled; |
View test.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// clang -framework Foundation -fobjc-arc -O3 test.m | |
#import <Foundation/Foundation.h> | |
@interface NSNumber (RangeCreation) | |
- (NSValue *): (NSInteger)length; | |
@end |