Skip to content

Instantly share code, notes, and snippets.

@djk12587
djk12587 / AccessTokenVerification.swift
Last active September 17, 2022 15:16
PopNetworking - Reauthentication (Deprecated)
import Foundation
import PopNetworking
public enum ReauthorizationMethod {
/// Your access token is invalid and needs to be refreshed. Once reauthorization is complete your request will be retried
case refreshAuthorization
/// Your access token is valid, retry the request
case retryRequest
@djk12587
djk12587 / UIStackView+UpdateArrangedSubviews.swift
Last active March 7, 2023 15:53
Swift: UIStackView arrangedSubview update helper. (Helpful for stackViews embedded in a UITableViewCell/UICollectionViewCell)
import UIKit
extension UIStackView {
/**
Removes or adds views to a stackview. This is usefull if you have a stackview within a tableviewcell or collectionviewcell
- Parameters:
- desiredCount: The new total count of `ViewType`
- viewType: Your custom view type
Becareful using this if all of the stackview's arranged subviews are not of the same type! The returned array could be missing views & your datasource index might not match up resulting in an index out of bounds crash.
~~~
@djk12587
djk12587 / WeakCollection.swift
Last active December 6, 2023 11:41
Swift: Array containing weak references
import Foundation
/**
Creates an array of weak reference objects.
- Important:
Because this is an array of weak objects, the objects in the array can be removed at any time.
The collection itself will handle removing nil objects (garbage collection) via the private function cleanUpNilContainers()
*/
@djk12587
djk12587 / CappedCollection.swift
Last active May 19, 2020 22:46
Swift: Collection with a cap limit (if new items are added at while count == the cap limit, the oldest item will be popped off)
//
// CappedCollection.swift
// UprightWatchApp Extension
//
// Created by Dan_Koza on 11/29/18.
// Copyright © 2018 DanielKoza. All rights reserved.
//
import Foundation
@djk12587
djk12587 / gist
Created January 17, 2012 05:13
plan info
[
{
"_id" : "4f14f8728b53227696000001",
"body" : "Hey 6pm PT",
"intent" : 2,
"privacy" : 1,
"metoos_count" : 0,
"checked_in": false,
"checkins_count" : 0,
"tagged_users_count" : 0,