This file contains hidden or 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
| // | |
| // MultiDirectionAdjudicatingScrollView.swift | |
| // Khan Academy | |
| // | |
| // Created by Andy Matuschak on 12/16/14. | |
| // Copyright (c) 2014 Khan Academy. All rights reserved. | |
| // | |
| import UIKit | |
| import UIKit.UIGestureRecognizerSubclass |
This file contains hidden or 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
| # You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine | |
| # This is how I upload my new Sol Trader builds (http://soltrader.net) | |
| # Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash | |
| S3KEY="my aws key" | |
| S3SECRET="my aws secret" # pass these in | |
| function putS3 | |
| { | |
| path=$1 |
This file contains hidden or 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 CustomStringConvertible { | |
| var description : String { | |
| var description: String = "" | |
| if self is AnyObject { | |
| // may be able to use unsafeAddressOf now | |
| description = "***** \(self.dynamicType) - <\(unsafeAddressOf((self as! AnyObject)))>***** \n" | |
| } else { | |
| description = "***** \(self.dynamicType) *****\n" | |
| } | |
| let selfMirror = Mirror(reflecting: self) |
This file contains hidden or 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
| // only class types: | |
| func myCast<MyClass: AnyObject>(value: AnyObject, type: MyClass.Type) -> MyClass? { | |
| return value as? MyClass | |
| } | |
| // any type (class, struct, etc): | |
| func myCast1<MyClass: Any>(value: Any, type: MyClass.Type) -> MyClass? { | |
| return value as? MyClass |
This file contains hidden or 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
| // | |
| // MockURLProtocol.swift | |
| // SolutoHome | |
| // | |
| // Created by Omer Levi Hevroni on 2/23/16. | |
| // Copyright © 2016 Soluto. All rights reserved. | |
| // | |
| import Foundation |
This file contains hidden or 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 Foundation | |
| // Extend String to support regex searching by conforming | |
| // to CustomStringConvertible | |
| extension String: CustomStringConvertible { | |
| public var description: String {return self} | |
| } | |
| // Regex support for keys | |
| public extension Dictionary where Key: CustomStringConvertible { |
This file contains hidden or 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
| plutil -lint MyProject.xcodeproj/project.pbxproj |
This file contains hidden or 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 Foundation | |
| extension Dictionary { | |
| mutating public func setValue(val: AnyObject, forKeyPath keyPath: String) { | |
| var keys = keyPath.componentsSeparatedByString(".") | |
| guard let first = keys.first as? Key else { print("Unable to use string as key on type: \(Key.self)"); return } | |
| keys.removeAtIndex(0) | |
| if keys.isEmpty, let settable = val as? Value { | |
| self[first] = settable | |
| } else { |
This file contains hidden or 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
| # must install gem | |
| # sudo gem install cocoapods-deintegrate | |
| pod deintegrate |
This file contains hidden or 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
| // Draw circle | |
| CGContextSaveGState(context); | |
| CGFloat lineWidth = 2.0f; | |
| CGPoint center = CGPointMake(rect.size.width / 2, rect.size.height / 2); | |
| UIBezierPath *outerCirclePath = [UIBezierPath bezierPath]; | |
| [outerCirclePath addArcWithCenter:center radius:(rect.size.height / 2) - insetPad/2 startAngle:0 endAngle:2 * M_PI clockwise:YES]; | |
| UIBezierPath *innerCirclePath = [UIBezierPath bezierPath]; | |
| [innerCirclePath addArcWithCenter:center radius:((rect.size.height / 2) - lineWidth - (insetPad/2)) startAngle:0 endAngle:2 * M_PI clockwise:YES]; | |
| [outerCirclePath appendPath:innerCirclePath]; | |
| outerCirclePath.usesEvenOddFillRule = YES; |
NewerOlder