If .DS_Store was never added to your git repository, simply add it to your .gitignore file.
.gitignore
In your the root directory of your app and simply write
extension StringProtocol where Index == String.Index { | |
func ranges<T: StringProtocol>(of substring: T, options: String.CompareOptions = [], locale: Locale? = nil) -> [Range<Index>] { | |
var ranges: [Range<Index>] = [] | |
while let result = range(of: substring, options: options, range: (ranges.last?.upperBound ?? startIndex)..<endIndex, locale: locale) { | |
ranges.append(result) | |
} | |
return ranges | |
} | |
} |
public protocol ReusableView: class { } | |
extension ReusableView where Self: UIView { | |
public static var reuseIdentifier: String { | |
return String(describing: self) | |
} | |
} | |
extension UITableViewCell: ReusableView { } | |
extension UITableViewHeaderFooterView: ReusableView { } |
// | |
// Keychain.swift | |
// SecKeychain | |
// | |
// Created by Paul Wagener on 01-11-17. | |
// Copyright © 2017 Paul Wagener. All rights reserved. | |
// | |
import Foundation |
import Foundation | |
let size = MemoryLayout<Int16>.stride | |
let data = Data(bytes: [1, 0, 2, 0, 3, 0]) // little endian for 16-bit values | |
let int16s = data.withUnsafeBytes { (bytes: UnsafePointer<Int16>) in | |
Array(UnsafeBufferPointer(start: bytes, count: data.count / size)) | |
} | |
let length = data.count * MemoryLayout<Int16>.stride |
// | |
// Inspired by wrjpgcom of libjpeg | |
// https://github.com/libjpeg-turbo/libjpeg-turbo/blob/master/wrjpgcom.c | |
// | |
// https://stackoverflow.com/a/46045524/5536516 | |
// | |
// Note: To add an EXIF UserComment go here: | |
// https://gist.github.com/nyg/c90f36abbd30f72c8b6681ef23db886b | |
import Foundation |
import Foundation | |
extension String { | |
//Know if self is only composed by numbers | |
var isNumber: Bool { | |
return !self.isEmpty && CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: self)) | |
} | |
} | |
//Struct to check Regular Expresions |
// No Security | |
{ | |
"rules": { | |
".read": true, | |
".write": true | |
} | |
} |
// | |
// GuardURLProtocol.swift | |
// URLProtocol | |
// | |
// Created by Bruno Philipe on 16/2/17. | |
// Copyright © 2017 Bruno Philipe. All rights reserved. | |
// | |
// 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 |
extension UIImageView { | |
/// Loads image from web asynchronosly and caches it, in case you have to load url | |
/// again, it will be loaded from cache if available | |
func load(url: URL, placeholder: UIImage?, cache: URLCache? = nil) { | |
let cache = cache ?? URLCache.shared | |
let request = URLRequest(url: url) | |
if let data = cache.cachedResponse(for: request)?.data, let image = UIImage(data: data) { | |
self.image = image | |
} else { | |
self.image = placeholder |