Skip to content

Instantly share code, notes, and snippets.

View chrsp's full-sized avatar

Charles Prado chrsp

  • Post Finance
  • Portugal
View GitHub Profile
@chrsp
chrsp / changed_files_by_author.sh
Last active January 12, 2024 15:20
Returns all the files updated by the provided authors in the interval of a month
#!/bin/bash
#This Bash script generates a succinct summary of file changes in Git repositories for specified users over the last month. The script accepts a list of Git usernames, producing a Markdown file (`changed_files.md`) that lists unique changed files for each user, limited to commits made within the past month. To ensure a fresh summary is created with each execution, the script clears the previous content of the output file.
#1. Edit the `git_users` array with the desired Git usernames and emails.
#2. Save the script and make it executable.
#3. Run the script to obtain an updated changes summary in the Markdown file.
# List of git users
git_users=(
"user1"
@chrsp
chrsp / remove_duplicate_imports.py
Last active September 21, 2023 11:49
Use to remove duplicate imports in Swift Files
import os
import re
import sys
def find_swift_files(directory):
swift_files = []
for root, _, files in os.walk(directory):
for file in files:
if file.endswith(".swift"):
swift_files.append(os.path.join(root, file))
@chrsp
chrsp / add_files.sh
Created September 8, 2023 09:04
Uses xcodeproj to add from a folder to a Xcode Project
#!/bin/bash
# Function to install the 'xcodeproj' gem
install_xcodeproj() {
gem install xcodeproj
}
# Check if 'xcodeproj' gem is installed
if ! gem spec xcodeproj > /dev/null 2>&1; then
echo "Installing 'xcodeproj' gem..."
// Module: CleanArchitectureRestaurant
import Domain
import Data
import Presentation
final class DinningHallDIContainer {
func makeKitchenUseCase() -> KitchenUseCase {
let cooker = ItalianCooker()
// Module: Data
import Domain
public struct KitchenLocalDataSource: KitchenLocalRepository {
public func getIngredients(_ recipe: Recipe) -> [Ingredient]? {
// do something to fetch the ingredients needed from some local store: UserDefaults, CoreData, Memory Cache, KeychainManager etc
}
}
// Module: Data
import Domain
public struct: ItalianCooker: CookerProtocol {
func cook(_ recipe: Recipe) {
switch recipe {
case recipe is SpaghettiCarbonara:
cookSpaghettiCarbonara(recipe)
public protocol KitchenLocalRepository {
public func getIngredients(_ recipe: Recipe) -> [Ingredient]?
}
public protocol KitchenRemoteRepository {
public func getIngredients(_ recipe: Recipe, completion: ([Ingredient]?) -> Void))
}
public protocol CookerProtocol {
public func cook(_ recipe: Recipe)
// Module: Domain
protocol Cookable {
func cook()
}
protocol Recipe: Cookable {
// Recipe definition
}
// Module: Domain
struct KitchenUseCase {
// Obtains stuff already stored in some place inside the restaurant
// For example: fetching it from CoreData, KeychainManager, UserDefaults and so on.
private let localDataSource: KitchenLocalRepository
// Obtains stuff needed from outside of our restaurant.
// For example: doing API calls to a NetworkManager.
[
{
"themeName": "base",
"colors": [
{
"name": "colorPrimary",
"hex": "fafafa"
},
{
"name": "colorOnPrimary",