Skip to content

Instantly share code, notes, and snippets.

Working from home

Ahmed Hamdy dimohamdy

Working from home
View GitHub Profile
bocato / CoordinatorExtended.swift
Last active May 19, 2020
An extended implementation of the Coordinator pattern.
View CoordinatorExtended.swift
import UIKit
/// An enum that defines an output to be passed on from
/// a child to it's parents over the responders Chain
public protocol CoordinatorOutput {}
/// An enum that defines an input to be passed on from
/// the parent to it's children
public protocol CoordinatorInput {}
bocato / CacheService.swift
Last active Nov 13, 2019
Simple Cache Service implementation
View CacheService.swift
import Foundation
/// Defines the CacheService errors
/// - encryptionFailed: the key encription has failed
/// - couldNotSaveData: the data could not be saved
/// - couldNotLoadData: the data could not be loaded
/// - raw: some system error, not previously defined
public enum CacheServiceError: Error {
case encryptionFailed
View HTTPBasicAuthenticationSessionTaskDelegate.swift
Everyone on Stack Overflow does HTTP Basic Authentication on iOS by manually
building the HTTP headers.
This amounts to re-implementing HTTP.
Why? The Cocoa Touch URL Loading System aleady knows HTTP, and you can
configure your URLSession to supply HTTP Basic Authentication credentials
like so.
ollieatkinson / HTTPStatusCode.swift
Last active Oct 8, 2020
HTTP status codes as a Swift enum.
View HTTPStatusCode.swift
/// This is a list of Hypertext Transfer Protocol (HTTP) response status codes.
/// It includes codes from IETF internet standards, other IETF RFCs, other specifications, and some additional commonly used codes.
/// The first digit of the status code specifies one of five classes of response; an HTTP client must recognise these five classes at a minimum.
enum HTTPStatusCode: Int, Error {
/// The response class representation of status codes, these get grouped by their first digit.
enum ResponseType {
/// - informational: This class of status code indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty line.
case informational
Bhavdip /
Created Oct 6, 2016
Modify Sketch to never ending trial

###Sketch trial non stop

Open hosts files:

$ open /private/etc/hosts

Edit the file adding:
bittz / QuadPageControl.swift
Last active Sep 25, 2020
UIPageControl with square dots having custom size (hack).
View QuadPageControl.swift
import UIKit
class QuadPageControl: UIPageControl {
override func layoutSubviews() {
guard !subviews.isEmpty else { return }
let spacing: CGFloat = 3
arnoappenzeller / appbuilders_2016_slides
Last active May 11, 2016
Link to all slides from App Builders 2016 (On going)
View appbuilders_2016_slides ("SourceKit and you" by @jpsim) ("Non-technical ways to be a better developer" by @icanzlib) ("Refactoring Wunderlist for Android" by @CesarValiente) ("Being a developer after 40" Medium Post: by @akosma) ("Error Handling" by @nst021) ("Upgrading approaches to the secure mobile architecture" by @vixental) ("Dynamic, native, backend-driven UIs" by @johnsundell)
dougdiego / MigrateDefaults.swift
Last active Sep 19, 2020
Migrate NSUserDefaults to App Groups - Swift
View MigrateDefaults.swift
func migrateUserDefaultsToAppGroups() {
// User Defaults - Old
let userDefaults = NSUserDefaults.standardUserDefaults()
// App Groups Default - New
let groupDefaults = NSUserDefaults(suiteName: "group.myGroup")
// Key to track if we migrated
let didMigrateToAppGroups = "DidMigrateToAppGroups"
sohayb / ArrayDeepCopy.swift
Last active Jun 21, 2020
Array deep copy in Swift
View ArrayDeepCopy.swift
//Protocal that copyable class should conform
protocol Copying {
init(original: Self)
//Concrete class extension
extension Copying {
func copy() -> Self {
return Self.init(original: self)
thebrankoo / TBAsyncOperation.swift
Last active Jun 14, 2016
Simple custom NSOperation subclass that handles piece of work with completion block
View TBAsyncOperation.swift
import UIKit
typealias TBAsyncBlock = (completionHandler: dispatch_block_t ) -> Void
class TBAsyncOperation: NSOperation {
private var block : TBAsyncBlock!
private var _executing : Bool = false
override var executing : Bool {
You can’t perform that action at this time.