Skip to content

Instantly share code, notes, and snippets.

Avatar
🐗
waffletime all the time

Zoë Smith zoejessica

🐗
waffletime all the time
View GitHub Profile
@zoejessica
zoejessica / DarwinNotificationCenter.swift
Created Apr 26, 2020 — forked from AvdLee/DarwinNotificationCenter.swift
A notification center for Darwin Notifications. MIT License applies.
View DarwinNotificationCenter.swift
//
// DarwinNotificationCenter.swift
//
// Copyright © 2017 WeTransfer. All rights reserved.
//
import Foundation
/// A Darwin notification payload. It does not contain any userInfo, a Darwin notification is purely event handling.
public struct DarwinNotification {
View Withable.swift
/// Withable is a simple protocol to make constructing
/// and modifying objects with multiple properties
/// more pleasant (functional, chainable, point-free)
public protocol Withable {
init()
}
public extension Withable {
/// Construct a new instance, setting an arbitrary subset of properties
init(with config: (inout Self) -> Void) {
@zoejessica
zoejessica / PagerView.swift
Created Dec 26, 2019 — forked from mecid/PagerView.swift
PagerView in SwiftUI
View PagerView.swift
//
// PagerView.swift
//
// Created by Majid Jabrayilov on 12/5/19.
// Copyright © 2019 Majid Jabrayilov. All rights reserved.
//
import SwiftUI
struct PagerView<Content: View>: View {
let pageCount: Int
@zoejessica
zoejessica / list-selection.swift
Created Aug 18, 2019
Showing a selection in a SwiftUI List from an observable object (not working atm!)
View list-selection.swift
class Context: ObservableObject {
init(selectedIngredients: Set<Ingredient>, ingredients: [Ingredient]) {
self.selectedIngredients = selectedIngredients
self.ingredients = ingredients
}
@Published var selectedIngredients: Set<Ingredient>
let ingredients: [Ingredient]
}
@zoejessica
zoejessica / ApproximateValuesSnapshotting.swift
Last active Mar 4, 2019
Custom diffing strategy for the pointfree.co swift-snapshot library, to compare dictionaries of named floating point values within a given percentage accuracy threshold.
View ApproximateValuesSnapshotting.swift
import Foundation
import SnapshotTesting
import XCTest
public typealias NamesToValues = [String : Double]
public func approximateValues(tolerance percentage: Double) -> SimplySnapshotting<NamesToValues> {
let diffingStrategy = Diffing.approximateValues(tolerance: percentage)
return SimplySnapshotting.init(pathExtension: "json", diffing: diffingStrategy)
}
View Mirrored user defaults
import Foundation
import CoreData
import CloudKit
// https://github.com/macmade/user-defaults/blob/master/swift/Preferences.swift
/*******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2017 Jean-David Gadina - www.xs-labs.com
@zoejessica
zoejessica / Activity.swift
Created Jul 8, 2017 — forked from zwaldowski/Activity.swift
os_activity_t for Swift 3
View Activity.swift
//
// Activity.swift
//
// Created by Zachary Waldowski on 8/21/16.
// Copyright © 2016 Zachary Waldowski. Licensed under MIT.
//
import os.activity
private final class LegacyActivityContext {
@zoejessica
zoejessica / multilinelabelnode.swift
Created Apr 29, 2017
Multiline SKLabelNode in Swift 3
View multilinelabelnode.swift
// from https://oleb.net/blog/2016/08/swift-3-strings/
extension String {
func wrapped(after: Int) -> [String] {
var i = 0
let lines = self.characters.split(omittingEmptySubsequences: false) { character in
switch character {
case "\n",
" " where i >= after:
i = 0
@zoejessica
zoejessica / multilinelabelnode.swift
Created Apr 29, 2017
Multiline SKLabelNode in Swift 3
View multilinelabelnode.swift
// from https://oleb.net/blog/2016/08/swift-3-strings/
extension String {
func wrapped(after: Int) -> [String] {
var i = 0
let lines = self.characters.split(omittingEmptySubsequences: false) { character in
switch character {
case "\n",
" " where i >= after:
i = 0
View keybase.md

Keybase proof

I hereby claim:

  • I am zoejessica on github.
  • I am zoejessica (https://keybase.io/zoejessica) on keybase.
  • I have a public key whose fingerprint is FB40 ACD5 4224 8770 4470 6C39 035A F65B 02C1 4E6B

To claim this, I am signing this object: