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 / 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 / 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 / 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 / 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)"