Skip to content

Instantly share code, notes, and snippets.

View mecmartini's full-sized avatar

Marco Martino mecmartini

View GitHub Profile
@mecmartini
mecmartini / drupal-resize-field.php
Last active October 11, 2022 14:16
Drupal - Resize field with already existing data
<?php
/**
* Increase the length of "field_one" to 512 characters.
*/
function trimis_cordis_update_9001() {
// Resize field DB column
$database = \Drupal::database();
$database->query("ALTER TABLE node__field_one MODIFY field_one_value VARCHAR(512)");
$database->query("ALTER TABLE node_revision__field_one MODIFY field_one_value VARCHAR(512)");
...
"scripts": {
"pre-install-cmd": [
"Composer\\Config::disableProcessTimeout"
]
},
...
@mecmartini
mecmartini / data_ex.json
Created May 5, 2022 14:52
Data Example
This file has been truncated, but you can view the full file.
[
{
"Code": "AR",
"X": -12.239555323,
"Y": 14.7617557769,
"Timeseries": 1,
"Date": "2021-03-06",
"Provider": "CERES",
"Parameter": "Aldrin",
"Media": "Water",
@mecmartini
mecmartini / content_synchronizer-fix_STATUS_PERMANENT.patch
Created February 25, 2022 16:19
drupal_content_synchronizer-fix_STATUS_PERMANENT
diff --git a/src/Base/JsonWriterTrait.php b/src/Base/JsonWriterTrait.php
index c4481f0..4116395 100644
--- a/src/Base/JsonWriterTrait.php
+++ b/src/Base/JsonWriterTrait.php
@@ -35,7 +35,7 @@ trait JsonWriterTrait {
File::create([
'uri' => $uri,
- 'status' => FileInterface::STATUS_PERMANENT,
+ 'status' => defined('FILE_STATUS_PERMANENT') ? FILE_STATUS_PERMANENT : FileInterface::STATUS_PERMANENT,
@mecmartini
mecmartini / javascript-set-with-objects.js
Last active January 6, 2022 13:48
Javascript Set with objects
const data = [
{a: 1, b: 2, c: 3},
{a: 4, b: 5, c: 6},
{a: 1, b: 2, c: 3},
{a: 4, b: 5, c: 6},
];
const dataSetRaw = new Set();
data.map( (item) => (
dataSetRaw.add(
@mecmartini
mecmartini / slack-github-subscribe-all.txt
Created January 5, 2022 19:28
Subscribe Slack to all branches in GitHub
/github subscribe owner/repo commits:all
@mecmartini
mecmartini / fix_oe_theme_preprocess_search_input_text.patch
Last active November 18, 2021 16:31
fix_oe_theme_preprocess_search_input_text
diff --git a/oe_theme.theme b/oe_theme.theme
index 2194d385..28cd20d6 100644
--- a/oe_theme.theme
+++ b/oe_theme.theme
@@ -1159,7 +1159,7 @@ function _oe_theme_preprocess_search_input_text(array $element): array {
// Process element attributes into an ECL input array.
$ecl_array = [
'id' => $element['#attributes']['id'],
- 'name' => $element['#attributes']['name'],
+ 'name' => isset($element['#attributes']['name']) ? $element['#attributes']['name'] : FALSE,
@mecmartini
mecmartini / http-trace.sh
Created August 27, 2021 15:47
Check HTTP Trace
#!/bin/sh
curl --insecure -v -X TRACE https://trimis.docker.localdev -H "Cache-Control: no-cache, no-store, must-revalidate" -H "Pragma: no-cache" -H "Expires: 0"
@mecmartini
mecmartini / ajax-facets-do-not-support-range-slider.patch
Created July 21, 2021 16:07
ajax-facets-do-not-support-range-slider.patch
diff --git a/js/facets-views-ajax.js b/js/facets-views-ajax.js
index e0e4f2c..7d9f7ea 100644
--- a/js/facets-views-ajax.js
+++ b/js/facets-views-ajax.js
@@ -39,10 +39,10 @@
// Update view on summary block click.
if (updateFacetsSummaryBlock() && (facetId === 'facets_summary_ajax')) {
- $('[data-drupal-facets-summary-id=' + facetSettings.facets_summary_id + ']').children('ul').children('li').once().click(function (e) {
+ $('[data-drupal-facets-summary-id=' + facetSettings.facets_summary_id + ']').find('a').once('facets_summary_ajax_link').click(function (e) {
@mecmartini
mecmartini / fix-cookie-consent-page-url.patch
Created July 1, 2021 16:07
fix-cookie-consent-page-url