Skip to content

Instantly share code, notes, and snippets.

Avatar
🌖

Alex Rock Pierstoval

🌖
View GitHub Profile
@Pierstoval
Pierstoval / Makefile
Created Mar 31, 2021
Reset your entire application securely from a Makefile
View Makefile
#
# When you run "make full-reset", you see a warning message telling you to
# re-run the command with an environment variable if you're sure.
#
# So to *actually* execute the command, you have to run "make -e RESET=1 full-reset".
# Feel free to change the "resetting" scripts as you want.
#
# These are helper vars to use to have a nicer display for messages
_TITLE := "\033[32m[%s]\033[0m %s\n" # Green text
@Pierstoval
Pierstoval / remove_windows_dir_from_wsl.bash
Last active Mar 14, 2021
Remove Windows directories from WSL's PATH
View remove_windows_dir_from_wsl.bash
# Remove Windows directories from WSL's PATH
export PATH=$(echo $PATH \
| sed 's/:/\n/g' \
| sort -u \
| grep -v -e'/mnt/[a-z]/' \
| sed -z 's/\n/:/g' \
| sed 's/:$//'
)
@Pierstoval
Pierstoval / Makefile
Last active Mar 3, 2021
"confirm" action for your Makefile
View Makefile
# To use the "confirm" target inside another target,
# use the " if $(MAKE) -s confirm ; " syntax.
mycommand:
@if $(MAKE) -s confirm ; then \
execute_your_command_here ; \
fi
.PHONY: mycommand
# The CI environment variable can be set to a non-empty string,
View Acronymes.md

Liste d'acronymes utilisés dans la programmation

Acronyme Définition
POO / OOP programmation orientée objet / object-oriented-programming
Les principes SOLID :
• SRP Single Responsibility Principle
• OCP Open/Closed principle
• LSP Liskov Substitution Principle (un acronyme féministe, du nom de la mathématicienne Barbara Liskov !)
@Pierstoval
Pierstoval / Makefile
Last active Mar 2, 2021
"Check requirements" command for your Makefile
View Makefile
# Use it like this:
#
# $ printf $(_TITLE) "Something in green" "The message"
#
# This will output something like this:
#
# [Something in green] The message
#
# (of course, with proper colors)
_TITLE := "\033[32m[%s]\033[0m %s\n" # Green text
View snippet.js
(function(){
let list=document.querySelectorAll('.event--vote-stars');
let score = 0;
for (let i=0,l=list.length;i<l;i++) {
let el=list[i];
score+=el.querySelectorAll('a.star.is-selected').length;
}
console.info(score/list.length);
})();
View Ways.php
<?php
declare(strict_types=1);
/*
* This file is part of the Agate Apps package.
*
* (c) Alexandre Rock Ancelet <pierstoval@gmail.com> and Studio Agate.
*
* For the full copyright and license information, please view the LICENSE
View README.md

Native mocks versus PHPUnit mocks

Mock type Tests duration
Native mocks 160.10 seconds
Mockery 177.01 seconds (+10%)
PHPUnit mocks 232.29 seconds (+45%)
Prophecy 3868.80 seconds (+2416%)
View FormLoginAuthenticator.php
<?php
/**
* This file is part of the corahn_rin package.
*
* (c) Alexandre Rock Ancelet <alex@orbitale.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
View GetHttpClientTestTrait.php
<?php
declare(strict_types=1);
namespace Tests;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase as BaseWebTestCase;
use Symfony\Component\BrowserKit\Cookie;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;