Skip to content

Instantly share code, notes, and snippets.

View hgraca's full-sized avatar

Herberto Graça hgraca

View GitHub Profile
@hgraca
hgraca / git-move-folder-with-history.sh
Last active June 6, 2025 09:02
Extract repo folder into a new repo
#!/usr/bin/env bash
# ATTENTION
# This script is incomplete, we would still need to add a way to provide the paths where the files we want to keep have been before.
# Alternatively, we could change the script to remove all files that are not under the path we specify,
# the code is already there, we just need to adjust and test.
# Usage: ./git-move.sh git@github.com:My/source-repo.git git@github.com:My/destination-repo.git my/path/to/keep
SOURCE_REPO=${1}
@hgraca
hgraca / M-V-C-VM_-_Controller_example.php
Last active August 17, 2017 07:05
A simple example of my prefered MVC implementation, with featuring the Model, a View, a Controller, and a ViewModel.
<?php
// src/UI/Admin/Some/Controller/Namespace/Detail/SomeEntityDetailController.php
namespace UI\Admin\Some\Controller\Namespace\Detail;
// use ...
final class SomeEntityDetailController
{
/**
@hgraca
hgraca / MVP_snippet.php
Last active April 2, 2017 20:17
MVP snippet used in my blog post about MVC and variants
<?php
class MyPresenter
// ...
public function showUsers()
{
// ...
$data = $this->accountManager->getUserDetails($from = 10, $to = 20);
$this->view->bind('list', $data);
// ...