Skip to content

Instantly share code, notes, and snippets.

View mackoj's full-sized avatar
🤓
Neerding & Parenting

Jeffrey Macko mackoj

🤓
Neerding & Parenting
View GitHub Profile
@mackoj
mackoj / FaceRemover.swift
Last active July 24, 2017 23:46
Simple to test to Pixellate face using CoreImage
//
// ViewController.swift
// localreporter
//
// Created by Jeffrey Macko on 15/07/2017.
// Copyright © 2017 Jeffrey Macko. All rights reserved.
//
import UIKit
@mackoj
mackoj / SDKExterneEtAPITierces.md
Last active June 19, 2023 13:48 — forked from icPJmobile/iOS-SDKExterneEtAPITierces.md
Lister ce à quoi les SDK externes et API tierces doivent se conformer avant d'être intégrés dans l'application iOS PagesJaunes. Le but est de ne pas limiter l'évolution de l'application si, par hasard, un SDK était mal conçu.

SDK Externe et API Tierces

Objectif : Lister ce à quoi les SDK externes et API tierces doivent se conformer avant d'être intégrés dans l'application iOS. Le but est de ne pas limiter l'évolution de l'application si, par hasard, un SDK était mal conçu.

Veuillez forker ce gist et mettre un ✅ devant ce que vous faites. Renvoyez nous son lien par mail avec l'explication de ce que vous ne faites pas et pourquoi ? 🙂

Besoin

  • On doit pouvoir influer sur les évolutions possibles du SDK afin qu'il puisse évoluer avec nous si besoin.
  • On doit avoir un contact technique direct (et non pas un quelqu'un du support commercial 😉). Cette personne doit avoir la possibilité d'influer sur l'évolution du SDK et nous renseigner techniquement dans un délais acceptable.
import UIKit
import Foundation
struct AllocDeallocTester {
struct AllocationResult : CustomDebugStringConvertible {
let className : String
var pointerNumber : Int = 0
var numberOfMissDealloc : Int = 0
var numberOfValidDealloc : Int = 0
@mackoj
mackoj / Font+Autoregistering.swift
Last active June 11, 2024 07:19
This simplifies the process of loading custom fonts that are resources in an iOS Apple SPM Package (Swift Package Manager).
import Foundation
import UIKit
public typealias FontNameExt = (name: String, ext: String)
public func autoRegisteringFont(_ fontNames: [FontNameExt], _ spmBundleName : String) throws {
guard let spmBundle = Bundle(bundleName: spmBundleName) else {
throw("Fail to find bundle(\(spmBundleName).bundle) in your app bundle.")
}
try fontURLs(for: fontNames, in: spmBundle).forEach { try registerFont(from: $0) }
@mackoj
mackoj / diagnose-api-breaking-changes.sh
Created April 28, 2022 08:31
This script test if there is breakage in API
#!/usr/bin/env bash
# Get the last tag and test
swift package diagnose-api-breaking-changes $(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`)
@mackoj
mackoj / DiffStatePropertyWrapper.swift
Last active May 19, 2022 12:11
This tool help to make diff on a state when using a TCA app
import Foundation
import CustomDump
@propertyWrapper
public struct Diff<Value: Equatable>: Equatable {
public static func == (lhs: Diff<Value>, rhs: Diff<Value>) -> Bool {
lhs.value == rhs.value
}
private var value: Value
@mackoj
mackoj / RandomAccessCollection+Duplicates.swift
Last active May 19, 2022 14:11
Extract duplicates from a RandomAccessCollection, Array, IndentifiedArray, etc...
import Foundation
extension RandomAccessCollection {
/// Extract duplicates from a RandomAccessCollection
///
/// ```swift
/// let data = [User("jerem", amount: 567), User("jeff", amount: 124), User("jeff", amount: 567)]
/// let duplicateName = data.duplicates(\.name)
/// // duplicateName = [User("jeff", amount: 124), User("jeff", amount: 567)]
/// let duplicateAmount = data.duplicates(\.amount)
@mackoj
mackoj / BytesFormatter.swift
Last active May 19, 2022 14:09
Get size of a struct
import Foundation
/*
print("💾 AddCustomParamsState size: \(bytesFormater(bytes: MemoryLayout<AddCustomParamsState>.size))")
*/
public func bytesFormater(bytes: Int) -> String {
let bf = ByteCountFormatter()
bf.allowedUnits = .useBytes
bf.countStyle = .memory
@mackoj
mackoj / Bundle+decode.swift
Created May 19, 2022 14:08
Decode file from bundle
import Foundation
extension Bundle {
func decode<Output: Decodable>(
_ type: Output.Type,
filename: String,
withExtension ext: String,
decoder: any TopLevelDecoder = JSONDecoder()
) throw -> Output {
guard let fileURL = url(forResource: filename, withExtension: ext) else {
@mackoj
mackoj / MockCodable.swift
Created June 3, 2022 20:59
This PropertyWrapper allow you to force a value when decoding a property
import Foundation
/// This allow to force a default value when using codable
/// This will force `isEditMode` to always have `false` when decoding it
/// @MockCodable(defaultValue: false) public var isEditMode: Bool = true
@propertyWrapper
public struct MockCodable<Value> {
private var value: Value
private var defaultValue: Value