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
//: [Previous](@previous) | |
import Foundation | |
var input = """ | |
626 2424 2593 139 2136 163 1689 367 2235 125 2365 924 135 2583 1425 2502 | |
183 149 3794 5221 5520 162 5430 4395 2466 1888 3999 3595 195 181 6188 4863 | |
163 195 512 309 102 175 343 134 401 372 368 321 350 354 183 490 | |
2441 228 250 2710 200 1166 231 2772 1473 2898 2528 2719 1736 249 1796 903 | |
3999 820 3277 3322 2997 1219 1014 170 179 2413 183 3759 3585 2136 3700 188 |
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
// | |
// LICENSE: MIT | |
// Created by Andrew C on 4/25/17. | |
// Copyright © 2017 Andrew Crookston. All rights reserved. | |
// | |
class TopAlignedLabel: UILabel { | |
override func drawText(in rect: CGRect) { | |
if let string = text as NSString? { | |
let size = string.boundingRect(with: CGSize(width: self.frame.width,height: CGFloat.greatestFiniteMagnitude), |
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
// | |
// CoreExtensions | |
// | |
// Created by Andrew Crookston on 1/30/18. | |
// | |
import Foundation | |
public extension DateComponents { | |
public static func with(year: Int? = nil, month: Int? = nil, day: Int? = nil, hour: Int? = nil, minute: Int? = nil, second: Int? = nil, calendar: Calendar = .current, timeZone: TimeZone? = nil) -> DateComponents { |
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 TimeInterval { | |
var milliseconds: Int { | |
return Int(truncatingRemainder(dividingBy: 1) * 100) | |
} | |
var minutes: Int { | |
return Int(self / 60) | |
} | |
var seconds: Int { |
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 UIColor { | |
static func rgba(_ r: CGFloat, _ g: CGFloat, _ b: CGFloat, _ a: CGFloat) -> UIColor { | |
return UIColor(red: r / 255.0, green: g / 255.0, blue: b / 255.0, alpha: a) | |
} | |
} |
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
struct Test { | |
let computed: Int | |
init(a: Int, b: Int, c: Int, d: Int, e: Int = 0, f: Int = 0, g: Int = 0, h: Int = 0) { | |
var value: Int = (a << 56) | |
value |= (b << 48) | |
value |= (c << 40) | |
value |= (d << 32) | |
value |= (e << 24) | |
value |= (f << 16) | |
value |= (g << 8) |
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
class HeaderCollectionViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UICollectionViewDelegate { | |
var collectionView : UICollectionView? | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
var layout = CSStickyHeaderFlowLayout() | |
layout.parallaxHeaderReferenceSize = CGRectMake(... size of the header...) | |
layout.minimumInteritemSpacing = 0 |
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
// | |
// MigrationCreateItems.swift | |
// Stash | |
// | |
// Created by Andrew C on 8/30/17. | |
// Copyright © 2017 Andrew Crookston. All rights reserved. | |
// License: MIT | |
// | |
import Foundation |
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 String { | |
func localized(_ args: CVarArg...) -> String { | |
return String(format: NSLocalizedString(self, comment: ""), arguments: args) | |
} | |
} | |
let format = NSLocalizedString("Hello %@", comment: "") | |
print(String(format: format, "World")) |