Skip to content

Instantly share code, notes, and snippets.

View mehmetfarhan's full-sized avatar
🚀

Mohammad Farhan mehmetfarhan

🚀
View GitHub Profile
public extension Sequence {
func group<K: Hashable & Comparable>(by keyForValue: (Element) -> K) -> [[Element]] {
return Dictionary(grouping: self, by: keyForValue).sorted { $0.key < $1.key }.map { $0.value }
}
}
import AVFoundation
import UIKit
public class ScannerOverlayPreviewLayer: AVCaptureVideoPreviewLayer {
// MARK: - OverlayScannerPreviewLayer
public var cornerLength: CGFloat = 30
public var lineWidth: CGFloat = 6
import UIKit
import PlaygroundSupport
final class ViewController: UIViewController {
// Step 1
lazy private var draggableView: UIView = {
let view = UIView(frame: CGRect(origin: .zero, size: CGSize(width: 50, height: 50)))
view.backgroundColor = .red
return view
@mehmetfarhan
mehmetfarhan / RemoteConfigManager.swift
Created August 11, 2020 18:09
Firebase Remote Config
import Foundation
import Firebase
struct RemoteConfigModel {
var url: String?
var forceUpdate: String?
var version: String?
}
final class RemoteConfigManager {
@mehmetfarhan
mehmetfarhan / CaptureList.swift
Created September 25, 2020 11:18
Capture List
import UIKit
final class Increment {
// MARK: - Properties
private var number: Int = 0
// MARK: - This will cause memory leak
// lazy var incrementNumber: (Int) -> Void = { value in
@mehmetfarhan
mehmetfarhan / Destructuring.swift
Created September 25, 2020 21:42
Destructuring
import UIKit
/*
Destructuring is the practice of pulling a tuple apart into multiple values in a single assignment.
*/
// MARK: - Destructuring
extension String {
var splittedName: (String, String) {