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 / prd.md
Created April 15, 2025 09:13 — forked from burkeholland/prd.md
TheUrlist PRD

Project Requirements Document: The Urlist Website

The following table outlines the detailed functional requirements of The Urlist website.

Requirement ID Description User Story Expected Behavior/Outcome
FR001 Creating a New URL List As a user, I want to be able to start a new, empty list so I can begin adding URLs. The system should provide a clear way for the user to initiate the creation of a new list, potentially presenting an empty list view or an "add new list" button.
FR002 A
@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
}