Skip to content

Instantly share code, notes, and snippets.

@rayvinly
rayvinly / RevenueFormatter.swift
Created October 5, 2018 19:49
Format large currency values using abbreviations such as K, M, B, T
func formatRevenue(_ revenue: Double) -> String
{
let currencyFormatter = NumberFormatter()
currencyFormatter.numberStyle = .currency
currencyFormatter.minimumFractionDigits = 0
currencyFormatter.maximumFractionDigits = 1
var number: NSNumber
switch revenue {
case 1_000_000_000_000..<1_000_000_000_000_000:
@rayvinly
rayvinly / GistAPI.swift
Created February 5, 2016 07:43
A simple API to fetch gists on GitHub
//
// GistAPI.swift
// Gists
//
// Created by Raymond Law on 2/5/16.
// Copyright © 2016 Clean Swift. All rights reserved.
//
import Foundation
@rayvinly
rayvinly / ViewController.swift
Created January 11, 2016 18:12
Breaking down responsibilities
import UIKit
// MARK: - User
class User: Equatable, Hashable
{
var id: String
var email: String
var hashValue: Int {
return id.hashValue
@rayvinly
rayvinly / MassiveViewDidLoad.swift
Created January 5, 2016 04:43
Massive View Did Load
class ViewController: UITableViewController
{
override func viewDidLoad()
{
super.viewDidLoad()
let currentUser = userManager.loggedInUser()
if let currentUser = currentUser {
var followerPosts = [Post]()
let followers = userManager.followersForUser(currentUser)
for follower in followers {