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 / 00-Add_Composer.md
Last active April 23, 2024 19:04
Composering a PrestaShop

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 / 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 / 1.PHP_OAuth_CLI.md
Last active April 22, 2024 23:34
⚡Recreate Github CLI OAuth feature in a Symfony command ⚡

⚡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 / 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 / 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
{