Skip to content

Instantly share code, notes, and snippets.

@coisa
coisa / convert-path-into-submodule.sh
Created August 15, 2023 22:48
Convert GIT repository monorepo path into a submodule of an external repository
#!/bin/bash
#########################################################################################
# SCRIPT: Git Monorepo Splitter
#
# DESCRIPTION:
# This script is designed to help teams and individuals transition from a monorepo
# (a single repository containing multiple projects or directories) to a multi-repo setup
# (each project or directory in its own repository). The primary function is to take a
# directory from a monorepo and transform it into its own standalone repository, while

Description

Describe the task in a concise and cohesive manner.

Rather than dictating how a task should be accomplished, the description should focus on the expected outcome.

Motivation

Explain the motivation behind the creation of this task. Why this task was needed.

@coisa
coisa / index.js
Created July 29, 2022 15:54
Example of how to use a shebang for a specific NodeJS version through NVM
#!/usr/bin/env -S ${NVM_DIR}/versions/node/v17.9.1/bin/node
// Don't forget to run `chmod +x index.js`
// Always run the script directly, with the following command: `./index.js` instead of `node index.js`
console.log(`You are running node with the version: ${process.version}`);
<?php
namespace CoiSA\Facade;
abstract class AbstractFacade implements FacadeInterface
{
use FacadeTrait;
}
<?php
namespace CoiSA\Iterator\IteratorIterator;
use IteratorIterator;
use Traversable;
final class TrimIteratorIterator extends IteratorIterator
{
private $characters;
<?php
namespace CoiSA\Iterator;
use FilesystemIterator;
use FilterIterator;
use IteratorIterator;
use RecursiveIterator;
use RecursiveIteratorIterator;
<?php
/**
* @copyright Copyright (c) 2020-2022 Felipe Sayão Lobato Abreu <[email protected]>
* @license https://opensource.org/licenses/MIT MIT License
*/
namespace CoiSA\Autoload\ClassLoader;
/**
@coisa
coisa / ProxyCallStaticMethodInterceptor.php
Last active February 11, 2022 16:17
Defines a class to help replace static calls inside objects, using dependency injection to control the unit tests, without the need to re-implement the static call (changing every place that calls methods statically from a specific class).
<?php
namespace CoiSA\Helper;
/**
* Defines a class that can be used to proxy non-static calls to the corresponding static method of an object.
* It is used to help implement unit tests for classes that have static methods.
*
* @example
* <code>
<?php
namespace CoiSA\Helper;
final class ReadlineAllowedAnswers
{
public function __construct(
private string $question,
private array $allowedAnswers = ['y', 'n'],
private bool $isCaseSensitive = false
<?php
use CoiSA\Facade;
interface PhpIncludeFacadeInterface
{
/**
* Facade for "include" & "include_once" functions
*/
public function includePhpFile($filepath, bool $once = true);