Skip to content

Instantly share code, notes, and snippets.

View MushuLeDragon's full-sized avatar
🐉
On Fire

MushuLeDragon MushuLeDragon

🐉
On Fire
View GitHub Profile
@MushuLeDragon
MushuLeDragon / composer.json
Created January 31, 2020 15:34 — forked from andyshinn/composer.json
Docker Compose PHP Composer Example
{
"require": {
"mfacenet/hello-world": "v1.*"
}
}
@MushuLeDragon
MushuLeDragon / debug.php
Last active April 6, 2020 09:29
Display execution time from your script PHP - Inspired from @EPradillon
<?php
/**
* Place this code line at the top of your code
*/
define('DEBUG_TIME', microtime( true ));
ini_set('xdebug.var_display_max_depth', '10');
ini_set('xdebug.var_display_max_children', '256');
ini_set('xdebug.var_display_max_data', '1024');
@MushuLeDragon
MushuLeDragon / HideTableRowsCollapse.html
Last active January 28, 2020 15:58
Hide / Show table rows HTML, JS or JQuery - Inspired from https://stackoverflow.com/a/41143167/7998119
<!-- https://getbootstrap.com/docs/4.3/components/collapse/ -->
<!-- Use Collapse Bootstrap to hide/show rows -->
<!-- Available on Tables -->
<p>
<a class="btn btn-primary" data-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Toggle first element</a>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#multiCollapseExample2" aria-expanded="false" aria-controls="multiCollapseExample2">Toggle second element</button>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target=".multi-collapse" aria-expanded="false" aria-controls="multiCollapseExample1 multiCollapseExample2">Toggle both elements</button>
</p>
<div class="row">
@MushuLeDragon
MushuLeDragon / listNameInputInArray.php
Last active January 24, 2020 10:23
List all INPUT name in an array on POST form (name="array[key]"). - Inspired from @EPradillon
<?php var_dump($_POST); ?>
<form action="" method="post">
First name: <input type="text" name="user[fname]" value="Yolo"><br>
Last name: <input type="text" name="user[lname]" value="Oloy"><br>
<input type="submit" value="Submit">
</form>
@MushuLeDragon
MushuLeDragon / FindDuplicatesRows.php
Last active November 25, 2020 14:06
Class Database
<?php
$sql = "SELECT DISTINCT a.*
FROM provider a
INNER JOIN provider b ON a.id_cgpo = b.id_cgpo
WHERE a.id <> b.id
ORDER BY a.id_cgpo, a.id;
";
@MushuLeDragon
MushuLeDragon / searchInArray.php
Last active November 26, 2019 14:50
How to find a value in multi array and return their position in the arrayList
<?php
// Base on the answer of :
// https://stackoverflow.com/a/24527099/7998119
$list = [
0 => [
'id' => '1',
'parent' => '4',
],
1 => [
@MushuLeDragon
MushuLeDragon / arraySearchKey.php
Created October 30, 2019 08:36
PHP fink array key (nested array include) and position in nested array
<?php
$json = '[{"autres":1000000,"numeroBien":1},{"nature":"Résidence Principale","libelle":"Ma kaz","numeroBien":1},{"nature":"Résidence secondaire","libelle":"Ma kaz 2","numeroBien":4}]';
// Cherche la clé 'nature' dans l'array et retourne toutes les valeurs associées sous forme d'arrayList
$column = array_column($json, 'nature');
// Retourne la position (clé/key) du mot recherché
$keyArray = array_search('Résidence Principale', $column); // Retourne 0
$keyArray = array_search('Résidence secondaire', $column); // Retourne 2
@MushuLeDragon
MushuLeDragon / querySelector.js
Last active October 29, 2019 08:42
.querySelector('item') in JavaScript to select item with separator thousand
// document.querySelectorAll("item") > pour prendre tous les items
// document.querySelector("item") > pour prendre un seul item s'il est bien définit. Renvoi le premier si plusieurs
// Les items peuvent prendre différentes formes :
// balise > item | id > #item | class > .item
// [id=monId] | [class=monId] | [name=monId] | ^ le chapeau permet de dire "Tout ce qui commence par..."
// "input[name^='myName']:checked" > Pour prendre l'item input qui a un name qui commence par myName ET qui est checked
// exemple: let varr = "input[name^='myName']:checked"
// Les champs seront formattés en milliers séparés
// Reformatter la valeur pour retirer les espaces avec un .replace(/ /g,"")
{"version":1,"resource":"file://wsl%24/ubuntu/home/mushuledragon/development/en-janvier/opadd-docker/source/config/sync/field.field.node.producteur.field_producer_email.yml","entries":[{"id":"pv2m.yml","source":"searchReplace.source","timestamp":1651153137112}]}
# remove specific file from git cache
git rm --cached filename
# remove all files from git cache
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"