Skip to content

Instantly share code, notes, and snippets.

View MatthieuScarset's full-sized avatar
🤷‍♂️
Probably me

MattGyver MatthieuScarset

🤷‍♂️
Probably me
View GitHub Profile
@MatthieuScarset
MatthieuScarset / dappcamp_challenge_galacticDTH.php
Created December 2, 2021 08:53
try to solve GalacticDTH challenge
<?php
/*
* Complete the 'getMinClicks' function below.
*
* The function is expected to return an INTEGER.
* The function accepts following parameters:
* 1. INTEGER lowest_channel
* 2. INTEGER highest_channel
* 3. INTEGER_ARRAY blocked_channels
@MatthieuScarset
MatthieuScarset / config_entity_type_is_a.php
Created October 18, 2021 05:52
Drupal - Check if a config entity type is a content entity type (or fieldable entity type...etc)
<?php
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
$entity_types = \Drupal::service('entity_type.manager')->getDefinitions();
/** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity_type */
foreach ($entity_types as $entity_type) {
// Stop now if entity type is not fieldable.
@MatthieuScarset
MatthieuScarset / basefields.php
Last active September 22, 2021 13:02
Drupal 8 - Programatically create new fields
<?php
/**
* Implements hook_entity_base_field_info().
*/
function mymodule_entity_base_field_info(EntityTypeInterface $entity_type) {
if ($entity_type->id() == 'user') {
$fields = [];
$default_field_definition = [
@MatthieuScarset
MatthieuScarset / entity_autocomplete_views.php
Created July 19, 2021 11:13
Drupal selection handlers views
$args = [];
$form['user_in_charge'] += [
'#title' => t('Entity autocomplete'),
'#type' => 'entity_autocomplete',
'#selection_handler' => 'views',
'#selection_settings' => [
'view' => [
'view_name' => 'view_machine_name',
'display_name' => 'entity_reference',
This post links my 3Box profile to my Github account! Web3 social profiles by 3Box.
✅ did:3:bafyreicudk4v2rlu4lt2ip7oi4kssudctl22j2p3ojqnekz7c3xcqpwmje ✅
Create your profile today to start building social connection and trust online at https://3Box.io/
@MatthieuScarset
MatthieuScarset / .lando.yml
Created December 13, 2020 20:23
Lando (+3.0) with XDebug (WordPress recipe)
name: wordpress
recipe: wordpress
services:
appserver:
webroot: .
xdebug: debug
config:
php: .vscode/php.ini
tooling:
install:wordpress:
@MatthieuScarset
MatthieuScarset / reorder-form-actions.php
Created July 14, 2020 14:17
Drupal - Order array by another array
<?php
// Reorder actions.
$order = [
'previous',
'reset',
'submit',
'preview_next',
];
@MatthieuScarset
MatthieuScarset / fixpermissions
Created July 19, 2018 02:36
Fix permissions on Docker-based env with Drupal
//Files should be `644` I think
find . -type f -exec chmod u=rw,g=r,o=r {} \;
// Folders should be `executable
find . -type d -exec chmod u=rwx,g=rx,o=rx {} \;
@MatthieuScarset
MatthieuScarset / reset_admin_password.sql
Created June 19, 2018 22:45
SQL query to reset admin password (admin / admin)
UPDATE users SET pass ='$S$DmWStgEK4Uwao1iqvQeHJibfO6bE/x9EQ0A40qqSrV6T24UW9uAd' WHERE uid = 1;
// Colors
$black: #000000;
$grey: #f4f4f4;
$pale-grey: #6c94a3;
$white: #ffffff;
$navy: #004057;
$blue: #00aac0;
$pale-blue: #eff7f9;
$purple: #5d1f84;
$pink: #e461bc;