Skip to content

Instantly share code, notes, and snippets.


Mickael Lehoux MkLHX

View GitHub Profile
MkLHX / template.html.twig
Last active March 25, 2020 15:16
How to update specific key on existing multidimensional array in twig
View template.html.twig
{% set contents = {"one": 1,"two":2,"three":3,"four":4,"five":5} %}
{# Create the array an structure somewhere in the view #}
{% set twigArray = {} %}
{% for content in contents %}
{% set twigArray = twigArray|merge({('hashkey_'~loop.index0):{'enabled':true,'caption':'unknow','button':{'text':'unknow','href':'unknow'},'image':{'src': content.content|raw),'alt':"image-"~loop.index, 'href':"" }}}) %}
{% endfor %}
{{ dump(twigArray)}}
{# For any reason you need to update a specific key value in the exiting array in the view
call the twig extension to do that in php side #}
Created January 8, 2020 15:54
raspi-config command list to use it in cli
/* Command strings */
#define GET_CAN_EXPAND "raspi-config nonint get_can_expand"
#define EXPAND_FS "raspi-config nonint do_expand_rootfs"
#define GET_HOSTNAME "raspi-config nonint get_hostname"
#define SET_HOSTNAME "raspi-config nonint do_hostname %s"
#define GET_BOOT_CLI "raspi-config nonint get_boot_cli"
#define GET_AUTOLOGIN "raspi-config nonint get_autologin"
#define SET_BOOT_CLI "raspi-config nonint do_boot_behaviour B1"
#define SET_BOOT_CLIA "raspi-config nonint do_boot_behaviour B2"
#define SET_BOOT_GUI "raspi-config nonint do_boot_behaviour B3"
MkLHX / PH_EC_reader_example.ino
Last active July 19, 2019 09:43
Read Serial Monitor orders to launch EC or PH calibration process (Arduino IDE version)
View PH_EC_reader_example.ino
#include "DFRobot_ESP_EC.h" //
#include "DFRobot_ESP_PH_WITH_ADC.h" //
#include "Adafruit_ADS1015.h" //
#include "OneWire.h"
#include "DallasTemperature.h"
#include "EEPROM.h"
#define ONE_WIRE_BUS 15
OneWire oneWire(ONE_WIRE_BUS);
MkLHX / main.cpp
Last active July 19, 2019 09:50
Read Serial Monitor orders to launch EC or PH calibration process (platformIO version)
View main.cpp
#include "Arduino.h"
#include "DFRobot_ESP_EC.h" //
#include "DFRobot_ESP_PH_WITH_ADC.h" //
#include "Adafruit_ADS1015.h" //
#include "OneWire.h"
#include "DallasTemperature.h"
#include "EEPROM.h"
MkLHX / main.cpp
Last active August 2, 2022 17:56
ESP32 - Update firmware through AsyncWebServer
View main.cpp
AsyncWebServer server_http(80);
const char header_html[] PROGMEM = "<!DOCTYPE html><html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'/><meta name='viewport' content='width=device-width, initial-scale=1, minimum-scale=1.0, shrink-to-fit=no'><title> - WebView</title></head><body>";
const char footer_html[] PROGMEM = "</body></html>";
const char update_html[] PROGMEM = "<h1>Only .bin file</h1><form method='POST' action='/updt' enctype='multipart/form-data'><input type='file' name='update' required><input type='submit' value='Run Update'></form>";
void setup()
/* ... */
MkLHX / main.cpp
Created April 30, 2019 16:59
Send Serial printed data in webserver view
View main.cpp
#include "Arduino.h"
#include "WiFi.h"
#include "ESPAsyncWebServer.h"
#include "SPIFFS.h"
const char *ssid = "<yourssid>";
const char *password = "<wpakey>";
AsyncWebServer server_http(80);
MkLHX / base.html.twig
Last active July 14, 2020 20:57
passe twig variables to javascript function Symfony 4.3.2
View base.html.twig
<!DOCTYPE html>
<!-- //... -->
{% set cookieData = {
msg: 'this website using cookie and by continuing navigation you accept blablablabla....etc',
btn1: 'More',
btn2: 'Accept',
path: '/privacy-policy'
MkLHX / ContactController.php
Last active March 27, 2019 14:50
Recaptcha V2 on SF4 project
View ContactController.php
namespace App\Controller\Ui\WebSite;
use App\Services\SendinblueApi;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use App\Form\ContactType;
use ReCaptcha\ReCaptcha;
MkLHX / SendinblueApi.php
Last active February 15, 2019 14:13
Send email in SF4 with sendinblue api V3 -
View SendinblueApi.php
namespace App\Services;
use Symfony\Component\DependencyInjection\ContainerInterface;
* Class SendinblueApi
* @package App\Services
MkLHX / App.js
Created February 4, 2019 16:59
View App.js
import React, { Component } from "react";
import "./App.css";
import MyTimer from "./MyTimer";
class App extends Component {
render() {
return (
<div className="App">
<header className="">