Skip to content

Instantly share code, notes, and snippets.

@ChMat
ChMat / README.md
Created January 17, 2024 08:14
Configuration Rector pour migrer vers PHP 8 & Symfony 6

Migrer vers Symfony 6 et PHP 8.1

Un embryon de code pour faciliter la montée en version avec Rector.

Installation de rector

composer require rector/rector --dev
@ChMat
ChMat / keybase.md
Created July 10, 2019 15:08
keybase.md

Keybase proof

I hereby claim:

  • I am chmat on github.
  • I am chmat (https://keybase.io/chmat) on keybase.
  • I have a public key ASAxEOx1jKJM5_2PS9-XwV4lRJBOPm2vxJ79Sne5APY7Ogo

To claim this, I am signing this object:

@ChMat
ChMat / iButton_formatter.php
Created May 15, 2019 12:37
iButton Serial Number Formatter
<?php
class iButton {
/**
* Convertit le format du numéro de série iButton dans un format acceptable pour Loxone
*
* Input : ABCDEFGHIJKLMNOP
* Output : OP.MN.KL.IJ.GH.EF.CD.AB
*
@ChMat
ChMat / translate_xliff_file.md
Created March 22, 2019 09:18
Traduire un fichier XLIFF (instructions)

Traduire un fichier XLIFF

Les fichiers contenus dans le dossier /translations peuvent être dupliqués et renommés en remplaçant le code de la langue (juste avant l'extension) par le code de la nouvelle langue. Les fichiers sont extraits au format XLIFF, un standard connu dans le secteur de la traduction.

Un segment dans un fichier XLIFF

Un segment de traduction ressemble à ceci :

@ChMat
ChMat / entity.php
Created March 19, 2019 13:04
Canonicalisation à la JF
<?php
/**
* Entité bidon, juste pour illustrer le principe
*/
class Entity {
/**
* @var string
*/
@ChMat
ChMat / functions.php
Created March 6, 2019 14:51
Wordpress Theme : Show the Age of a Person
<?php
// Ajoute le shortcode [age date="jj/mm/aaaa"]
add_shortcode('age', 'chmat_age');
/**
* Retourne l'âge d'une personne suivant la date de naissance fournie au format jj/mm/aaaa.
*
* Exemple :
*
{
"version": "1.1",
"timestamp": "1524334620",
"station": "Ottignies",
"stationinfo": {
"id": "BE.NMBS.008811601",
"locationX": "4.56936",
"locationY": "50.673667",
"@id": "http://irail.be/stations/NMBS/008811601",
"standardname": "Ottignies",
{
"version": "1.1",
"timestamp": "1524334335",
"vehicle": "BE.NMBS.TRN14017",
"vehicleinfo": {
"locationX": "4.56936",
"locationY": "50.673667",
"name": "BE.NMBS.TRN14017",
"shortname": "TRN14017",
"@id": "http://irail.be/vehicle/TRN14017"
@ChMat
ChMat / .htaccess
Created May 31, 2017 08:38
Enable passing OAuth2 Authorization header in requests
# Apache blocks the Authorization header by default.
# You should enable the RewriteEngine if this is not done already
RewriteEngine On
# Sets the HTTP_AUTHORIZATION header removed by apache
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
@ChMat
ChMat / tail.php
Last active August 29, 2015 14:27 — forked from deizel/tail.php
PHP log tail example
<?php
if (isset($_GET['ajax'])) {
session_start();
$handle = fopen('/private/var/log/system.log', 'r');
if (isset($_SESSION['offset'])) {
$data = stream_get_contents($handle, -1, $_SESSION['offset']);
echo nl2br($data);
} else {
fseek($handle, 0, SEEK_END);
$_SESSION['offset'] = ftell($handle);