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
extension NSTimer { | |
/** | |
Creates and schedules a one-time `NSTimer` instance. | |
- Parameters: | |
- delay: The delay before execution. | |
- handler: A closure to execute after `delay`. | |
- Returns: The newly-created `NSTimer` instance. | |
*/ |
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
// | |
// CollectionViewDataSource.swift | |
// Khan Academy | |
// | |
// Created by Andy Matuschak on 10/14/14. | |
// Copyright (c) 2014 Khan Academy. All rights reserved. | |
// | |
import UIKit |
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
curl https://developer.apple.com/videos/wwdc/2014/ | grep -iIoh 'http.*._hd_.*dl=1">HD' | sed -e 's/\?dl=1">HD//g' | xargs -n1 wget -N g |
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
BOOL MTDIsBoldTextEnabled(void) { | |
static BOOL boldTextEnabled = NO; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
// Hack that checks if the "bold text" flag in the accessibility settings is enabled | |
UIFont *font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody]; | |
boldTextEnabled = [font.fontName rangeOfString:@"MediumP4"].location != NSNotFound; | |
}); |
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
// http://stackoverflow.com/a/19277383 | |
// | |
- (void)textViewDidChange:(UITextView *)textView | |
{ | |
CGRect line = [textView caretRectForPosition:textView.selectedTextRange.start]; | |
CGFloat overflow = line.origin.y + line.size.height | |
- ( textView.contentOffset.y + textView.bounds.size.height | |
- textView.contentInset.bottom - textView.contentInset.top ); | |
if (overflow > 0) { | |
// We are at the bottom of the visible text and introduced a line feed, scroll down (iOS 7 does not do it) |
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
@interface DDDelegateProxy : NSProxy | |
+ (id)proxyForDelegate:(id)delegate conformingToProtocol:(Protocol *)protocol; | |
@property (weak, readonly) id delegate; | |
@property (strong, readonly) Protocol *protocol; | |
/*! | |
* Set a default return value for a method on the delegate's protocol. | |
* \param value This must be a block that returns the default value. Bad Things will happen if it's not. |
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
@implementation BHSCollectionViewFlowLayout | |
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { | |
NSArray *allAttrs = [super layoutAttributesForElementsInRect:rect]; | |
for (UICollectionViewLayoutAttributes *attributes in allAttrs) { | |
attributes.frame = CGRectIntegral(attributes.frame); | |
} | |
return allAttrs; | |
} |
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
// | |
// OLD AND BUSTED | |
// | |
if ([self.zoomingDelegate respondsToSelector:@selector(zoomingWindow:didZoomOutViewController:)] == YES) | |
{ | |
// Do something important. | |
} | |
// |
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
#!/usr/bin/env python | |
import argparse, os, re, subprocess | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--sdk', default='', help='OS X or iOS SDK directory') | |
parser.add_argument('--no-frameworks', action='store_true', default=False, help='do not print frameworks, only unprefixed classes') | |
args = parser.parse_args() | |
print_frameworks = not args.no_frameworks |
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
#!/bin/sh | |
# Current as working as of 2012/4/17 | |
# Xcode 4.3.2 | |
PROJECT_ROOT="$HOME/SomeDirWhereYourProjectLives/XXXXXXXX" | |
WORKSPACE="$PROJECT_ROOT/XXXXXXXX.xcodeproj/project.xcworkspace" | |
CONFIG="AdHoc" | |
SCHEME="XXXXXXXX" |
NewerOlder