Skip to content

Instantly share code, notes, and snippets.

View iAmrSalman's full-sized avatar

Amr Salman iAmrSalman

View GitHub Profile
UIFont.familyNames.sorted().forEach{ familyName in
print("*** \(familyName) ***")
UIFont.fontNames(forFamilyName: familyName).forEach { fontName in
print("\(fontName)")
}
print("---------------------")
}
/*
*** Academy Engraved LET ***
@iAmrSalman
iAmrSalman / Sociable.swift
Last active April 8, 2018 09:40
[Sociable] protocol to handle social deeplinking #swift #protocol
import UIKit
import MessageUI
protocol Sociable: MFMailComposeViewControllerDelegate, UINavigationControllerDelegate {
func openInstagramAccount(withID id: String)
func openTwitterAccount(withID id: String)
func openFacebookAccount(withID id: String)
func openSnapchatAccount(withID id: String)
func sendEmail(to email: String, withDefaultMessage message: String)
func call(_ mobileNumber: String)
@iAmrSalman
iAmrSalman / timeAgoSinceDate.swift
Last active March 30, 2018 05:55
[timeAgoSinceDate] #date #swift
class func timeAgoSince(_ date: Date, from currentDate: Date = Date(), numericDates: Bool = false) -> String {
let calendar = Calendar.current
let now = currentDate
let earliest = (now as NSDate).earlierDate(date)
let latest = (earliest == now) ? date : now
let components:DateComponents = (calendar as NSCalendar).components([NSCalendar.Unit.minute , NSCalendar.Unit.hour , NSCalendar.Unit.day , NSCalendar.Unit.weekOfYear , NSCalendar.Unit.month , NSCalendar.Unit.year , NSCalendar.Unit.second], from: earliest, to: latest, options: NSCalendar.Options())
if (components.year! >= 2) {
return "\(components.year!) years ago"
} else if (components.year! >= 1){
@iAmrSalman
iAmrSalman / ContactsManager.swift
Last active May 26, 2021 21:25
[ContactsManager] fetch all contacts from Phone Contacts using Contacts framework #swift4 #contacts
import Foundation
import ContactsUI
enum ContactsFilter {
case none
case mail
case message
}
struct PhoneContact {
@iAmrSalman
iAmrSalman / PhoneNumberManager.swift
Created March 21, 2018 14:15
[PhoneNumberManager] validate and format phoneNumber using PhoneNumberKit
import Foundation
import PhoneNumberKit
enum Format {
case e164
case national
case international
}
class PhoneNumberManager {
@iAmrSalman
iAmrSalman / XLPagerTabStrip.swift
Created March 10, 2018 21:23
[XLPagerTabStrip] #swift #XLPagerTabStrip
import UIKit
import XLPagerTabStrip
class ProfileTabsVC: ButtonBarPagerTabStripViewController {
//MARK: - Life Cycle
override func viewDidLoad() {
setupPager()
super.viewDidLoad()
@iAmrSalman
iAmrSalman / NetworkManager.swift
Last active March 2, 2018 14:43
[NetwokManager] #swift4 #Alamofire #ObjectMapper
import UIKit
import Alamofire
import ObjectMapper
typealias NetworkSuccessClosure = (BaseModel?) -> Void
typealias NetworkFailureClosure = (Error?) -> Void
class NetworkManager: NSObject {
class func startRequest<T: BaseModel>(withRequestConfiguration request: RequestConfiguraton, andMappingObject objectClass: T?, successClouser success: NetworkSuccessClosure?, andFailure failure: NetworkFailureClosure?) {
@iAmrSalman
iAmrSalman / .git-commit-template.txt
Created February 22, 2018 19:03 — forked from adeekshith/.git-commit-template.txt
This commit message template that helps you write great commit messages and enforce it across your team.
# <type>: (If applied, this commit will...) <subject> (Max 50 char)
# |<---- Using a Maximum Of 50 Characters ---->|
# Explain why this change is being made
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
# Provide links or keys to any relevant tickets, articles or other resources
# Example: Github issue #23
@iAmrSalman
iAmrSalman / Reachability.swift
Created February 12, 2018 09:43
[Reachability.swift] #swift #networkimg
//
// Reachability.swift
//
// Created by Amr Salman on 4/4/17.
//
//
import Foundation
import SystemConfiguration
import UIKit
import SystemConfiguration.CaptiveNetwork
@iAmrSalman
iAmrSalman / MacPowerUser.md
Created January 26, 2018 15:13
This is my collection of Apps & Tools for macOS

Mac Power User

This is my collection of Apps & Tools for macOS

Terminal

  • Homebrew: The missing package manager for macOS
  • Homebrew-Cask: extends Homebrew and brings its elegance, simplicity, and speed to the installation and management of GUI macOS applications such as Atom and Google Chrome.
  • Mac-CLI: macOS command line tools for developers