Skip to content

Instantly share code, notes, and snippets.

View SaganRitual's full-sized avatar
:octocat:
Realizing daily I'm not a mathematician

Rob Bishop SaganRitual

:octocat:
Realizing daily I'm not a mathematician
View GitHub Profile
@SaganRitual
SaganRitual / SequenceDiff.swift
Last active March 15, 2018 00:35 — forked from sergiosette/diff5.swift
Compare two sequences, report back the common elements, plus deletes/inserts required to make the sequences match
// See how to use it at the bottom of this file
// Helper struct for sequenceDiff
public struct SequenceDiff<T1, T2> {
public let common: [(T1, T2)]
public let removed: [T1]
public let inserted: [T2]
public init(common: [(T1, T2)] = [], removed: [T1] = [], inserted: [T2] = []) {
self.common = common
self.removed = removed
@SaganRitual
SaganRitual / CoreStoreNotificationsExample.swift
Last active March 2, 2018 07:59
Working, bare-bones example of how to use CoreStore's notification mechanism
// Figuring out how CoreStore's monitor/observer mechanism works was a painful
// experience. This is a working example of how to use list object observers and
// single object observers. You'll need CoreStore, of course, to run this.
// Instantiate a Database object and call the .go() method. The reason for the
// Timers is that I wanted to make sure the code would run in asynchronous pieces,
// rather than all on one execution thread, to more-or-less simulate mouse
// clicks in a real app.
//
// https://github.com/JohnEstropia/CoreStore -- don't get me wrong, it was
// worth the pain. But with any luck this example will spare you some headaches.