Skip to content

Instantly share code, notes, and snippets.

Scott Hoyt scottrhoyt

Block or report user

Report or block scottrhoyt

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
scottrhoyt / HeapsAlgorithm.swift
Created Sep 20, 2017
Heap's Algorithm for permutations in Swift
View HeapsAlgorithm.swift
import Foundation
Generates all possible permutations of `data` using Heap's Algorithm
- parameters:
- data: The data to permute
- output: A closure called with each permutation of the data
scottrhoyt / JSONCodable+JSONObjects.swift
Last active Dec 15, 2019
A Swift 4 extension for JSONEncoder and JSONDecoder to enable serialization to/deserialization from JSON Objects (e.g. [String: Any])
View JSONCodable+JSONObjects.swift
import Foundation
extension JSONEncoder {
func encodeJSONObject<T: Encodable>(_ value: T, options opt: JSONSerialization.ReadingOptions = []) throws -> Any {
let data = try encode(value)
return try JSONSerialization.jsonObject(with: data, options: opt)
extension JSONDecoder {
scottrhoyt / RandomGenerator.swift
Created Sep 1, 2015
This is a Swift 2.0 conversion of Erica Sadun's RandomGenerator from here:
View RandomGenerator.swift
A Swift 2.0-compatible version of Erica Sadun's take on shuffling a
`CollectionType` available here:
import Foundation
You can’t perform that action at this time.