Skip to content

Instantly share code, notes, and snippets.

View jeffreybergier's full-sized avatar

Jeffrey Bergier jeffreybergier

View GitHub Profile
//
//
// SwiftUI.List appears to iterate all the way including the endIndex
// which causes a crash. LazyVStack and ForEach do not do have this issue
//
// Refer to other GIST where there is no backing storage for the custom collection
// https://gist.github.com/jeffreybergier/0a366e173a871c1a8f3828824dbf7a54
//
import SwiftUI
@jeffreybergier
jeffreybergier / BoomApp.swift
Last active January 22, 2021 00:06
SwiftUI ObservableCollection Crash
//
//
// SwiftUI.List appears to iterate all the way including the endIndex
// which causes a crash. LazyVStack and ForEach do not do have this issue
//
//
import SwiftUI
@main
@jeffreybergier
jeffreybergier / TransparentEmojiAttributedString.swift
Last active August 1, 2017 21:37
Semi-transparent Emoji in NSAttributedString Workaround
import UIKit
extension NSAttributedString {
var image: UIImage {
let options: NSStringDrawingOptions = [ .usesLineFragmentOrigin, .usesFontLeading, .usesDeviceMetrics ]
let rect = boundingRect(with: self.size(), options: options, context: nil)
return UIGraphicsImageRenderer(bounds: rect).image { _ in
draw(at: .zero)
}
}
enum Direction {
case right, left, up, down
}
func traverseClockwise(_ input: [[String]]) -> [String] {
// used to calculate how long the output needs to be
let countY = input.count
let countX = input.first?.count ?? 0
"use strict";
//
//
// // This file should be multiple files
// // But because multiple JS files take multiple round trips
// // Putting it in one for now
//
//
// I've tried several combos
// I'll list each one and the error it gives
// #1 Playground execution failed: error: Untitled Page 2.xcplaygroundpage:4:24: error: cannot specialize non-generic type 'MyWeirdDictionaryDelegate'
protocol MyWeirdDictionaryDelegate: class {
associatedtype K
func willSet(value: K, forKey key: String) -> K?
func willReturn(value: K?, forKey: String) -> K?
}
class MyWeirdDictionary<T> {
//
// Remindable.swift
// WaterMe
//
// Created by Jeffrey Bergier on 5/7/16.
//
// Copyright (c) 2015 Jeffrey Bergier
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@jeffreybergier
jeffreybergier / JSBPurchaseManager.swift
Created December 13, 2015 21:22
A simple Completion Handler based Purchase Manager class for StoreKit written in Swift
//
// PurchaseManager.swift
// GratuitousSwift
//
// Created by Jeffrey Bergier on 9/30/15.
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is