Skip to content

Instantly share code, notes, and snippets.

View flocondetoile's full-sized avatar

Flocon de toile flocondetoile

View GitHub Profile
@flocondetoile
flocondetoile / macos_high_sierra_apache_php_brew_2018.md
Created September 25, 2018 13:49 — forked from karlhillx/macos_high_sierra_apache_php_brew_2018.md
macOS High Sierra Setup: Homebrew + Apache + PHP + MariaDB + SSL

macOS High Sierra Setup: Homebrew + Apache + PHP + MariaDB + SSL

Homebrew Installation

First let's install Homebrew.

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

@flocondetoile
flocondetoile / MigrateAsymmetricToSymmetric.php
Created January 26, 2019 09:21 — forked from nikunjkotecha/MigrateAsymmetricToSymmetric.php
Code to migrate content from Asymmetric to Symmetric translations for paragraphs.
<?php
namespace Drupal\module\Helper;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Logger\LoggerChannelInterface;
use Drupal\paragraphs\Entity\Paragraph;
/**
<?php
/**
* @When I switch to the frame by selector "[title=:arg1]"
*/
public function switchToIFrameFromSelector($iframeSelector) {
$function = <<<JS
(function(){var iframe = document.querySelector("$iframeSelector");iframe.name = "iframeToSwitchTo";})()
JS;
try {
@flocondetoile
flocondetoile / ReferenceLastDate.php
Created February 7, 2019 14:30 — forked from DuaelFr/ReferenceLastDate.php
Drupal 8 Search API processor example
<?php
namespace Drupal\hc_core\Plugin\search_api\processor;
use Drupal\node\Entity\Node;
use Drupal\search_api\Datasource\DatasourceInterface;
use Drupal\search_api\IndexInterface;
use Drupal\search_api\Item\ItemInterface;
use Drupal\search_api\Processor\ProcessorPluginBase;
use Drupal\search_api\Processor\ProcessorProperty;
@flocondetoile
flocondetoile / progressbar.css
Created February 24, 2019 11:23 — forked from kmelve/progressbar.css
jQuery snippet for making a progressbar for reading position in browser.
#progresswrapper {
position: fixed;
top: 0px;
height: 2px;
width: 100%;
z-index: 1000;
}
#progressbar {
top: 0;
position: fixed;
@flocondetoile
flocondetoile / progress.html
Created February 24, 2019 11:24 — forked from hlorand/progress.html
jQuery reading position indicator progress bar
<!doctype html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script>
$(document).ready(function(){
var getMax = function(){
@flocondetoile
flocondetoile / module.php
Created March 11, 2019 13:20 — forked from opi/module.php
Drupal 8 Custom form mode
<?php
/**
* Implements hook_entity_form_display_alter().
*/
function MY_MODULE_entity_form_display_alter(&$form_display, array $context) {
if ($context['entity_type'] == 'node' && $context['bundle'] == 'MY_BUNDLE') {
$current_user = \Drupal::currentUser();
if ($current_user->hasPermission('CUSTOM PERMISSION')) {
$storage = \Drupal::entityManager()->getStorage('entity_form_display');
@flocondetoile
flocondetoile / EditorImageStyle.php
Created June 26, 2019 23:10 — forked from mortenson/EditorImageStyle.php
A custom Drupal 8 filter plugin to use an image style for image embedss custom Drupal 8 filter plugin to use an image style for image embeds. A custom Drupal 8 filter plugin to use an image style for image embeds.
<?php
namespace Drupal\ppdx_editor\Plugin\Filter;
use Drupal\Component\Utility\Html;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Image\ImageFactory;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\file\FileInterface;
use Drupal\filter\FilterProcessResult;
@flocondetoile
flocondetoile / import.php
Created November 29, 2019 23:33 — forked from crittermike/import.php
Importing Drupal 8 config programmatically
<?php
// Import arbitrary config from a variable.
$config = \Drupal::service('config.factory')->getEditable('filter.format.basic_html');
$config->setData($data)->save();
// Or, re-import the default config for a module or profile, etc.
\Drupal::service('config.installer')->installDefaultConfig('module', 'my_custom_module');
// Or, import YAML config an arbitrary directory.
#!/bin/bash
function greenecho {
echo "" && echo -e "\e[30;48;5;82m ✔ $1 \e[0m"
}
function orangeecho {
echo "" && echo -e "\e[30;48;5;208m ⚠ $1 \e[0m"
}
# Get document root path