Skip to content

Instantly share code, notes, and snippets.

View shaps80's full-sized avatar
🏠
Working from home

Shaps shaps80

🏠
Working from home
View GitHub Profile
import UIKit
/// Protocol to be extended with implementations
protocol UIViewLoading {}
/// Extend UIView to declare that it includes nib loading functionality
extension UIView : UIViewLoading {}
/// Protocol implementation
extension UIViewLoading where Self : UIView {
@shaps80
shaps80 / ReusableView.swift
Last active June 18, 2019 18:08
A generic cell provider implementation in Swift
//
// ReusableView.swift
// Pods
//
// Created by Shahpour Benkau on 27/02/2017.
//
//
import UIKit
/*
Copyright (C) 2016 Apple Inc. All Rights Reserved.
See LICENSE.txt for this sample’s licensing information
Abstract:
Provides a generic implementation of testing a value for value semantics.
*/
import XCTest
@shaps80
shaps80 / Color.swift
Last active December 25, 2019 04:06
A Swift color value-type. Includes hexadecimal values support, ExpressibleByString, Swift 4 Codable and other conveniences.
/*
Copyright © 01/10/2016 Shaps
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@shaps80
shaps80 / Xcode Shortcuts.md
Last active November 2, 2023 05:13
A collection of Xcode shortcuts I use often.

Open/Close Xcode console: cmd+shift+y

Jump to definition, but in the assistant editor: cmd+opt+click

Open/close navigators pane: cmd+0

Open/close inspectors pane:

// 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")
@shaps80
shaps80 / DemoViewController.swift
Last active June 19, 2018 21:50
A simple workspace builder using simple UIStackView's and a clean DSL for describing the layout.
//
// ViewController.swift
// Workspace
//
// Created by Shaps Benkau on 12/27/2016.
// Copyright (c) 2016 Snippex Ltd. All rights reserved.
//
import UIKit
@shaps80
shaps80 / cURL+Request.swift
Last active December 23, 2023 17:43
Generates a cURL command representation of a URLRequest in Swift.
import Foundation
extension URLRequest {
/**
Returns a cURL command representation of this URL request.
*/
public var curlString: String {
guard let url = url else { return "" }
var baseCommand = #"curl "\#(url.absoluteString)""#
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.698053 0.73105 0.720167 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>OperatorMono-Book - 13.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0.847059 0.847059 0.376471 1</string>
@shaps80
shaps80 / 1. Xcode-Theme.dvtcolortheme
Last active February 28, 2017 07:40
My personal Xcode theme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.698053 0.73105 0.720167 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>OperatorMono-Book - 13.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0.847059 0.847059 0.376471 1</string>