Skip to content

Instantly share code, notes, and snippets.

View alexandreelise's full-sized avatar
💡
Votre Site Web. Augmenté.

Mr Alexandre J-S William ELISÉ alexandreelise

💡
Votre Site Web. Augmenté.
View GitHub Profile
@alexandreelise
alexandreelise / create-docker-image-diff.sh
Created March 12, 2025 14:23
How to create a diff of Docker images on Unix Systems (It might work for Windows too)
#!/bin/bash
set -eux
diff -u <(docker image history yourrepo/yourimage1:yourtag) <(docker image history yourrepo/yourimage2:yourtag)
@alexandreelise
alexandreelise / postman-collection-level-optimised-pre-request-script.js
Created December 21, 2024 15:43
An example of heavily automated, optimized, effective Postman collection level pre-request script
// Remove collection name from the breadcrumb
pm.execution.location.splice(0, 1);
// Remove the last element as it is the request and we don't need it
pm.execution.location.pop();
let currentLocation = pm.execution.location.map(item => item.replace(/^((\d+\.\d*)(\s+))/, '').toLowerCase().split(' ').join('_')).join('_') || pm.variables.replaceIn('{{$uuid}}');
console.log('computed current location', currentLocation);
// set collection level current location to use it in all request and responses in this collection and it also mean it is self-contained
@alexandreelise
alexandreelise / postman-collection-level-optimised-post-response-script.js
Created December 21, 2024 15:41
An example of heavily automated, optimized, effective Postman Collection level post-response script
let currentLocation = pm.collectionVariables.get('computed_current_location');
pm.test(`Successful 2xx request for ${currentLocation}`, () => {
pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 203, 204, 205, 206, 207, 208, 226]);
});
let method = pm.request.method;
if (['POST', 'PATCH', 'PUT'].includes(method)) {
pm.test("Content-Type is present for ${currentLocation}", () => {
@alexandreelise
alexandreelise / solution-ucfirst-bug-string-already-in-allcaps.php
Created December 17, 2024 18:20
Solution ucfirst bug when string is already in ALLCAPS in php one-liner
<?php
// Solution ucfirst bug when string is already in ALLCAPS
$result = (isset($givenString) && !empty(trim($givenString)) ? mb_ucfirst(mb_strtolower($givenString)) : '');
@alexandreelise
alexandreelise / regex-to-find-merge-conflicts-in-git-when-using-phpstorm.txt
Created December 13, 2024 10:37
Find merge conflicts in git using PhpStorm Java based POSIX-form regex
(<<<<<<< ([A-Za-z\s]+)\n)([\p{Print}\p{Space}\p{ASCII}\p{L}]+)\n(=======)\n([\p{Print}\p{Space}\p{ASCII}\p{L}]+)(>>>>>>> ([A-Za-z\s]+))

One-liner to use plausible.io Web Analytics on your Joomla Website

Joomla\CMS\Factory::getApplication()->getDocument()->getWebAssetManager()->registerAndUseScript('plausible-io', 'https://plausible.io/js/script.js', [], ['defer' => true, 'data-domain' => \Joomla\CMS\Uri\Uri::getInstance()->getHost()], []);

WHY

Scratched my own itch. Thought it might be useful to you too.

@alexandreelise
alexandreelise / error.php
Last active May 13, 2023 14:44
Handle Joomla 404 errors gracefully in 5 lines of code: Fr: Redirection erreur 404 vers un article Joomla en 5 lignes de code / En: Redirect incoming 404 errors to custom Joomla article in 5 lines of code
<?php
/** Redirection vers article personnalisé */
if ($this->error->getCode() == 404) {
header(sprintf('Location: %s', \Joomla\CMS\Router\Route::_('index.php?option=com_content&view=article&id=64', false, \Joomla\CMS\Router\Route::TLS_FORCE, true)));
exit(0);
}
@alexandreelise
alexandreelise / create-joomla-article-from-streamed-csv-with-raw-php-using-joomla4x-api.php
Last active October 8, 2022 15:58
Create an article in Joomla from streamed csv with raw php using Joomla! 4.x Web Services Api
<?php
declare(strict_types=1);
/*
YOUR ATTENTION PLEASE. THE NEW PLACE FOR THIS CODE IS : https://github.com/alexandreelise/j4x-api-examples
*/
/**
@alexandreelise
alexandreelise / plg_fields_articles_layout_title.php
Created October 2, 2022 19:33
Quick fix on line 29 to prevent error from happening when using this plugin with Joomla! 4.x Webservices Api. Fix made for one of my Super Joomler friends: Custom King.
<?php
/**
* @package Articles Field
* @version 3.9.0
*
* @author Peter van Westen <[email protected]>
* @link http://regularlabs.com
* @copyright Copyright © 2022 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
@alexandreelise
alexandreelise / plg_content_responsive.php
Created October 2, 2022 19:21
Quick fix on line 31 to prevent error when using it with Joomla! Webservices Api
<?php
/**
* @package ttc-freebies.plugin-responsive-images
*
* @copyright Copyright (C) 2017 Dimitrios Grammatikogiannis. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') || die;
use Joomla\CMS\Plugin\CMSPlugin;