Skip to content

Instantly share code, notes, and snippets.

View joshuadutton's full-sized avatar

Joshua Dutton joshuadutton

  • Tesseract Collective
  • Provo, UT
  • 11:35 (UTC -12:00)
View GitHub Profile
@joshuadutton
joshuadutton / summary-of-coronavirus-why-you-must-act-now.md
Last active March 12, 2020 17:59
Summary of Coronavirus: Why You Must Act Now
@joshuadutton
joshuadutton / NSFetchRequest+Extensions.swift
Created April 15, 2016 15:23
Functional Core Data in Swift
import Foundation
import CoreData
extension NSFetchRequest {
func withPredicate(format: String, arguments: [AnyObject]? = nil) -> NSFetchRequest {
return withPredicate(NSPredicate(format: format, argumentArray: arguments))
}
func andPredicate(format: String, arguments: [AnyObject]? = nil) -> NSFetchRequest {
import Foundation
enum NSDataError: ErrorType {
case OutOfBounds(data: NSData)
case InvalidASCIIString(data: NSData)
case ValueDoesNotMatchEnum(value: UInt8, type: Any)
}
// MARK: - NSData CollectionType conformance
extension NSData: CollectionType {
@joshuadutton
joshuadutton / UIColor+Extensions.swift
Last active March 25, 2016 15:42
UIColor Hex Value Extensions
import UIKit
extension UIColor {
static func colorWithHexValue(hexValue: UInt32, alpha: CGFloat) -> UIColor {
let red = CGFloat((hexValue & 0xFF0000) >> 16)
let green = CGFloat((hexValue & 0x00FF00) >> 8)
let blue = CGFloat((hexValue & 0x0000FF))
return UIColor(red: red/255.0, green: green/255.0, blue: blue/255.0, alpha: alpha)
}
@joshuadutton
joshuadutton / CollectionViewCellConfigurable.swift
Last active February 15, 2022 10:52
Generic Collection View and Table View data sources in Swift
import UIKit
protocol CollectionViewCellConfigurable {
typealias ItemType
typealias CellType: UICollectionViewCell
static func reuseIdentifierForIndexPath(indexPath: NSIndexPath) -> String
static func configureCellAtIndexPath(indexPath: NSIndexPath, item: ItemType, cell: CellType)
}