This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UserDefaultsManager.swift | |
// Www.ADKATech.com | |
// | |
// Created by AmrAngry on 7/30/19. | |
// Modifyed by AmrAngry on 5/5/20. | |
// Copyright © 2019 Www.ADKATech.com. All rights reserved. | |
// Generic use original mestion by (FB)محمود زكى and hamada147(Github) | |
import Foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
public extension UICollectionView { | |
/** | |
Register nibs faster by passing the type - if for some reason the `identifier` is different then it can be passed | |
- Parameter type: UICollectionView.Type | |
- Parameter identifier: String? | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var shouldLogTextAnalyzer = false | |
if ProcessInfo.processInfo.environment["text_analyzer_log"] == "verbose" { | |
shouldLogTextAnalyzer = true | |
} | |
if shouldLogTextAnalyzer { | |
/// Actual logger code | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
struct ViewStyle<T> { | |
let style: (T) -> Void | |
} | |
let filled = ViewStyle<UIButton> { | |
$0.setTitleColor(.white, for: .normal) | |
$0.backgroundColor = .red |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MIT License | |
// Copyright (c) 2018 Boris Polania | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Swift 4 | |
// Check out the history for contributions and acknowledgements. | |
extension String { | |
/// Returns a new string made by replacing all HTML character entity references with the corresponding character. | |
/// | |
/// - Returns: decoded string | |
func decodingHTMLEntities() -> String { | |
var result = String() | |
var position = startIndex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
/* | |
Truncates the string to the specified length number of characters and appends an optional trailing string if longer. | |
- Parameter length: Desired maximum lengths of a string | |
- Parameter trailing: A 'String' that will be appended after the truncation. | |
- Returns: 'String' object. | |
*/ | |
func trunc(length: Int, trailing: String = "…") -> String { | |
return (self.count > length) ? self.prefix(length) + trailing : self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: A UIKit based Playground to present user interface | |
import UIKit | |
import PlaygroundSupport | |
protocol Traceable { | |
var cornerRadius: CGFloat { get set } | |
var borderColor: UIColor? { get set } | |
var borderWidth: CGFloat { get set } | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DataTask.swift | |
// | |
// | |
// Created by Amr AlGhadban on 2/15/17. | |
// Copyright © 2017 Amr AlGhadban. All rights reserved. | |
// | |
import Foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// credit to @eirnym, adapted this from their OBJC code: https://gist.github.com/eirnym/c9526a045556e4d8464b41a367843e3c | |
// generates a random date and time in the past, limited by daysBack (a number of days before today) | |
// also generates a random time to go with that date. | |
// original request: http://stackoverflow.com/questions/10092468/how-do-you-generate-a-random-date-in-objective-c | |
func generateRandomDate(daysBack: Int)-> Date?{ | |
let day = arc4random_uniform(UInt32(daysBack))+1 |
NewerOlder