Skip to content

Instantly share code, notes, and snippets.

View mergesort's full-sized avatar
😱
Very busy with life matters, will do my best to reply as soon as I can

Joe Fabisevich mergesort

😱
Very busy with life matters, will do my best to reply as soon as I can
View GitHub Profile
import Foundation
public enum Platform {
case iOS
case iOSOnMac
case mac
}
public func execute(if condition: Bool, _ action: () -> Void) {
if condition {
public final class LiveActivitiesController<Model: Identifiable & Equatable & Codable, ModelActivity: ActivityAttributes & Identifiable>: ObservableObject {
var activityFromModel: (Model) -> ModelActivity
var contentStateFromModel: (Model) -> ModelActivity.ContentState
public init(activityFromModel: @escaping (Model) -> ModelActivity, contentStateFromModel: @escaping (Model) -> ModelActivity.ContentState) {
self.activityFromModel = activityFromModel
self.contentStateFromModel = contentStateFromModel
}
@mergesort
mergesort / Color+DynamicallyUpdatingUIColor.swift
Last active October 11, 2022 02:56
Color to UIColor conversion that preserves light/dark mode support for asset catalog backed colors
// Problem: Converting a Color to UIColor via the UIColor(Color) initializer does not properly respect dark/light mode.
// This becomes an issue when you have a color palette that provides different colors for dark and light mode, for example a red that's rendered darker in dark mode.
// This came up because I use asset catalogs for my apps color palettes, if you'd like to learn how to make slick SwiftUI color palettes check out: https://build.ms/2021/08/24/creating-slick-color-palette-apis
///////////////////////////
// Solution: This extension
///////////////////////////
@mergesort
mergesort / AnimationDemo.swift
Last active December 18, 2023 02:34
A SwiftUI prototype animation for adding/removing players from a game
import SwiftUI
let colors = [
Color.pink,
Color.blue,
Color.green,
Color.orange,
Color.purple,
Color.black,
]
@mergesort
mergesort / UIViewController+ChildViewController.swift
Created October 22, 2017 15:56
Making ChildViewControllers easier to deal with
import UIKit
extension UIViewController {
/// This function adds a `UIViewController` as a childViewController,
/// and calls the appropriate lifecycle methods.
///
/// - Parameter childViewController: The childViewController to add to the view.
func add(childViewController: UIViewController) {
self.addChildViewController(childViewController)
{
"id": 0,
"position_id": 0,
"user_id": 0,
"noun_list_icon_id": 3,
"private": false,
"shared": false,
"master_list": false,
"title": "Search Results",
"description": "Search results found for 'godfather' in movies.",
@mergesort
mergesort / UIViewController+ChildViewControllers.swift
Created September 7, 2017 14:58
Never remember the order for `didMoveToParentOrSomething` ever again
import UIKit
extension UIViewController {
/// This function adds a `UIViewController` as a childViewController,
/// and calls the appropriate lifecycle methods.
///
/// - Parameter childViewController: The childViewController to add to the view.
func add(childViewController: UIViewController) {
self.addChildViewController(childViewController)

Keybase proof

I hereby claim:

  • I am mergesort on github.
  • I am mergesort (https://keybase.io/mergesort) on keybase.
  • I have a public key ASBrCbe4NtxBhbKR8uhxRvW3Eti48la91J-Biph4klTPNAo

To claim this, I am signing this object:

@mergesort
mergesort / TextEffectView.swift
Created October 26, 2016 21:49
A playground for TextEffectView updated for Swift 3
//
// TextEffectView.swift
// TextEffects
//
// Created by Ben Scheirman on 2/15/16.
// Copyright © 2016 NSScreencast. All rights reserved.
//
import UIKit
import CoreText
import UIKit
public protocol Anchor {
var rawValue: Int { get }
var constant: CGFloat { get }
var priority: UILayoutPriority { get }
init(rawValue: Int, constant: CGFloat, priority: UILayoutPriority)