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 | |
class PowerSetIterator<T> { | |
var sourceSet: [T] | |
var l: Int | |
var setlen: Int | |
var ones: [Int] | |
var lastDigit: Int? | |
var yield1: Bool |
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
// | |
// PortionProgress.swift | |
// PortionProgress | |
// | |
// Created by Erison Veshi on 7/24/16. | |
// Copyright © 2016 Bashta. All rights reserved. | |
// | |
import UIKit |
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
func timeAgoSinceDate(date:NSDate, numericDates:Bool) -> String { | |
let calendar = NSCalendar.currentCalendar() | |
let now = NSDate() | |
let earliest = now.earlierDate(date) | |
let latest = (earliest == now) ? date : now | |
let components:NSDateComponents = calendar.components([NSCalendarUnit.Minute , NSCalendarUnit.Hour , NSCalendarUnit.Day , NSCalendarUnit.WeekOfYear , NSCalendarUnit.Month , NSCalendarUnit.Year , NSCalendarUnit.Second], fromDate: earliest, toDate: latest, options: NSCalendarOptions()) | |
if (components.year >= 2) { | |
return String.localizedStringWithFormat(NSLocalizedString("%d years ago", comment: ""), components.year) | |
} else if (components.year >= 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
// See the accompanying blog post: http://chris.eidhof.nl/posts/tiny-networking-in-swift.html | |
public enum Method: String { // Bluntly stolen from Alamofire | |
case OPTIONS = "OPTIONS" | |
case GET = "GET" | |
case HEAD = "HEAD" | |
case POST = "POST" | |
case PUT = "PUT" | |
case PATCH = "PATCH" | |
case DELETE = "DELETE" |