Skip to content

Instantly share code, notes, and snippets.

View mecmartini's full-sized avatar

Marco Martino mecmartini

View GitHub Profile
@mecmartini
mecmartini / bump_oe_corporate_blocks_conflict_version.patch
Created June 15, 2021 17:42
bump_oe_corporate_blocks_conflict_version.patch
diff --git a/composer.json b/composer.json
index 6687f522..0d172c98 100644
--- a/composer.json
+++ b/composer.json
@@ -63,7 +63,7 @@
"We explicitly require consolidation/annotated-command to allow lower 'composer update --prefer-lowest' to complete successfully."
],
"conflict": {
- "openeuropa/oe_corporate_blocks": "<2.1.0"
+ "openeuropa/oe_corporate_blocks": "<3.0.0"
@mecmartini
mecmartini / d7-delete-node.php
Created May 29, 2021 14:24
Drupal 7 - Programmatically delete nodes
<?php
$results = db_select('node', 'n')
->fields('n', ['nid'])
->condition('type', 'organisation')
->condition('nid', 35401, '<>')
->execute()
->fetchAll();
dpm($results);
@mecmartini
mecmartini / openeuropa-oe_theme-fix-pager.patch
Created May 6, 2021 09:11
peneuropa/oe_theme fix pager
diff --git a/oe_theme.theme b/oe_theme.theme
index dc0f98df..d8d0ddfe 100644
--- a/oe_theme.theme
+++ b/oe_theme.theme
@@ -444,6 +444,9 @@ function oe_theme_preprocess_pager(array &$variables): void {
$route_name = $variables['pager']['#route_name'];
$route_parameters = $variables['pager']['#route_parameters'] ?? [];
global $pager_page_array, $pager_total;
+ if (!$pager_total) {
+ return;
@mecmartini
mecmartini / fix-custom-body-class.patch
Last active May 11, 2021 16:20
fix-custom-body-class
diff --git a/custom_body_class.info.yml b/custom_body_class.info.yml
index 85b48ca..9c9683d 100644
--- a/custom_body_class.info.yml
+++ b/custom_body_class.info.yml
@@ -2,3 +2,4 @@ type: module
name : Custom body class
description : Adds custom class/es
core : 8.x
+core_version_requirement: ^8 || ^9
\ No newline at end of file
@mecmartini
mecmartini / drupal-test-csv.php
Created February 11, 2021 15:04
Drupal - Test CSV
<?php
namespace Drupal\Tests\tablefield\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Simple test to ensure that a field can be created.
*
* @group tablefield
@mecmartini
mecmartini / drupal-and-react-field-formatter.php
Created February 4, 2021 19:39
Drupal and React - Field Formatter
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = [];
$id = $items->getEntity()->id();
# Generate a wrapper to use as dom root to attach the React component.
$field_name = $this->fieldDefinition->getItemDefinition()->getFieldDefinition()->getName();
$wrapper_id = 'drupal-and-react-app-' . $field_name .'-'. $id;
@mecmartini
mecmartini / drupal-and-react-library.php
Created February 4, 2021 18:46
Drupal and React - Create library
<?php
/**
* Implements hook_library_info_build().
*/
function drupal_and_react_library_info_build() {
# Load current module path.
$module = \Drupal::moduleHandler()->getModule('drupal_and_react');
$module_path = $module->getPath();
@mecmartini
mecmartini / oe_webtools_libraries_over_https.patch
Last active January 29, 2021 15:23
openeuropa/oe_webtools load libraries over https patch
diff --git a/modules/oe_webtools_cookie_consent/oe_webtools_cookie_consent.libraries.yml b/modules/oe_webtools_cookie_consent/oe_webtools_cookie_consent.libraries.yml
index 001751f..a1794de 100644
--- a/modules/oe_webtools_cookie_consent/oe_webtools_cookie_consent.libraries.yml
+++ b/modules/oe_webtools_cookie_consent/oe_webtools_cookie_consent.libraries.yml
@@ -2,4 +2,4 @@ oe_webtools_cookie_consent.cck:
version: 1.x
header: true
js:
- //ec.europa.eu/wel/cookie-consent/consent.js: { type: external, minified: false }
+ https://ec.europa.eu/wel/cookie-consent/consent.js: { type: external, minified: false }
@mecmartini
mecmartini / setup-dnmasq-for-localdev-ubuntu.md
Last active January 25, 2021 11:10
Setup Dnsmasq for .localdev (Ubuntu)

Setup Dnsmasq for .localdev (Ubuntu)

Ubuntu comes with systemd-resolve which you need to disable since it binds to port 53 which will conflict with Dnsmasq port.

Run the following commands to disable the service:

sudo systemctl disable systemd-resolved
sudo systemctl stop systemd-resolved
@mecmartini
mecmartini / dnsmsq-macos-install-and-setup.md
Last active December 23, 2021 16:21
Dnsmasq - MacOs install and setup

Dnsmasq - MacOs install and setup

Requirements

Install

Run brew install dnsmasq.

Setup