Skip to content

Instantly share code, notes, and snippets.

View pascualmg's full-sized avatar
👾
happy coding!

Pascual Muñoz pascualmg

👾
happy coding!
View GitHub Profile
@pascualmg
pascualmg / install_nix_macos.sh
Last active February 2, 2024 13:24
uninstall nix in macos
#!/bin/bash
if ! command -v curl >/dev/null 2>&1
then
echo "Curl no está instalado. Intentando instalar..."
# Intenta instalar Curl
sudo apt-get install curl
fi
# Verificar si Nix está instalado
if command -v nix >/dev/null 2>&1
@pascualmg
pascualmg / DropExceptionWhenMiddleware.php
Last active November 24, 2022 10:26
MiddleWare HOC to drop messages with concrete conditions
<?php
namespace PcComponentes\AfterSales\Infrastructure\MessagingMiddleware;
use PcComponentes\Ddd\Util\Message\Message;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Middleware\MiddlewareInterface;
use Symfony\Component\Messenger\Middleware\StackInterface;
use Symfony\Component\Messenger\Transport\AmqpExt\AmqpReceivedStamp;
use Throwable;
@pascualmg
pascualmg / zipAndZipWith.php
Created July 15, 2022 07:45
example iml of zip and zipWith in php
<?php
include_once '../vendor/autoload.php';
use Symfony\Component\VarDumper;
function zip(array $xs , array $ys): array {
$result = [];
foreach ($xs as $i => $x) {
$result[$i] = [$x, $ys[$i]];
}
@pascualmg
pascualmg / Makefile
Created October 5, 2020 09:31
docker consume
consume:
docker-compose exec --user=${UID} ${DOCKER_PHP_SERVICE} sh -c "console messenger:consume commands_low --bus=execute_command.bus --limit=100 --time-limit=60 -vv"
@pascualmg
pascualmg / CreateRepairCenterByFamilyAssignmentCommandHandlerTest.php
Created July 13, 2020 19:13
HOWTO test a command handler ( symfony , phpunit )
<?php
declare(strict_types=1);
namespace PcComponentes\AfterSales\Tests\Application\CreateRepairCenterByFamilyAssignment;
use InvalidArgumentException;
use PcComponentes\AfterSales\Application\CreateRepairCenterByFamilyAssignment\CreateRepairCenterByFamilyAssignmentCommand;
use PcComponentes\AfterSales\Application\CreateRepairCenterByFamilyAssignment\CreateRepairCenterByFamilyAssignmentCommandHandler;
use PcComponentes\AfterSales\Domain\Service\RepairCenterByFamilyAssigementCreator;
use PHPUnit\Framework\TestCase;
public function test_given_create_repair_center_by_family_assignment_command_handler_when_invoke_whith_correct_payload_then_save(
)
{
/** @var RepairCenterByFamilyAssigementCreator | MockObject $serviceMocked */
$serviceMocked = $optionCreatorMock = $this->getMockBuilder(
RepairCenterByFamilyAssigementCreator::class
)->disableOriginalConstructor()->getMock();
$serviceMocked
->expects(self::once())
<?php
namespace Pcc\Domain\AfterSales\Service;
use Doctrine\DBAL\Connection;
use Pcc\Domain\AfterSales\RefundMode;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class RefundModeToAfterSalesCaseAssociatorTest extends KernelTestCase
{
@pascualmg
pascualmg / Hydrator.php
Created June 23, 2020 23:40
generic php hydrator using reflextion
<?php
final class Hydrator
{
public static function fromPayload(string $className, array $payload)
{
return new $className(
...self::sortedParametersOrThrow(
(new ReflectionClass($className))->getConstructor()->getParameters(),
$payload
@pascualmg
pascualmg / 0 Linux-On-MBP-Late-2016.md
Created November 8, 2018 22:43 — forked from roadrunner2/0 Linux-On-MBP-Late-2016.md
Linux on MacBook Pro Late 2016 and Mid 2017 (with Touchbar)

Introduction

This is about documenting getting Linux running on the late 2016 and mid 2017 MPB's; the focus is mostly on the MacBookPro13,3 and MacBookPro14,3 (15inch models), but I try to make it relevant and provide information for MacBookPro13,1, MacBookPro13,2, MacBookPro14,1, and MacBookPro14,2 (13inch models) too. I'm currently using Fedora 27, but most the things should be valid for other recent distros even if the details differ. The kernel version is 4.14.x (after latest update).

The state of linux on the MBP (with particular focus on MacBookPro13,2) is also being tracked on https://github.com/Dunedan/mbp-2016-linux . And for Ubuntu users there are a couple tutorials (here and here) focused on that distro and the MacBook.

Note: For those who have followed these instructions ealier, and in particular for those who have had problems with the custom DSDT, modifying the DSDT is not necessary anymore - se

@pascualmg
pascualmg / react-component-modal.js
Created August 18, 2018 01:00
un puto modal en react usando emotion para el css
function PutoModal(props) {
const id = props.id || tOolz.generateRandomId('putomodal')
const uniqueModalId = 'modal-'.concat(id)
const blockOrNothing = props.open === true ? 'block' : ''
/**
* Cierra el modal
*/
function closeSelfModal() {