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 / LocationManager.swift
Created May 5, 2023 08:13
A simple class illustration the use of CoreLocation to get ask and access user's location in SwiftUI
import CoreLocation
{
private let locationManager = CLLocationManager()
@Published var authorisationStatus: CLAuthorizationStatus = .notDetermined
@Published private(set) var userLocation: UserLocation?
private let merchantProvider: MerchantProtocol
var permissionStatus: LocationStatus {
switch authorisationStatus {
@cedricbahirwe
cedricbahirwe / FileCache.swift
Created May 3, 2023 14:03
A Simple File Cache in Swift
import Foundation
import CryptoKit
enum FileCache {
// Write data to the cache file with the given URL
static func write(_ url: URL, data: Data) -> Void {
// Get the cache directory URL for the current user
if let fileManager = try? FileManager.default.url(for: .cachesDirectory, in: .userDomainMask, appropriateFor: nil, create: true) {
// Generate a unique file name for the cache file based on the URL hash
import UIKit
let json = """
[
{
"id": 1,
"name": "Watermarking photos with ImageMagick, Vapor 3 and Swift on macOS and Linux",
"type": "articles",
"photo": "https://mikemikina.com/assets/imagemagick-vapor-3/watermarked-photo.png",
"tags": ["Tutorial", "Vapor"]
let json = """
[
{
"id": 1,
"name": "Any vs. AnyObject in Swift",
"type": "articles"
},
{
"id": 2,
"name": "New Apple silicon",
@cedricbahirwe
cedricbahirwe / territories.swift
Last active November 15, 2022 18:39
Algorithm to extract the Ethnies/Tribus/Territoire of DRC from a literal String
import Foundation
//VOICI LA LISTE DES ETHNIES ET TRIBUS PAR TERRITOIRE DE LA RDC, UN ARTICLE RETROUVÉ AU MUSEE DE TERVUREN EN BELGIQUE (LES BANYAMULENGE, 𝑫𝑬𝑺 𝑹𝑾𝑨𝑵𝑫𝑨𝑰𝑺, N'Y FIGURENT PAS )*
//
//Recherchez aussi la vôtre...
//Ethnies/Tribus/Territoire*
//Patrice Emery Lumumba avait prédit : « l’histoire du Congo sera écrite par les congolais eux-mêmes ».
//Bravo à nos historiens et chefs coutumiers qui devraient vulgariser ce texte afin de sortir notre progéniture de l'ignorance.
//Le Chercheur !!!!
// Check output at: https://gist.github.com/cedricbahirwe/13cbeee55ff10dfc39f56940aa8b82ea
@cedricbahirwe
cedricbahirwe / drc_territories.json
Last active May 3, 2023 16:13
VOICI LA LISTE DES ETHNIES ET TRIBUS PAR TERRITOIRE DE LA RDC, UN ARTICLE RETROUVÉ AU MUSEE DE TERVUREN EN BELGIQUE
[
{
"key": 1,
"ethnie": "Abandiya",
"tribues": [
"Aketi",
"Bondo",
"Buta"
]
},
@cedricbahirwe
cedricbahirwe / PrereqsCourses.swift
Last active May 3, 2023 14:15
My Attempted Algorithmic Solution to Andela Interview Question
import Foundation
var prereqsCourses = [
("Software Design", "Algorithms"),
("Foundations of Computer Science", "Operating Systems"),
("Computer Networks", "Computer Architecture"),
("Computer Architecture", "Software Design"),
("Algorithms", "Foundations of Computer Science"),
("Data Structures", "Computer Networks")
]
@cedricbahirwe
cedricbahirwe / cross-view-lines.swift
Created September 14, 2022 14:46 — forked from bjhomer/cross-view-lines.swift
Creating cross-view lines in SwiftUI
//
// ContentView.swift
// SwiftUIPlayground
//
// Created by BJ Homer on 4/26/21.
//
import SwiftUI
@cedricbahirwe
cedricbahirwe / Canvas.swift
Created September 2, 2022 18:41
No words to explain this
//
// CanvasView.swift
// MyiOS15
//
// Created by Cédric Bahirwe on 14/06/2021.
//
import SwiftUI
let someSymbols = Array(repeating: Symbol("image1"), count: 80) + Array(repeating: Symbol("image2"), count: 50)
@cedricbahirwe
cedricbahirwe / SOLID.swift
Last active August 24, 2022 09:38
A bunch of example illustrating SOLID Principles
import Foundation
class Book {
let name: String
let authorName: String
let year: Int
let price: Double
let isbn: String
init(name: String, authorName: String, year: Int, price: Double, isbn: String) {