Skip to content

Instantly share code, notes, and snippets.

🐗
it puts the rectangles on the screen

Zoë Smith zoejessica

🐗
it puts the rectangles on the screen
Block or report user

Report or block zoejessica

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
@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:

@zoejessica
zoejessica / chunk.swift
Created May 16, 2016
Chunk an array into subarrays
View chunk.swift
extension Array {
func chunk<T : Equatable>(by valueToCompare: (Element) -> T) -> [[Element]] {
var currentValue = self[0]
var startIndex = 0
var splits = [[Element]]()
for (index, value) in self.enumerate() {
if valueToCompare(value) != valueToCompare(currentValue) {
let newSplit = self[startIndex..<index]
splits.append(Array(newSplit))
startIndex = index
@zoejessica
zoejessica / Badged pin
Created Apr 24, 2015
Badged pin (eg for maps) using IB_Designable and IBInspectable
View Badged pin
#import <UIKit/UIKit.h>
IB_DESIGNABLE @interface BadgedPin : UIView
@property (nonatomic, assign) IBInspectable CGFloat badgeDiameter;
@property (nonatomic, strong) IBInspectable UIColor *badgeColor;
@property (nonatomic, assign) IBInspectable CGFloat badgeStrokeWidth;
@property (nonatomic, strong) IBInspectable UIColor *fillColor;
@property (nonatomic, strong) IBInspectable NSString *imageName;
View Export bookmarks from Evernote to pinboard
(*
http://zoesmith.io
Export Bookmarks from Evernote to Pinboard
v1.4 12th September 2012
This script takes selected notes in Evernote and sends an email for each to Pinboard, extracting each note's title, source URL and associated tags. The user should enter their Pinboard email address in the pinboardEmail property below, and can choose a default tag to add to each bookmark on import.
This code is hacky, horrible and non-error checking (but it worked for me). Don't use on thousands of notes at a time, it'll go all crashy. Try selecting one test note first to see if it works for you.
Change log:
You can’t perform that action at this time.