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 PlaygroundSupport | |
typealias DispatcherIdentifier = String | |
class Dispatcher { | |
private var items = [DispatcherIdentifier: DispatchWorkItem]() | |
private let queue: DispatchQueue |
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 CryptoKit | |
extension String { | |
func hmacUsingSHA1(_ secretString: String) -> String { | |
let key = SymmetricKey(data: secretString.data(using: .utf8)!) | |
let signature = HMAC<Insecure.SHA1>.authenticationCode(for: self.data(using: .utf8)!, using: key) | |
return Data(signature).map { String(format: "%02hhx", $0) }.joined() |
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 SwiftUI | |
#if canImport(UIKit) | |
import UIKit | |
#elseif canImport(AppKit) | |
import AppKit | |
#endif | |
extension Image { | |
/// Initializes a SwiftUI `Image` from data. |
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 UIKit | |
class FourColumnsContainerViewController: UIViewController { | |
let outerSplitViewController = UISplitViewController(style: .tripleColumn) | |
let innerSplitViewController = UISplitViewController(style: .doubleColumn) | |
let primary = makeContentViewController("App") | |
let secondary = makeContentViewController("Files") | |
let mainContent = makeContentViewController("File Content") | |
let inspector = makeContentViewController("Inspector") |
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
private func getTranslationLanguage(translate: String, from originLanguage: String = "auto", to destinationLanguage: String = "en", completion: @escaping (_ result: String?) -> Void) { | |
// 1- Create the query | |
if let translatationURL: String = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=\(originLanguage)&tl=\(destinationLanguage)&dt=t&q= \(translate)&ie=UTF-8&oe=UTF-8".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed), | |
let validURL = URL(string: translatationURL) { | |
var resultSearch: String = keyword | |
// 2- Make Request | |
URLSession.shared.dataTask(with: validURL) { [weak self] data, _, error in | |
guard error == nil, let data = data else { |
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
/* | |
* Returns Array from optional NSSet. Returns empty array if NSSet is nil. | |
* It's useful for when you want an Array of objects from a Core Data many relationship. | |
* | |
* Example usage with managed object `game` with 1-to-many relationship to `Goal` entity: | |
* let goalArray = game.goals.array(of: Goal.self) | |
*/ | |
extension Optional where Wrapped == NSSet { | |
func array<T: Hashable>(of: T.Type) -> [T] { |
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
// | |
// AuthImagePickerSettings.swift | |
// | |
// Created by Marcelo Perretta on 18/05/2022. | |
// | |
import UIKit | |
import AVFoundation | |
import Photos | |
import PhotosUI |
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
// | |
// SpeechManager.swift | |
// | |
// Created by Marcelo Perretta on 22/04/2022. | |
// | |
import Foundation | |
import AVFoundation | |
// We need this because the delegate doesnt works correctly |
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
// CustomitleView | |
// | |
// Created by Marcelo Perretta on 21/04/2022. | |
// | |
import UIKit | |
class CustomTitleView: UIView { | |
private let elementsDistance: CGFloat = 5.0 | |
private let iconSize: CGFloat = 25.0 |
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
// | |
// UISearchBar+Ext.swift | |
// frazeit | |
// | |
// Created by Maysam Shahsavari on 7/30/18. | |
// Updated on 9/26/19. | |
// Copyright © 2018 Maysam Shahsavari. All rights reserved. | |
// Updated: 10/02/2020. | |
import Foundation |
NewerOlder