Skip to content

Instantly share code, notes, and snippets.

@tapi
tapi / wwdc2014
Created July 16, 2019 14:49 — forked from phnessu4/wwdc2014
wwdc 2014 sessions and pdf
pdf
http://devstreaming.apple.com/videos/wwdc/2014/102xxw2o82y78a4/102/102_platforms_state_of_the_union.pdf?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/201xx2xfazhzce8/201/201_advanced_topics_in_internationalization.pdf?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/202xx3ane09vxdz/202/202_whats_new_in_cocoa_touch.pdf?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/203xxh9oqtm0piw/203/203_introducing_healthkit.pdf?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/204xxhe1lli87dm/204/204_whats_new_in_cocoa.pdf?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/205xxqzduadzo14/205/205_creating_extensions_for_ios_and_os_x,_part_1.pdf?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/206xxdiurnffagr/206/206_introducing_the_modern_webkit_api.pdf?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/207xx270npvffao/207/207_accessibility_on_os_x.pdf?dl=1
@tapi
tapi / Pairwise+Sequence.swift
Created December 5, 2017 20:22
Swift 4 - Pairwise Sequence
public struct PairwiseIterator<T>: IteratorProtocol {
private var iterator: AnyIterator<T>
private var lastElement: T?
public init(_ iterator: AnyIterator<T>) {
self.iterator = iterator
self.lastElement = self.iterator.next()
}
@tapi
tapi / UICollectionView+Registration.swift
Created April 4, 2016 16:38
Typed UITableView & UICollectionView Dequeuing in Swift
import UIKit
extension UICollectionReusableView {
/// The default implementation of `defaultIdentifier()` uses `NSStringFromClass(class)` rather than `String(class)` so that the module name is includded.
/// The hope being that this makes collisions unlikely making it unnnecessary to provide your own implementations.
public class func defaultIdentifier() -> String {
return NSStringFromClass(self)
}
}
@tapi
tapi / ReferenceTypes.swift
Created November 26, 2015 20:40
Test case demonstrating relationship clobbering in ObjectMapper 1.0
import Foundation
import ObjectMapper
class Person: Mappable {
var name: String?
var spouse: Person?
required init?(_ map: Map) {
}
@tapi
tapi / error extension
Created March 27, 2015 18:31
Wouldn't this work instead of a nil default?
extension NSError{
//...
class func
myParseError(description:String?="Parse failed.") -> NSError {
let info = [NSLocalizedDescriptionKey: description]
return self(
domain:myDomain,
code:MyErrorCodes.ParseError.rawValue,
userInfo:info)
@tapi
tapi / GroupBy.swift
Created February 6, 2015 14:24
A generic groupby function that should work similarily to ruby's
/**
Group all items in a collection according to the value returned by a block.
:param: collection The collection whose items you want to group.
:param: groupBlock A block that returns a key for that value to be grouped by.
:returns: Returns a dictionary whose keys are the values returned by the groupBlock.
*/
func groupBy<V, K : protocol<Hashable, Equatable>, C : _ExtensibleCollectionType where C.Generator.Element == V>(collection: C, groupBlock: (V) -> K) -> [K: [V]] {
typealias ValueGroup = [V]
@tapi
tapi / BookExample.swift
Created June 4, 2014 05:41
Generic types broken into separate lines
func anyCommonElements <T, U where T: Sequence, U: Sequence, T.GeneratorType.Element: Equatable, T.GeneratorType.Element == U.GeneratorType.Element> (lhs: T, rhs: U) -> Bool {
for lhsItem in lhs {
for rhsItem in rhs {
if lhsItem == rhsItem {
return true
}
}
}
return false
}
### Keybase proof
I hereby claim:
* I am tapi on github.
* I am tapi (https://keybase.io/tapi) on keybase.
* I have a public key whose fingerprint is B8A2 FE8D A75F 3FD8 9114 77D5 E7E6 6A04 5D6C 1382
To claim this, I am signing this object:
@tapi
tapi / gist:9236422
Created February 26, 2014 19:17
This is the funkiest assignment syntax I have ever seen used in Objective-C
_imageView = ({
UIImageView *imageView = [[UIImageView alloc] init];
imageView.contentMode = UIViewContentModeScaleAspectFill;
[self.scrollView addSubview:imageView];
imageView;
});
@tapi
tapi / pageViewGestures.m
Created August 14, 2013 15:07
A little had to get at the gesture recognizers of a UIPageviewControllers paging view
- (void)didMoveToParentViewController:(UIViewController *)parent
{
[super didMoveToParentViewController:parent];
if ([parent isKindOfClass:[UIPageViewController class]]) {
UIScrollView *scrollView;
for (UIView *view in parent.view.subviews) {
if ([view isKindOfClass:[UIScrollView class]]) {
scrollView = (UIScrollView *)view;
}