Skip to content

Instantly share code, notes, and snippets.

View faris-mobile89's full-sized avatar
:shipit:
Focusing

Faris Abu Saleem faris-mobile89

:shipit:
Focusing
View GitHub Profile
@faris-mobile89
faris-mobile89 / Loadable.swift
Created July 24, 2020 01:14 — forked from nalexn/Loadable.swift
A container for a resource requested from the backend
// Copyright © 2019 Alexey Naumov. MIT License
import Foundation
enum Loadable<Value> {
case notRequested
case isLoading(prevValue: Value?)
case loaded(Value)
case failed(Error)
}
@faris-mobile89
faris-mobile89 / .gitignore
Created April 16, 2020 23:58
CocoaPods GitIgnore Template
### CocoaPods ###
## CocoaPods GitIgnore Template
# CocoaPods - Only use to conserve bandwidth / Save time on Pushing
# - Also handy if you have a large number of dependant pods
# - AS PER https://guides.cocoapods.org/using/using-cocoapods.html NEVER IGNORE THE LOCK FILE
Pods/
### Swift ###
@faris-mobile89
faris-mobile89 / TemplateInfo.plist
Created April 16, 2020 23:53
A custom Xcode Template with MVVM coordinator
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Icon</key>
<string>TemplateIcon</string>
<key>SortOrder</key>
<string>1</string>
<key>Description</key>
<string>This generates a new scene using MVVM architecture. It consists of the view controller, view model and navigator.</string>
@faris-mobile89
faris-mobile89 / Percent.swift
Last active April 4, 2020 01:46
Percent increase & decrease formula
import UIKit
/** Percent increase formula
* Percentage increase is useful when you want to analyse how a value has changed with time. Although percentage increase is very similar to absolute increase, the former is more useful when comparing multiple data sets. For example, a change from 1 to 51 and from 50 to 100 both have an absolute change of 50, but the percentage increase for the first is 5000%, while for the second it is 100%, so the first change grew a lot more. This is why percentage increase is the most common way of measuring growth.
* https://www.omnicalculator.com/math/percentage-increase
* https://www.omnicalculator.com/math/percentage-change
*/
///Percent increase = [(new value - original value)/original value] * 100
func percentIncrease(newValue:Double, originalValue:Double) -> Double{