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 / fix-docker-permissions
Last active August 30, 2017 17:53
Allow local user to edit files when chown to 82:alpine-www-data
sudo chown -R 82:alpine-www-data .
sudo setfacl -dR -m u:$(whoami):rwX -m u:21:rX -m u:82:rwX .
sudo setfacl -R -m u:$(whoami):rwX -m u:21:rX -m u:82:rwX .
@MatthieuScarset
MatthieuScarset / pom.xml
Created June 10, 2017 10:43
SonarQube pom.xml example for Drupal 7 project (mvn sonar:sonar)
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>APPNO</groupId>
<artifactId>AVALERE</artifactId>
<name>AVAL003</name>
<version>1.0</version>
<packaging>pom</packaging>
<build>
<!--
Quality Profile: Drupal
@MatthieuScarset
MatthieuScarset / _menu.hamburger.scss
Last active May 17, 2017 13:21
My SCSS hamburger menu with transition.
// Hamburger menu SCSS
/*
<a href="#" class="main-menu-btn js-main-menu-toggle">
<span class="wrapper">
<span class="bar top"></span>
<span class="bar middle"></span>
<span class="bar bottom"></span>
</span>
</a>
*/
@MatthieuScarset
MatthieuScarset / paragraphs.install
Created April 24, 2017 15:37
Programmatically create Paragraph Types (bundles).
<?php
/**
* Implements hook_install().
*/
function MYMODULE_install() {
// Create new Bundle.
$bundle = new stdClass();
$bundle->name = 'Test Bundle'; // user friendly label
$bundle->bundle = 'paragraphy_test'; // machine name
@MatthieuScarset
MatthieuScarset / .bash_aliases
Last active December 25, 2017 14:43
My custom bash aliases
# Rexecute last cmd as root
alias fuck='$(history -p \!\!)'
# Folders related aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Typo (because I type quick and dirty...)
alias cc='clear'
@MatthieuScarset
MatthieuScarset / docker-compose.yml
Created April 19, 2017 09:58
Drupal Composer Docker Compose file
version: "2"
services:
mariadb:
image: wodby/mariadb:10.1-2.0.0
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: drupal
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
@MatthieuScarset
MatthieuScarset / README.md
Created April 17, 2017 15:11 — forked from skwashd/README.md
Drupal git pre-commit hook

This pre-commit hook is designed to be used for Drupal 7 and 8 sites.

Download the pre-commit file. Save it as .git/hook/pre-commit in your git repo. You need to ensure that the file is executable.

If you want this to be added to all new projects automatically, add it to your git init templates.

To install and PHP CodeSniffer for Drupal, please read the official documentation.

To see this working checking out this short YouTube video.

// Get element offset from top of page
function getOffset(el) {
el = el.getBoundingClientRect();
return {
left: el.left + window.scrollX,
top: el.top + window.scrollY
};
};
@MatthieuScarset
MatthieuScarset / custom_block.module
Created April 6, 2017 18:21
Drupal 7 - Custom Block example
<?php
/**
* Implements hook_block_info().
*/
function custom_block_block_info() {
$blocks = array();
$blocks['states_map'] = array(
'info' => t('States map'),
);
@MatthieuScarset
MatthieuScarset / d7-add-entity-view-mode.md
Created April 5, 2017 20:10 — forked from swichers/d7-add-entity-view-mode.md
Drupal 7 - Programmatically add view mode to entity

In a module file:

This will enable an additional view mode for use on the specified entity type(s). Many examples will show the custom settings here being set to TRUE. If TRUE is used then that view mode is added to all entities of the specified type regardless of if it should be on the bundle or not.

/**
 * Implements hook_entity_info_alter().
 */
function HOOK_entity_info_alter(&$entity_info) {