Skip to content

Instantly share code, notes, and snippets.

View ranmyfriend's full-sized avatar
🦆
Calm

Ranjith ranmyfriend

🦆
Calm
View GitHub Profile
@ranmyfriend
ranmyfriend / Count lines of code in Xcode project
Created March 14, 2021 06:23 — forked from Tokuriku/Count lines of code in Xcode project
Count lines of code in SWIFT Xcode project
1. Open Terminal
2. cd to your Xcode project
3. Execute the following when inside your target project:
find . -name "*.swift" -print0 | xargs -0 wc -l
extension UIView {
var leftAnchor: NSLayoutXAxisAnchor {
return iOS11NAbove ? safeAreaLayoutGuide.leftAnchor : self.leftAnchor
}
var rightAnchor: NSLayoutXAxisAnchor {
return iOS11NAbove ? safeAreaLayoutGuide.rightAnchor : self.rightAnchor
}
var topAnchor: NSLayoutYAxisAnchor {
return iOS11NAbove ? safeAreaLayoutGuide.topAnchor : self.topAnchor
target 'Thrift' || 'ThriftConnection'
do pods end
def pods
pod 'Synchronized', '~> 4.0'
pod 'SwiftyBeaver'
pod 'BlueSSLService'
end
@ranmyfriend
ranmyfriend / 3rdPartyTools.txt
Created February 13, 2019 06:21
3rd Party Dependency Tool commands
3rd Party Dependency Tool commands
Cocoapod:
1)Pod initialization
Command: pod init
2)Pod installation or updation
Command: pod install or pod update
Carthage:
1)Carthage initialization
//Using C function in Swift
var numbers = [50,4,13,2,1]
func quickSort(input: inout [Int]) {
qsort(&input, input.count, MemoryLayout<Int>.size) { (l,r) -> Int32 in
if let left = l?.assumingMemoryBound(to: Int.self),
let right = r?.assumingMemoryBound(to: Int.self) {
if left.pointee < right.pointee {
return -1
}else if left.pointee == right.pointee {
@ranmyfriend
ranmyfriend / TinyResult.swift
Created August 29, 2018 11:38 — forked from brennanMKE/TinyResult.swift
Tiny Result type in Swift
// Credit: Hooman Mehr via swift-evolution
// https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20171113/041314.html
import Foundation
public enum Result<Value> {
case success(Value)
case failure(Error)
public init(_ value: Value) { self = .success(value) }
Refer: https://stackoverflow.com/questions/34230191/added-pod-files-and-pushed-how-to-undo-how-to-use-gitignore-in-xcode-github/34239746
That's correct, you need to add the Pods directory to your .gitignore
1) Remove your files from your github repository:
git rm -r Pods/
and don't forget to commit and push
extension DateFormatter {
class func formatter(dateFormat: String = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
timeZone: TimeZone? = TimeZone(abbreviation: "UTC")) -> DateFormatter? {
if let timeZone = timeZone {
return self.init(dateFormat: dateFormat, timeZone: timeZone)
}
return nil
}
convenience init(dateFormat: String, timeZone: TimeZone) {
self.init()
@ranmyfriend
ranmyfriend / MyError.swift
Last active June 1, 2018 09:47
This MyError Helper can help us to build a concrete Errors in Swift
/* Error Handling in Swift*/
struct MyError: Error {
private let possibleErrors: [Int:String] = {
return [
200: "Success",
403: "Forbidden",
404: "Not Found",
500: "Internal Server Error",
-999: "Make use of this Error code with your own usage"]
import Foundation
import UIKit
struct StoryboardIdentifiers {
static let ViewController1 = "ViewController1"
static let ViewController2 = "ViewController2"
static let ViewController3 = "ViewController3"
static let ViewController4 = "ViewController4"
static let ViewController5 = "ViewController5"
static let ViewController6 = "ViewController6"