Skip to content

Instantly share code, notes, and snippets.

View Jibbarth's full-sized avatar
🌴

Jibé Barth Jibbarth

🌴
View GitHub Profile
@Jibbarth
Jibbarth / convert_mov_to_mp4.sh
Created November 28, 2016 13:46
Convert mov to mp4 with ffmpeg preserving modification time
#!/bin/bash
for file in *.MOV; do
ffmpeg -i "$file" -vcodec copy -acodec copy "${file%.MOV}".mp4
touch -r "$file" "${file%.MOV}".mp4
done
@Jibbarth
Jibbarth / ieVersion.js
Last active April 4, 2017 10:14
Get Internet Explorer version and get is Edge Navigator in javascript
/**
* Gets the internet explorer version.
*
* @return {int} The internet explorer version.
*/
function getInternetExplorerVersion() {
var rv = -1;
if (navigator.appName == 'Microsoft Internet Explorer') {
var ua = navigator.userAgent;
@Jibbarth
Jibbarth / convertPdf.php
Created June 1, 2017 13:24
Convert pdf / PHP / Imagick
$sPathName = realpath($oFile->getPathname());
$oIm = new Imagick($sPathName);
$iNoOfPagesInPDF = $oIm->getNumberImages();
if ($iNoOfPagesInPDF) {
$aPdfPagePath = [];
for ($i = 0; $i < $iNoOfPagesInPDF; $i++) {
$sUrl = $sPathName . '[' . $i . ']';
$sPath = '/tmp/' . $oFile->getFilename() . '_' . ($i + 1) . '.pdf';
@Jibbarth
Jibbarth / README.md
Last active May 2, 2020 14:46
🇫🇷 Gnome / Chrome / Dark mode

Sur GNOME, j'ai ajouté l'extension DayNight qui permet de passer d'un theme sombre a light d'un clic.

Contrairement a Firefox, chrome ne prend pas en compte le theme mode de l'utilisateur à la volée.

Chrome n'interprete pas le color-prefers-scheme correctement, même si le theme est configuré sur Dark.

Pour lancer chrome en mode dark,

  google-chrome-stable --force-dark-mode
@Jibbarth
Jibbarth / Managing personal and work git email.md
Last active May 3, 2020 15:12
Automatically managing personal and work git email

In order to differentiate your professional and personal email address when working on git repositories, here is how I proceeded.

1. Create a global git hooks folder

Create a folder where you will drop the hooks that should apply to each repository. And set the core.hooksPath on this folder

git config --global core.hooksPath /path/to/my/centralized/hooks
@Jibbarth
Jibbarth / 00_sylius_admin_links_phpunit.md
Last active December 10, 2020 20:00
[Sylius] Test all admin menu links 🦢
@Jibbarth
Jibbarth / sylius_restrict_payment_methods.md
Last active May 10, 2021 16:38
[Sylius] Restrict Payment Methods depending on customer group

It could be common to display some payment methods only to customers that belong to a group.

For example, you can add an offline payment method for you B2B customers, and invoice them at the end of the month, and this offline payment should absolutely not be available for other customer! Let's see how to integrate this in a Sylius Application.

1. The Quick and Dirty way

The form displaying payment methods in Sylius retrieve them from the service sylius.payment_methods_resolver.

Let's decorate it !

@Jibbarth
Jibbarth / NoValidateFixerConfigurationResolver.php
Created February 12, 2023 11:37
[PHP-CS-Fixer] Configure any rule with except paths
<?php
declare(strict_types=1);
namespace App\Fixer;
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface;
final class NoValidateFixerConfigurationResolver implements FixerConfigurationResolverInterface
{
@Jibbarth
Jibbarth / ResolveTargetEntityListenerDecorator.php
Created August 27, 2023 15:06
[DOCTRINE] Automatically remove mappedSuperClass when resolveTargetEntity target the root model
<?php
declare(strict_types=1);
namespace App\Doctrine;
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
use Doctrine\ORM\Tools\ResolveTargetEntityListener;
use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
@Jibbarth
Jibbarth / index.md
Created December 9, 2023 11:38
[Sylius] Get ready to add a behat feature that use javascript

While contributing on Sylius, I had to add a test for a fix.

There was already some behat test regarding the feature, but I had trouble to get ready to launch them in my own environment, and Makefile provided by Sylius didn't help me.

Here is how I proceed.

1. Launching Sylius in test mode

First, you need to be able to launch the sylius, but in Test mode.