Skip to content

Instantly share code, notes, and snippets.

View 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
iButton Serial Number Formatter
View iButton_formatter.php
<?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 Mar 22, 2019
Traduire un fichier XLIFF (instructions)
View translate_xliff_file.md

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 Mar 19, 2019
Canonicalisation à la JF
View entity.php
<?php
/**
* Entité bidon, juste pour illustrer le principe
*/
class Entity {
/**
* @var string
*/
@ChMat
ChMat / functions.php
Created Mar 6, 2019
Wordpress Theme : Show the Age of a Person
View functions.php
<?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 :
*
View liveboard_Ottignies
{
"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",
View vehicle_BE.NMBS.TRN14017.json
{
"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
Enable passing OAuth2 Authorization header in requests
View .htaccess
# 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 Aug 29, 2015 — forked from deizel/tail.php
PHP log tail example
View tail.php
<?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);