Skip to content

Instantly share code, notes, and snippets.

@Jibbarth
Jibbarth / sylius_restrict_payment_methods.md
Last active Mar 15, 2021
[Sylius] Restrict Payment Methods depending on customer group
View sylius_restrict_payment_methods.md

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 / 00_sylius_admin_links_phpunit.md
Last active Dec 10, 2020
[Sylius] Test all admin menu links 🦢
View 00_sylius_admin_links_phpunit.md
@Jibbarth
Jibbarth / README.md
Last active May 2, 2020
🇫🇷 Gnome / Chrome / Dark mode
View README.md

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 / 1.PHP_OAuth_CLI.md
Last active Feb 27, 2021
Recreate Github CLI OAuth feature in a Symfony command
View 1.PHP_OAuth_CLI.md

Recreate Github CLI OAuth feature in a Symfony command

Github recently released a CLI tool to manage issues and PR directly from your terminal. As I work on some open source projects, I downloaded it to give a try.

And at first launch, the CLI ask to connect by using OAuth. It propose to press "Enter" to open github.com in my browser, and catch correctly the access_token.

That .. blown my mind 🤯 I didn't expect we can connect through terminal like this. So, as it's open source, I dived into the code source.

@Jibbarth
Jibbarth / Managing personal and work git email.md
Last active May 3, 2020
Automatically managing personal and work git email
View Managing personal and work git email.md

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-Add_Composer.md
Last active Feb 18, 2021
Composering a PrestaShop
View 00-Add_Composer.md

Note : This is a guide for PS 1.6.x because 1.7 provide a composer.json

How to use composer in PrestaShop

The PHP World is full of talentued developers. They create very usefull and powerfull libraries. In PrestaShop, developers often have to reimplement them. Unless use composer !

Init a composer

First, you have to install composer to your system. I don't teach you how to do this, read the doc.

@Jibbarth
Jibbarth / convertPdf.php
Created Jun 1, 2017
Convert pdf / PHP / Imagick
View convertPdf.php
$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 / ieVersion.js
Last active Apr 4, 2017
Get Internet Explorer version and get is Edge Navigator in javascript
View ieVersion.js
/**
* 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 / convert_mov_to_mp4.sh
Created Nov 28, 2016
Convert mov to mp4 with ffmpeg preserving modification time
View convert_mov_to_mp4.sh
#!/bin/bash
for file in *.MOV; do
ffmpeg -i "$file" -vcodec copy -acodec copy "${file%.MOV}".mp4
touch -r "$file" "${file%.MOV}".mp4
done