Skip to content

Instantly share code, notes, and snippets.

View juampynr's full-sized avatar

Juampy NR juampynr

View GitHub Profile
@juampynr
juampynr / bash.sh
Created January 2, 2024 21:44
Prettify JSON string in command line
echo '{"a":"b"}' | jq -R -r '. as $line | try fromjson catch $line'
# Prints
# {
# "a": "b"
# }
@juampynr
juampynr / gist:2a9bc7fde571d25daf819ddf59e40fc8
Created December 19, 2023 22:23
Drupal 7 Drush print a field_collection value
drush php-eval "print_r(entity_load('field_collection_item', array(803409))[803409]->field_product_url)";
colima start --cpu 6 --memory 12 --disk 250 --mount-type=sshfs
@juampynr
juampynr / config.yml
Last active February 26, 2021 01:10
Sample .tugboat/config.yml for a Drupal 8 contrib project (webform). Inspired by https://github.com/q0rban/tugboat-drupal
services:
php:
image: q0rban/tugboat-drupal:8.8
default: true
http: false
depends: mysql
commands:
update: |
set -eux
# Check out a branch using the unique Tugboat ID for this repository, to
@juampynr
juampynr / extract_fields.php
Created July 17, 2020 16:43
Drupal 7: script to extract all fields
<?php
/**
* Drupal 7 field extract script.
*
* Extracts all fields into a csv file so it can be open with Google Spreadsheet, LibreOffice, or Excel.
*
* Usage:
* 1. Save this file to the docroot.
* 2. run drush php-script exctract_fields.php
@juampynr
juampynr / query.sql
Created July 14, 2020 13:44
Drupal 7: Extract all fields per content type
select fci.entity_type, fci.bundle, fci.field_name, fc.type, fc.module
from field_config_instance fci
inner join field_config fc on fc.id = fci.field_id
order by fci.entity_type ASC, fci.bundle ASC, fci.field_name ASC;
@juampynr
juampynr / RoboFile.php
Last active October 9, 2021 10:07
Drupal 8 common migration tasks
<?php
/**
* Command line tasks.
*
* @codingStandardsIgnoreStart
* @codeCoverageIgnore
* @SuppressWarnings(PHPMD)
*/
class RoboFile extends \Robo\Tasks {
@juampynr
juampynr / commands.sh
Created October 30, 2018 23:26
Tweak a migration group and commit the changes
# 1. Delete the migration group.
# This command needs the patch at https://www.drupal.org/project/migrate_tools/issues/2977501#comment-12640911
drush migrate:delete-group migrate_drupal_7
# 2. Recreate the migration group.
drush migrate:upgrade --legacy-db-key=drupal7 --legacy-root=sites/default/files --configure-only
# 3. Export the configuration, then review and commit the changes.
drush config:export -y
@juampynr
juampynr / bash.sh
Last active October 30, 2018 23:16
Set up Drupal 8 and run the first migration
# 1. Download dependencies.
composer require drupal/migrate_tools:4.x-dev drupal/migrate_upgrade:3.x-dev drupal/migrate_plus:4.x-dev
# 2. Enable modules.
drush en -y migrate_tools,migrate_upgrade,migrate_plus
# 3. Generate a migration group.
drush migrate:upgrade --legacy-db-key=drupal7 --legacy-root=/var/www/drupal/drupal7 --configure-only
# 4. Export group into configuration and commit the files. Then review and commit the files.
@juampynr
juampynr / mymodule.info
Last active August 31, 2023 05:48
Drupal 7 Views 3 custom filter handler
dependencies[] = ctools
; Views Handlers
files[] = views/mymodule_handler_filter_myfiltername.inc