Skip to content

Instantly share code, notes, and snippets.

View embassem's full-sized avatar
🎯
Focusing

Bassem Tourky embassem

🎯
Focusing
View GitHub Profile
@durul
durul / Xcode 26 Defaults.md
Last active November 21, 2025 16:14
Xcode Defaults

Xcode Defaults

Command Line

# Enable internal menu
defaults write com.apple.dt.Xcode ShowDVTDebugMenu -bool YES

# Enable project build time
@malcolmkmd
malcolmkmd / UIView+Anchors.swift
Created July 10, 2017 11:16
UIView Extensions
import Foundation
import UIKit
extension UIView {
func addConstraintsWithFormat(_ format: String, views: UIView...) {
var viewsDictionary = [String: UIView]()
for (index, view) in views.enumerated() {
let key = "v\(index)"
@Gujci
Gujci / CustomTextField.swift
Last active November 16, 2022 17:42
Simple snippet how to disable actions in a UITextField
import UIKit
@IBDesignable
class CustomTextField: UITextField {
@IBInspectable var isPasteEnabled: Bool = true
@IBInspectable var isSelectEnabled: Bool = true
@IBInspectable var isSelectAllEnabled: Bool = true
@Sorix
Sorix / AsynchronousOperation.swift
Last active May 22, 2024 07:15
Subclass of NSOperation (Operation) to make it asynchronous in Swift 3, 4, 5
// Created by Vasily Ulianov on 09.02.17, updated in 2019.
// License: MIT
import Foundation
/// Subclass of `Operation` that adds support of asynchronous operations.
/// 1. Call `super.main()` when override `main` method.
/// 2. When operation is finished or cancelled set `state = .finished` or `finish()`
open class AsynchronousOperation: Operation {
public override var isAsynchronous: Bool {
@iAviatorJose
iAviatorJose / RoundedSection.swift
Last active July 20, 2022 03:25
Create Rounded Sections in UITableView
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
if (cell.respondsToSelector(Selector("tintColor"))){
if (tableView == self.tvUserDetails) {
let cornerRadius : CGFloat = 12.0
cell.backgroundColor = UIColor.clearColor()
let layer: CAShapeLayer = CAShapeLayer()
let pathRef:CGMutablePathRef = CGPathCreateMutable()
let bounds: CGRect = CGRectInset(cell.bounds, 5, 0)
var addLine: Bool = false
@wojteklu
wojteklu / clean_code.md
Last active April 20, 2026 07:59
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@barbietunnie
barbietunnie / modal-view.md
Last active April 20, 2026 09:07
Swift Modal View Controller with transparent background

You can do it like this:

In your main view controller:

func showModal() {
    let modalViewController = ModalViewController()
    modalViewController.modalPresentationStyle = .OverCurrentContext
    presentViewController(modalViewController, animated: true, completion: nil)
}
/** Throttle wraps a block with throttling logic, guarantueeing that the block will never be called (by enquueing
asynchronously on `queue`) more than once each `interval` seconds. If the wrapper callback is called more than once
in an interval, it will use the most recent call's parameters when eventually calling the wrapped block (after `interval`
has elapsed since the last call to the wrapped function) - i.e. calls are not queued and may get 'lost' by being superseded
by a newer call. */
public func throttle<P>(interval: TimeInterval, queue: DispatchQueue, _ block: ((P) -> ())) -> ((P) -> ()) {
var lastExecutionTime: TimeInterval? = nil
var scheduledExecutionParameters: P? = nil
let mutex = Mutex()
@kos9kus
kos9kus / NSURLErrorDomain.h
Last active December 11, 2025 09:40
URL Loading System Error Codes
These values are returned as the error code property of an NSError object with the domain “NSURLErrorDomain”.
Declaration
SWIFT
var NSURLErrorUnknown: Int { get }
var NSURLErrorCancelled: Int { get }
var NSURLErrorBadURL: Int { get }
var NSURLErrorTimedOut: Int { get }
var NSURLErrorUnsupportedURL: Int { get }
var NSURLErrorCannotFindHost: Int { get }