Skip to content

Instantly share code, notes, and snippets.

Keith Harrison kharrison

Block or report user

Report or block kharrison

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
@kharrison
kharrison / Protocol.swift
Created Jan 21, 2019
Refactoring Examples in Swift
View Protocol.swift
// Example of refactoring with protocols
// Original javascript version is from Refactoring (2nd Edition) by Martin Fowler
import Foundation
struct Play {
enum Genre {
case tragedy
case comedy
}
@kharrison
kharrison / RSSFeed.swift
Last active Dec 9, 2019
Swift Decodable With Multiple Custom Dates
View RSSFeed.swift
import Foundation
extension DateFormatter {
static let iso8601Full: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
formatter.calendar = Calendar(identifier: .iso8601)
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.locale = Locale(identifier: "en_US_POSIX")
return formatter
@kharrison
kharrison / SwiftIntegerGuide.swift
Created Feb 17, 2017
Swift Integer Quick Guide
View SwiftIntegerGuide.swift
// -------------------------------------
// Swift Integer Quick Guide
// -------------------------------------
// Created by Keith Harrison http://useyourloaf.com
// Copyright (c) 2017 Keith Harrison. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
@kharrison
kharrison / Country.swift
Last active Sep 24, 2019
Swift Hash Functions
View Country.swift
import Foundation
struct Country {
let name: String
let capital: String
var visited: Bool
}
extension Country: Equatable {
static func == (lhs: Country, rhs: Country) -> Bool {
@kharrison
kharrison / CoreDataController.h
Last active Apr 9, 2018
Objective-C wrapper for NSPersistentContainer - Easy Core Data setup with iOS 10
View CoreDataController.h
//
// CoreDataController.h
//
// Created by Keith Harrison http://useyourloaf.com
// Copyright (c) 2016 Keith Harrison. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright
@kharrison
kharrison / CoreDataController.swift
Last active Sep 12, 2019
Swift wrapper for NSPersistentContainer - Easy Core Data Setup with iOS 10
View CoreDataController.swift
//
// CoreDataController.swift
//
// Created by Keith Harrison http://useyourloaf.com
// Copyright (c) 2017 Keith Harrison. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright
@kharrison
kharrison / String.swift
Last active Mar 25, 2019
Swift String Playground Examples
View String.swift
// Swift Standard Librray - String
// Keith Harrison http://useyourloaf.com
// Import Foundation if you want to bridge to NSString
import Foundation
// ====
// Initializing a String
// ====
@kharrison
kharrison / ppc.m
Last active Aug 29, 2015
Popover Presentation Delegate
View ppc.m
// Set the popover presentation controller when prepare for segue
// The presentation style is set in the storyboard
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"SeguePopover"])
{
self.featuredPPC = segue.destinationViewController.popoverPresentationController;
self.featuredPPC.delegate = self;
}
}
View keybase.md

Keybase proof

I hereby claim:

  • I am kharrison on github.
  • I am kharrison (https://keybase.io/kharrison) on keybase.
  • I have a public key whose fingerprint is DA8F 843F AD53 60FB 293B 83FA A8A6 9ECD A775 E681

To claim this, I am signing this object:

@kharrison
kharrison / shuffle.go
Last active Aug 29, 2015
Fisher - Yates shuffle Go package
View shuffle.go
package shuffle
import (
"math/rand"
"time"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
You can’t perform that action at this time.