Skip to content

Instantly share code, notes, and snippets.

View cedricbahirwe's full-sized avatar
📈
Small things in a Great way

Cédric Bahirwe cedricbahirwe

📈
Small things in a Great way
View GitHub Profile
@cedricbahirwe
cedricbahirwe / dealloc-breakpoint.md
Created March 18, 2025 22:10 — 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.

@cedricbahirwe
cedricbahirwe / hexagonalshapes.swift
Created August 5, 2024 12:38
This function creates a horizontal row of hexagons based on the specified width, height, number of hexagons, and spacing. Each hexagon is generated by the addHexagon(at:) helper function, which places it at the correct position with a flat-sided shape.
/// Creates a combined path of hexagons arranged horizontally with specified width, height, and spacing.
///
/// - Parameters:
/// - width: The total width available for the hexagons.
/// - height: The height of each hexagon.
/// - count: The number of hexagons to include (default is 1).
/// - spacing: The spacing between adjacent hexagons (default is 0).
/// - Returns: A `UIBezierPath` object representing the combined hexagon path.
func createCombinedHexagonPath(width: CGFloat, height: CGFloat, count: Int = 1, spacing: CGFloat = 0) -> UIBezierPath {
let path = UIBezierPath()
@cedricbahirwe
cedricbahirwe / DriosToolTipView.swift
Last active March 21, 2024 09:53
A Tooltip Prototype View
import UIKit
import SwiftUI
protocol DriosToolTipViewDelegate : AnyObject {
func didTapToolTip(_ tipView: DriosToolTipView)
func didDismissToolTip(_ tipView : DriosToolTipView)
}
// MARK: - DriosToolTipView class implementation
final class DriosToolTipView: UIView {
@cedricbahirwe
cedricbahirwe / find_top_heaviest.sh
Created December 11, 2023 09:52
This shell script finds and displays the top N heaviest subdirectories in a given directory, where N is provided by the user as a command-line argument.
#!/bin/bash
# Check if the correct number of arguments is provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <directory> <number_of_top_directories>"
exit 1
fi
directory="$1"
top_count="$2"
@cedricbahirwe
cedricbahirwe / migration.sh
Created November 22, 2023 10:54
One of those scripts you may need
#!/bin/bash
# Set the paths for the folders
folderA="/path/to/A"
folderB="$folderA/B"
folderC="$folderA/C"
# Check if folders exist
if [ ! -d "$folderA" ] || [ ! -d "$folderB" ] || [ ! -d "$folderC" ]; then
extension CongratulationsView {
internal struct CongratsView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
CongratsViewController()
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) { }
}
}
@cedricbahirwe
cedricbahirwe / seats.swift
Created September 28, 2023 19:24
A demo on seats simulations using MapBox
import UIKit
import MapboxMaps
class ViewController: UIViewController {
private let geoJSONDataSourceIdentifier = "geoJSON-data-source"
private var mapView: MapView!
private var label: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
@cedricbahirwe
cedricbahirwe / extensions.swift
Created July 15, 2023 20:36
Contains HelpFul Swift Extensions that can also be found on my gists with more explanation
import UIKit
import CryptoKit
import CommonSwiftExtensions_Sources
var str = "Hello, playground"
//1 A simple Regex algorithm that check if a string respect a certain logic
func stringContains(string: String, logic: String) {
let range = NSRange(location: 0, length: logic.utf16.count)
let regex = try! NSRegularExpression(pattern: "[a-z]at")
extension String {
func add(highlight: String, color: UIColor = .white) -> NSAttributedString {
let attributedString = NSMutableAttributedString(string: self)
guard
let range = self.range(of: highlight),
let fullRange = self.range(of: self)
else {
return attributedString
}

Some issues supporting older versions of iOS (4, 5 years older)

Supporting older versions of iOS, such as those released 4 or 5 years ago, can present several challenges for developers and organizations. Here are some of the main issues associated with supporting older iOS versions:

  1. Compatibility: As iOS evolves, newer features, frameworks, and APIs are introduced. Supporting older versions requires developers to ensure compatibility with outdated APIs and frameworks, which can be time-consuming and may limit the ability to leverage new functionalities.

  2. Security vulnerabilities: Older iOS versions are more likely to have known security vulnerabilities that have been patched in subsequent updates. By supporting older versions, developers expose users to potential security risks, as they may miss out on critical security updates and bug fixes.

  3. Limited user base: Over time, the majority of users tend to update their devices to the latest iOS version. Supporting older versions may require signific