Skip to content

Instantly share code, notes, and snippets.

Avatar

Joshua Sullivan JoshuaSullivan

View GitHub Profile
@JoshuaSullivan
JoshuaSullivan / DataParser.swift
Last active Nov 21, 2020
A helper for translating Advent of Code puzzle input into usable values.
View DataParser.swift
import Foundation
/// A type that can be initialized from a string value.
///
public protocol StringInitable {
/// Initialize the object with a string.
///
/// - Note: This operation can fail if the string is not valid for this object type.
///
init?(_ string: String)
@JoshuaSullivan
JoshuaSullivan / ColorCubeImageCreator-swift2.swift
Last active Nov 11, 2020
The Color Cube Image Creator creates the specially formatted images needed to create data for the CIColorCube filter.
View ColorCubeImageCreator-swift2.swift
//
// ColorCubeImageCreator.swift
// ColorCubeImageCreator
//
// Created by Joshua Sullivan on 4/25/16.
// Copyright © 2016 Joshua Sullivan. All rights reserved.
//
import UIKit
@JoshuaSullivan
JoshuaSullivan / ColorAbsoluteDifference.txt
Created Oct 11, 2020
Enumerations of the 3 new CoreImage Filters in iOS 14.0
View ColorAbsoluteDifference.txt
=========================
Color Absolute Difference
=========================
[Availability]
iOS: 14
macOS: 11.0
[Categories]
Color Adjustment, Video, Interlaced, Non-Square Pixels, Still Image, Built-In
@JoshuaSullivan
JoshuaSullivan / CoreImageFilterEnumeration.swift
Created Oct 11, 2020
A Swift Playground that will enumerate the properties of all of the CoreImage filters.
View CoreImageFilterEnumeration.swift
import Foundation
import CoreImage
struct FilterInput {
struct ValueRange {
let minValue: Float
let maxValue: Float
let sliderMin: Float?
let sliderMax: Float?
@JoshuaSullivan
JoshuaSullivan / core-image-filters-ios-13.md
Last active Sep 24, 2020
An enumeration of iOS 13 Core Image filters.
View core-image-filters-ios-13.md

Core Image Filters

iOS 13 has 218 filters.

New Filters in iOS 13

  • CIDocumentEnhancer
  • CIGaborGradients
  • CIKeystoneCorrectionCombined
  • CIKeystoneCorrectionHorizontal
  • CIKeystoneCorrectionVertical
@JoshuaSullivan
JoshuaSullivan / CapturedImageSampler.swift
Created Oct 1, 2017
The source code for an object that helps you sample RGB values from ARFrames.
View CapturedImageSampler.swift
//
// CapturedImageSampler.swift
// ARKitTest
//
// Created by Joshua Sullivan on 9/22/17.
// Copyright © 2017 Joshua Sullivan. All rights reserved.
//
import UIKit
import ARKit
@JoshuaSullivan
JoshuaSullivan / EnumExample.swift
Last active Apr 8, 2020
Don't use Swift enums to box magic strings! Read the blog post: http://www.chibicode.org/?p=16
View EnumExample.swift
enum NotificationNames: String {
case UserDataChanged: "UserDataChangedNotificationName"
case ReceivedAlert: "ReceivedAlertNotificationName"
case PeanutButterJellyTime: "ItsPeanutButterJellyTimeNotificationName"
}
@JoshuaSullivan
JoshuaSullivan / synonym-search.swift
Created Mar 30, 2020
Uses the NaturalLanguage framework combined with a thesaurus API to replace adjectives in a sentence with synonyms. This is designed to be run in a Swift Playground.
View synonym-search.swift
import UIKit
import NaturalLanguage
import PlaygroundSupport
//: Your secret API key from `https://dictionaryapi.com` goes here.
//: THIS WON'T WORK UNLESS YOU GET A KEY.
let thesaurusKey = ""
//: The string you want to work on.
var testString = "The bright sun set behind the green hills. Thin clouds streaked the red sky."
@JoshuaSullivan
JoshuaSullivan / swift4-kvo-playground.swift
Created May 11, 2018
Here is a playground demonstrating how to set up Swift 4 KVO.
View swift4-kvo-playground.swift
//: # Setting up Swift 4 KVO
import Foundation
//: This class has a pair of properties that can be observied by KVO.
//: - Note: This class *must* inheret from `NSObject` in order to posess the KVO functionality.
class ObservableClass: NSObject {
/// An observable string property. Note that it most be annotated with both "@objc" (expose the property to the
/// Objective-C runtime) and "dynamic" (enables KVO for the property).
@objc dynamic private(set) var stringProperty: String = "Starting string!"
@JoshuaSullivan
JoshuaSullivan / ColorCubeHelper-swift2.swift
Last active Dec 12, 2019
Here are the Swift 2.3 and Swift 3.0 versions of the ColorCubeHelper class.
View ColorCubeHelper-swift2.swift
//
// ColorCubeHelper.swift
//
// Created by Joshua Sullivan on 10/01/16.
// Copyright © 2016 Joshua Sullivan. All rights reserved.
//
import UIKit
import Accelerate
You can’t perform that action at this time.