Skip to content

Instantly share code, notes, and snippets.

extension Date {
func yearsCount(from date: Date) -> Int {
return Calendar.current.dateComponents([.year], from: date, to: self).year ?? 0
}
func monthsCount(from date: Date) -> Int {
return Calendar.current.dateComponents([.month], from: date, to: self).month ?? 0
}
/* 3.1 */
// 1. Write Pseudo code find a given element in an array
func linearSearch<T: Equatable>(target: T, in array: [T]) {
for (index, element) in array.enumerated() {
if element == target {
print("Found \(element) at \(index)")
break
} else if (index == array.count) {
print("The target \(target) not found")
@williamhqs
williamhqs / Test.playground
Last active May 13, 2020 10:21
ProperyWrapper decode
import UIKit
let jsonString =
"""
{
"name": "Tim",
"age": "28"
}
"""
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy