- Create new file and name
.my_custom_commands.sh
- Add some functions e.g
function ios() {
open -a "Xcode" ~/Documents/iOS/MyiOSProject.xcodeproj
}
private func saveRandomContact() { | |
let store = CNContactStore() | |
let contact = CNMutableContact() | |
// Name | |
contact.givenName = UUID().uuidString | |
// Phone | |
contact.phoneNumbers.append( | |
CNLabeledValue( |
import Foundation | |
enum Result<T> { | |
case success(T) | |
case failure(Error) | |
} | |
class Service: ServiceProtocol { | |
func get(callback: @escaping ((Result<[MyObject]>) -> ())) { | |
let url = URL(string: Links.baseUrl)! |
class Node<T> { | |
var value:T | |
var next: Node? | |
var previous: Node? | |
init(value: T) { | |
self.value = value | |
self.next = nil | |
self.previous = nil | |
} |
class Tree { | |
let value: Int | |
var left: Tree? | |
var right: Tree? | |
init(_ v: Int) { | |
self.value = v | |
} | |
} |
class Node<T> { | |
var value:T | |
var next: Node? | |
var previous: Node? | |
init(value: T) { | |
self.value = value | |
self.next = nil | |
self.previous = nil | |
} |
//Duplicate | |
func returnDuplicates(arr: [Int]) -> [Int] { | |
var dict: [Int: Bool] = [:] | |
var duplicates: [Int] = [] | |
for i in arr { | |
if dict.keys.contains(i) { | |
duplicates.append(i) | |
} else { | |
dict[i] = true | |
} |
func toLowerCase(string: String) -> String { | |
var str = string as NSString | |
for i in 0...(str.length - 1) { | |
if str.character(at: i) >= 65 && str.character(at: i) <= 90 { | |
let changeValue = str.character(at: i) + 32 | |
str = str.replacingCharacters(in: NSMakeRange(i, 1), with: String(Character(UnicodeScalar(changeValue)!))) as NSString | |
} | |
} | |
return str as String |
import Foundation | |
func allPrimeFactors(number: Int) { | |
var n = number | |
while n % 2 == 0 { | |
print("2") | |
n /= 2 | |
} | |
var i = 3 |
class Node { | |
var key : Int | |
var left : Node? | |
var right: Node? | |
init(key: Int, left: Node?, right: Node?) { | |
self.key = key | |
self.left = left | |
self.right = right |