Skip to content

Instantly share code, notes, and snippets.

View rlaguilar's full-sized avatar

Reynaldo Aguilar rlaguilar

  • Canva
  • Sydney, Australia
View GitHub Profile
import UIKit
final class PagingCollectionView: UICollectionView, UICollectionViewDelegate {
private weak var externalDelegate: UICollectionViewDelegate?
override var delegate: UICollectionViewDelegate? {
get { return externalDelegate }
set {
externalDelegate = newValue
let currentDelegate = super.delegate
@rlaguilar
rlaguilar / CIFilter+Extension.swift
Created May 8, 2019 16:04 — forked from Umity/CIFilter+Extension.swift
CIFilter+Extension.swift
//
// Created by はるふ on 2017/12/11.
// Copyright © 2017年 ha1f. All rights reserved.
//
import Foundation
import CoreImage
import AVFoundation
extension CIFilter {
import Foundation
import CoreGraphics
/*
Usage:
Interpolate(.linear).between(x, and: y, progress: progress) // progress is 0 to 1
*/
@rlaguilar
rlaguilar / dealloc-breakpoint.md
Created March 7, 2022 03:43 — forked from eneko/dealloc-breakpoint.md
Xcode UIViewController dealloc breakpoint

Xcode deinit breakpoint for UIViewController

This breakpoint provides an easy way to track view controller deinitialization (deallocation) in UIKit-based applications. This can help finding memory leaks caused by retain cycles preventing view controllers from being deinitialized when dismissed or popped.

From Cédric Luthi's tweet in 2017:

Useful Xcode breakpoint. When you dismiss a controller and you don’t hear the pop sound (or see the log), you probably have a retain cycle.

@rlaguilar
rlaguilar / Buffer.swift
Last active October 3, 2024 03:31
Producer consumer pattern using Swift concurrency
import Foundation
actor Buffer<Element> {
private let emptySlots = Stream<Void>()
private let availableElements = Stream<Element>()
init(capacity: Int) {
for _ in 0 ..< capacity {
emptySlots.push(())
}