Skip to content

Instantly share code, notes, and snippets.

View Tron5000's full-sized avatar
💭
Coding!

Mark Brady Tron5000

💭
Coding!
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using System.Runtime.Caching;
using System.Runtime.Serialization;
using System.Reflection;
using System.Linq.Expressions;
using System.Diagnostics;
@Tron5000
Tron5000 / gist:2bd9965aa3a0346695c6
Last active March 22, 2017 03:27
Singleton Pattern in Swift >= v1.2
// Swift 1.2 introduced support for static properties.
class Singleton {
static let shared = Singleton()
}
@Tron5000
Tron5000 / gist:7bb51318db1da86a3a78
Last active January 7, 2020 07:45
Compressing/Decompressing UUID to 22 characters via base64
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? {
@Tron5000
Tron5000 / gist:74d3b46dcc93fe12e718
Last active August 29, 2015 14:04
Singleton Pattern in Swift < v1.2
class Singleton {
class var sharedInstance : Singleton {
struct Static {
static let instance : Singleton = Singleton()
}
return Static.instance
}
}