Skip to content

Instantly share code, notes, and snippets.

@opi
opi / getWithFallback.php
Last active February 21, 2024 09:47
iea_migrate_partners.yml
<?php
namespace Drupal\iea_migrate\Plugin\migrate\process;
use Drupal\migrate\MigrateException;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
@opi
opi / mailhog.md
Last active January 27, 2023 23:19
Install and configure MailHog (for Drupal) with a nice systemd unit and apache reverse proxy

MailHog (for Drupal) on Debian Stretch

MailHog is a nice mail testing tool for developers.

Website: https://github.com/mailhog/MailHog

Installation

Download the latest release on your local machine

@opi
opi / install_nodejs_debian_jessie.md
Last active January 18, 2023 00:11
How to install nodejs on Debian Jessie

How to install nodejs on Debian Jessie

Pre-requisites

apt install apt-transport-https curl

Add GPG key for signing packages

curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
@opi
opi / drupal_dialog_buttonpane.md
Created April 26, 2021 11:14
Drupal: Do not put buttons into modal/dialog button pane
@opi
opi / BlogAuthorComputed.php
Created October 21, 2021 12:22
Computed field example for Drupal 8/9
<?php
// in MY_MODULE/src/ComputedField/BlogAuthorComputed.php
namespace Drupal\MY_MODULE\ComputedField;
use Drupal\Core\Field\EntityReferenceFieldItemList;
use Drupal\Core\TypedData\ComputedItemListTrait;
class BlogAuthorComputed extends EntityReferenceFieldItemList {
@opi
opi / my_module.php
Last active November 11, 2021 14:46
Extra field example for drupal 8/9
<?php
/**
* Implements hook_entity_extra_field_info().
*/
function MYMODULE_entity_extra_field_info() {
$extra = [];
foreach (NodeType::loadMultiple() as $bundle) {
@opi
opi / ViewsPagerAsBlock.php
Created September 28, 2021 11:41
Drupal Views pager as block
<?php
namespace Drupal\mymodule\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\views\Views;
/**
@opi
opi / d8_contrib_update.sh
Created July 21, 2021 12:08
D8/D9 : Auto update contrib with composer and Git commit
#!/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"
}
greenecho "Here we are: "$(pwd)
@opi
opi / skype_on_debian_stretch.md
Last active July 1, 2021 21:56
Install Skype on Debian Stretch

Install Skype on Debian Stretch

Install the GPG key:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1F3045A5DF7587C3

Ensure apt is set up to work with https sources:

sudo apt-get install apt-transport-https