Skip to content

Instantly share code, notes, and snippets.

View Bashta's full-sized avatar
🎯
Focusing

Erison Veshi Bashta

🎯
Focusing
  • Vlore
View GitHub Profile
@vladignatyev
vladignatyev / PowerSet.swift
Created March 1, 2020 17:16
Combinatorics: Pure Swift 5 Power Set algorithm implementation. Returns power set elements (permutation), in ascending order from smaller to bigger subsets.
import Foundation
class PowerSetIterator<T> {
var sourceSet: [T]
var l: Int
var setlen: Int
var ones: [Int]
var lastDigit: Int?
var yield1: Bool
//
// PortionProgress.swift
// PortionProgress
//
// Created by Erison Veshi on 7/24/16.
// Copyright © 2016 Bashta. All rights reserved.
//
import UIKit
@arnaudlamy
arnaudlamy / timeago.swift
Last active July 17, 2019 09:13 — forked from jacks205/timeago.swift
"Time ago" function for Swift (based on MatthewYork's DateTools for Objective-C) *Swift 2
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){
// 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"