Skip to content

Instantly share code, notes, and snippets.

View keopx's full-sized avatar

Ruben Egiguren keopx

View GitHub Profile

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.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 / 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 / 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") {
@keopx
keopx / fix-drupal8-permissions.sh
Created November 7, 2017 08:37 — forked from GreenSkunk/fix-drupal8-permissions.sh
Drupal - Bash shell script to fix Drupal 8 permissions where the PHP Handler is FastCGI.
#!/bin/bash
path=${1%/}
user=${2}
group=${2}
help="\nHelp: This script is used to fix permissions of a Drupal 8 installation in which the PHP Handler is FastCGI\nYou need to provide the following arguments:\n\t 1) Path to your drupal installation\n\t 2) Username of the user that you want to give files/directories ownership\n\nNote: This script assumes that the group is the same as the username if your PHP is compiled to run as FastCGI. If this is different you need to modify it manually by editing this script or checking out forks on GitHub.\nUsage: bash ${0##*/} drupal_path user_name\n"
echo "Refer to https://www.Drupal.org/node/244924"
@keopx
keopx / XPS-15 9560 Getting Nvidia To Work on KDE Neon
Created May 30, 2018 15:54 — forked from gggauravgandhi/XPS-15 9560 Getting Nvidia To Work on KDE Neon
[XPS 15 Early 2017 9560 kabylake] Making Nvidia Drivers + (CUDA 8 / CUDA 9 / CUDA 9.1) + Bumblebee work together on linux ( Ubuntu / KDE Neon / Linux Mint / debian )
# Instructions for 4.14 and cuda 9.1
# If upgrading from 4.13 and cuda 9.0
$ sudo apt-get purge --auto-remove libcud*
$ sudo apt-get purge --auto-remove cuda*
$ sudo apt-get purge --auto-remove nvidia*
# also remove the container directory direcotory at /usr/local/cuda-9.0/
# Important libs required with 4.14.x with Cuda 9.X
$ sudo apt install libelf1 libelf-dev
# perform a fresh install of Ubuntu 17.10
# upgrade the kernel to v4.13.10
mkdir ~/kernel-v4.13.10
cd ~/kernel-v4.13.10
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13.10/linux-headers-4.13.10-041310_4.13.10-041310.201710270531_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13.10/linux-headers-4.13.10-041310-generic_4.13.10-041310.201710270531_amd64.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13.10/linux-image-4.13.10-041310-generic_4.13.10-041310.201710270531_amd64.deb
sudo dpkg -i *.deb
@keopx
keopx / XPS-15 9560 Getting Nvidia To Work on KDE Neon
Created January 15, 2018 16:20 — forked from whizzzkid/XPS-15 9560 Getting Nvidia To Work on KDE Neon
Making Nvidia Drivers + CUDA 8 + Bumblebee work together on XPS 15 Early 2017 9560 kabylake. Ubuntu, KDE Neon, Linux Mint, debian.
# Instructions for 4.13 and cuda 9.0 RC
# If upgrading from 4.11 and cuda 8.0
$ sudo apt-get purge --auto-remove libcud*
$ sudo apt-get purge --auto-remove cuda*
$ sudo apt-get purge --auto-remove nvidia*
# also remove the container directory direcotory at /usr/local/cuda-8.0/
# Install Intel Graphics Patch Firmwares (This should reboot your system):
bash -c "$(curl -fsSL http://bit.ly/IGFWL-install)"