Skip to content

Instantly share code, notes, and snippets.

View robnadin's full-sized avatar

Rob Nadin robnadin

  • Dyson
  • Bristol, UK
  • 10:51 (UTC +01:00)
  • X @robnadin
View GitHub Profile
@robnadin
robnadin / ReadMe.txt
Created June 26, 2018 21:39 — forked from WinSe7en/ReadMe.txt
Mac Symantec Uninstall
********* RemoveSymantecMacFiles.command 7.0.49 *********
WARNING: This script will remove all files and folders created by Symantec
Mac OS X products (LiveUpdate Administration Utility files) and
any files within those folders. Therefore, you will lose ALL files
that reside in those folders, including any that you have created.
Usage: RemoveSymantecMacFiles.command [-CcdeFfghIikLlmpQqRrV] [-QQ] [-re] [volume ...]
Summary: If no option or volume is specified, then all Symantec files are
extension UIViewAnimatingState: CustomStringConvertible {
public var description: String {
switch self {
case .inactive: return "inactive"
case .active: return "active"
case .stopped: return "stopped"
}
}
}
extension UITextField {
func textRange(from range: NSRange) -> UITextRange? {
guard
let startPosition = position(from: beginningOfDocument, offset: range.location),
let endPosition = position(from: startPosition, offset: range.length) else {
return nil
}
return textField.textRange(from: startPosition, to: endPosition)
}
//
// Optional+Unwrapped.swift
//
public enum UnwrapError: Error {
case failedToUnwrap(file: StaticString, function: StaticString, line: UInt)
}
extension Optional {
protocol LayoutAnchorEdgesContainer {
var topAnchor: NSLayoutYAxisAnchor { get }
var leadingAnchor: NSLayoutXAxisAnchor { get }
var bottomAnchor: NSLayoutYAxisAnchor { get }
var trailingAnchor: NSLayoutXAxisAnchor { get }
func pinAllEdges(to view: LayoutAnchorEdgesContainer)
}
@robnadin
robnadin / CustomFontMetrics.swift
Created August 9, 2017 09:15 — forked from zwaldowski/CustomFontMetrics.swift
[WIP] UIFontMetrics Backport from iOS 11
//
// CustomFontMetrics.swift
//
// Created by Zachary Waldowski on 6/6/17.
// Licensed under MIT.
//
import UIKit
private extension UITraitCollection {
@robnadin
robnadin / SpacerView+LayoutGuide.swift
Last active February 21, 2020 11:13
Add support for custom layout guide instances in interface builder by using custom UIView subclass. Uses method swizzling to swap out the view during nib decoding.
private extension UIView {
private struct Static {
static let initialize: (AnyClass) -> Void = { (aClass: AnyClass!) in
let swizzle: (Selector, Selector) -> Void = { (original, swizzled) in
let originalSelector = original
let swizzledSelector = swizzled
let originalMethod = class_getInstanceMethod(aClass, originalSelector)
let swizzledMethod = class_getInstanceMethod(aClass, swizzledSelector)
// MARK: RawRepresentable Equality
func ==<T: Equatable, U: protocol<RawRepresentable, Equatable> where U.RawValue == T>(left: T?, right: U?) -> Bool {
return left == right?.rawValue
}
func !=<T: Equatable, U: protocol<RawRepresentable, Equatable> where U.RawValue == T>(left: T?, right: U?) -> Bool {
return left != right?.rawValue
}
@robnadin
robnadin / HashTable.swift
Created October 31, 2016 08:30
A generic wrapper for NSHashTable on Swift <= 2.3
import Foundation
#if swift(>=3.0)
typealias HashTable<ObjectType: AnyObject> = NSHashTable<ObjectType>
#else
struct HashTable<ObjectType: AnyObject> {
private let _table = NSHashTable.weakObjectsHashTable()
static func weakObjects() -> HashTable<ObjectType> {
Pod::Spec.new do |s|
s.name = 'BLEFramework'
s.version = '1.4'
s.summary = 'The Buzz Flashing Glassware framework allows you to activate your Buzz Celebration Drinkware from your mobile device.'
s.homepage = 'http://www.buzzproducts.com/flashingcup/'
s.author = { 'Buzz Products' => '[email protected]' }
s.source = { :path => 'BLEFramework' }
s.social_media_url = 'https://twitter.com/buzzproducts'
s.ios.deployment_target = '8.0'