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 UIKit | |
protocol SegueHandlerType { | |
typealias SegueIdentifier: RawRepresentable | |
} | |
extension SegueHandlerType where | |
Self: UIViewController, | |
SegueIdentifier.RawValue == String | |
{ |
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 UIKit | |
/// A very simple example view that can accept keyboard input and add or delete text from an enclosed label. | |
class CustomTextInputView : UIControl, UIKeyInput { | |
var label : UILabel? | |
override func canBecomeFirstResponder() -> Bool { | |
return true | |
} |
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
// | |
// SimpleScrollingStack.swift | |
// A super-simple demo of a scrolling UIStackView in iOS 9 | |
// | |
// Created by Paul Hudson on 10/06/2015. | |
// Learn Swift at www.hackingwithswift.com | |
// @twostraws | |
// | |
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
# | |
# This file is the units database for use with GNU units, a units conversion | |
# program by Adrian Mariano adrianm@gnu.org | |
# | |
# March 2014 Version 2.10 | |
# | |
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006 | |
# 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 | |
# Free Software Foundation, Inc | |
# |
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
// NSScanner+Swift.swift | |
// A set of Swift-idiomatic methods for NSScanner | |
// | |
// (c) 2015 Nate Cook, licensed under the MIT license | |
import Foundation | |
extension NSScanner { | |
// MARK: Strings |
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
// MARK: Using NSURLSession | |
// Get first todo item | |
let todoEndpoint: String = "http://jsonplaceholder.typicode.com/todos/1" | |
guard let url = NSURL(string: todoEndpoint) else { | |
print("Error: cannot create URL") | |
return | |
} | |
let urlRequest = NSURLRequest(URL: url) |
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
2015-01-26 18:02:31.223 Invaluable iOS[29323:1139622] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '{objective 0x7ff55b678f30: <251:-343, 250:915> + <250:5.96046e-08>*0x7ff55d81f580.marker{id: 7363} + <250:-2.98023e-08>*0x7ff55db73220.marker{id: 7364} + <250:2>*0x7ff55fa3e030.marker{id: 9313} + <250:2>*0x7ff55fd01060.negError{id: 9018} + <250:-2>*0x7ff55fd01060.posErrorMarker{id: 9017} + <250:-2>*0x7ff55fd018b0.marker{id: 9032}}: internal error. Setting empty vector for variable INVTriColumnPriceView:0x7ff55fe35160.minX{id: 8877}.' | |
*** First throw call stack: | |
( | |
0 CoreFoundation 0x00000001085ddf35 __exceptionPreprocess + 165 | |
1 libobjc.A.dylib 0x000000010546cbb7 objc_exception_throw + 45 | |
2 CoreFoundation 0x00000001085dde6d +[NSException raise:format:] + 205 | |
3 Foundation 0x00000001060cf45e -[NSISObjectiveLinearExpression setPriorityVector:forKnownAbsentVariable:] + 76 | |
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
// | |
// BitwiseOptions.swift | |
// | |
// Created by Gregory Higley on 11/24/14. | |
// Copyright (c) 2014 Prosumma LLC. All rights reserved. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
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
// (c) 2014 Nate Cook, licensed under the MIT License | |
/** | |
Returns a tuple with the closest compound fraction possible with Unicode's built-in "vulgar fractions". | |
See here: http://www.unicode.org/charts/PDF/U2150.pdf | |
:param: number The floating point number to convert. | |
:returns: A tuple (String, Double): the string representation of the closest possible vulgar fraction and the value of that string |
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 Foundation | |
// Compressing and decompressing a UUID to 22 characters via base64. | |
// Works great as a Swift playground. These articles were helpful: | |
// http://blog.codinghorror.com/equipping-our-ascii-armor/ | |
// http://69.195.124.60/~jasondoh/2013/08/14/creating-a-short-guid-in-objective-c/ | |
let identifier = NSUUID().uuidString | |
let base64TailBuffer = "=" | |
func compress(identifier: String) -> String? { |