Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View keopx's full-sized avatar

Ruben Egiguren keopx

View GitHub Profile
@keopx
keopx / settings.local.php
Last active March 25, 2024 12:22
Drupal 8 Redis settings.local.php
<?php
/**
* Set redis configuration.
*/
/** @see: https://docs.platform.sh/frameworks/drupal8/redis.html */
if (extension_loaded('redis')) {
// Set Redis as the default backend for any cache bin not otherwise specified.
// $settings['cache']['default'] = 'cache.backend.redis';

Drupal Commerce Code Snippet

Reference

Snippets -> https://www.drupal.org/documentation/customization/snippets
A beginner's guide to using snippets -> https://www.drupal.org/node/337959
Drupal Commerce 2 Snippets -> https://gist.github.com/jakubhnilicka/00ed4492fea86571ab88a68d0e7a2158
https://gist.github.com/BBGuy/c362a30bb0dda65777b076040b14cab5
@keopx
keopx / import_gzip_drush.sh
Created July 16, 2015 18:36
Import gzipped sql using Drush
gunzip -c database.sql.gz | drush sqlc
@keopx
keopx / import.php
Last active September 20, 2023 12:47 — forked from crittermike/import.php
Importing Drupal 8 config programmatically
<?php
// Import arbitrary config from a variable.
// Assumes $data has the data you want to import for this config.
$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');
@keopx
keopx / add_translations.install
Created June 6, 2023 07:40 — forked from Erikdekamps/add_translations.install
Drupal 8 - Programmatically translate strings via hook_update_N()
/**
* Helper function for adding translations.
*
* @param array $strings
* The array with strings and their translations.
*/
function _my_module_add_translations(array $strings) {
// Get locale storage service.
$storage = \Drupal::service('locale.storage');
@keopx
keopx / create_docker_hub_images
Created April 3, 2020 16:36
Create docker hub images using docker push
docker tag 105_mariadb docker.io/keopx/mariadb:10.5
docker push keopx/mariadb:10.5
@keopx
keopx / gpg-import-and-export-instructions.md
Created January 15, 2019 08:14 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@keopx
keopx / gist:c059cf76ec46799c90a7cf29d43eb0d4
Created December 4, 2018 15:13 — forked from mrconnerton/gist:1979037
node form in ctools modal drupal 7
<?php
/*
Make Sure you include:
ctools_include('modal');
ctools_modal_add_js();
On the pages you put your link.
*/
@keopx
keopx / phpcs.xml.dist
Created September 13, 2018 08:07
drupal: /core/phpcs.xml.dist
Reworked the script to use XML instead. This works a lot better. I do have to edit the XML file to remove some invalid characters such as EOL characters which end up in the XML file.
If you install PHP CodeSniffer and the ruleset using the instructions from #10, you can then generate the coding standards report with:
$ ./modules/coder/vendor/bin/phpcs --standard=phpcs.xml --extensions=css,inc,info,install,js,module,php,profile,test,theme --ignore=core/vendor,core/assets/vendor --report=xml core/ > report.xml
You'll need to edit the XML to remove a couple of illegal characters, then finally generate the phpcs.xml file:
$ ./phpcs-generate.php report.xml > phpcs.xml
@keopx
keopx / script.pipeline
Created October 11, 2017 07:09 — forked from juampynr/script.pipeline
Jenkins job to sync Production into Develoment
String pro_domain = '2017.drupalcamp.es'
String dev_domain = 'dev.drupalcamp.es'
String drush_pro = "drush -l ${pro_domain} -r /var/www/${pro_domain}/current/web"
String drush_dev = "drush -l ${dev_domain} -r /var/www/${dev_domain}/current/web"
String files_pro = "/var/www/${pro_domain}/shared/web/sites/default/files/"
String files_dev = "/var/www/${dev_domain}/shared/web/sites/default/files/"
String rsyncOpts = '-azv --delete --exclude .php --exclude php --exclude styles'
String deploySshKeyId = 'some-key-id'
lock(resource: "dev.drupalcamp.es") {