Skip to content

Instantly share code, notes, and snippets.

eMdOS eMdOS

Block or report user

Report or block eMdOS

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@eMdOS
eMdOS / KeyedDecodingContainer.swift
Created Mar 15, 2019
Decoding custom date formats using Decodable
View KeyedDecodingContainer.swift
extension KeyedDecodingContainer where Key: CodingKey {
func decodeDate(from key: Key, using formats: String...) throws -> Date {
let dateAsString = try decode(String.self, forKey: key)
let dateFormatter = DateFormatter()
for format in formats {
dateFormatter.dateFormat = format
guard let date = dateFormatter.date(from: dateAsString) else {
continue
}
return date
@eMdOS
eMdOS / app.md
Created Mar 12, 2019
Installing .app in iPhone simulator
View app.md

Installing .app in iPhone simulator

xcrun simctl install booted #{.app-path}

View DateFormatter+ISO8601.swift
// Swift 3
extension DateFormatter {
public static var iso8601: DateFormatter {
return DateFormatter.iso8601DateFormatter
}
private static let iso8601DateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
@eMdOS
eMdOS / gist:a5fa54a0e8be32dcd6b46b83824228e6
Created Feb 21, 2019 — forked from 480/gist:3b41f449686a089f34edb45d00672f28
MacOS X + oh my zsh + powerline fonts + visual studio code terminal settings
View gist:a5fa54a0e8be32dcd6b46b83824228e6
1. Install oh my zsh
http://ohmyz.sh/
$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
1. Install powerline fonts
https://github.com/powerline/fonts
1. download agnoster theme
https://github.com/mbadolato/iTerm2-Color-Schemes/zipball/master
@eMdOS
eMdOS / ScrollableStackView.swift
Last active Jan 5, 2019
Scrollable Stack View
View ScrollableStackView.swift
import UIKit
public class ScrollableStackView: UIView {
// MARK: Properties
private var didSetupConstraints = false
private lazy var scrollView: UIScrollView = {
let scrollView = UIScrollView(frame: .zero)
View Size Classes.md

Size Classes

(w, h)

iPad Pro 12.9"

Orientation Full Screen Split View 2/3 Split View 1/2 Split View 1/3
Portrait R, R C, R - C, R
@eMdOS
eMdOS / NibNameableView.swift
Created Nov 1, 2018
Table/Collection Views - Generic Cell Registration & Dequeuing
View NibNameableView.swift
import UIKit
public protocol NibNameableView: class {
static var nibName: String { get }
}
extension NibNameableView where Self: UIView {
public static var nibName: String {
return String(describing: self)
}
View ResultType.swift
import Foundation
public enum ResultType<Value> {
case success(Value)
case failure(Swift.Error)
}
extension ResultType {
public init(value: () throws -> Value) {
do {
@eMdOS
eMdOS / CGSize.swift
Created Jul 30, 2018
CGSize Scaling
View CGSize.swift
extension CGSize {
func widthScaling(with value: CGFloat) -> CGSize {
return CGSize(width: value, height: (value * height) / width)
}
func heightScaling(with value: CGFloat) -> CGSize {
return CGSize(width: (value * width) / height, height: value)
}
}
@eMdOS
eMdOS / DOC.md
Last active Jul 18, 2018
Localization (Protocol-Oriented Programming approach)
View DOC.md

Examples

  1. Getting the signInButton value from Common.strings file.
Strings.Common.signInButton.localized
You can’t perform that action at this time.