Skip to content

Instantly share code, notes, and snippets.

@weaver299
weaver299 / query_all.sh
Last active November 19, 2021 15:47
Pantheon - run db query on all sites on an upstream
#!/usr/bin/env bash
# Example usage:
# echo "select distinct type, count(*) from node group by 1 order by 2 desc;" > node_counts.sql
# ./query_all.sh node_counts.sql live | tee node_counts.txt
UPSTREAM='asdfasdf-asdf-asdf-asdf-asdfasdfasdf';
# Check command line arguments
if [[ -z $1 ]]; then
@weaver299
weaver299 / backup_fresh.sh
Last active December 4, 2020 17:08
Pantheon - check site backup freshness
#!/usr/bin/env bash
if [[ -z $1 ]]; then
echo; echo "Usage: $0 <site.env>";
echo; echo;
exit 1;
fi
# MacOS compatibility....
if [[ "$OSTYPE" == *"darwin"* ]]; then
#!/usr/bin/env bash -e
if [[ -z $1 ]]; then
echo;
echo "Usage: $0 <pantheon_site>";
echo;
echo;
exit;
fi
function ffclip {
# some links about calculating durations in bash
# https://stackoverflow.com/questions/8903239/how-to-calculate-time-difference-in-bash-script
# http://giantdorks.org/alain/script-to-calculate-clip-duration-from-startstop-times/
# http://giantdorks.org/alain/bash-script-to-calculate-duration-between-two-time-stamps-and-also-report-minutes-hours-days-weeks-months-and-years/
# http://www.daveeddy.com/2014/06/29/human-readable-duration-in-bash/
# https://gist.github.com/bezhermoso/2d61cf44646c2f07c0820d81c644c1de
if [ "$#" -lt 3 ]; then
echo "Usage: ffclip <file> <start> <finish>";
id: media_youtube
label: Migrate Youtube Videos
description: Migrate Youtube Videos
migration_group: media
migration_tags:
- Custom
source:
plugin: file_entity
id: users
label: User Migration
source:
key: source_db
plugin: d7_user
destination:
plugin: entity:user
process:
<?php
namespace Drupal\asc_migrate_standardd7\Plugin\migrate\source;
use Drupal\Core\Database\Query\Condition;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
/**
* Drupal 7 file_entity source from database.
*
id: media_images
label: Migrate image file entities
description: Migrate image file entities
migration_group: media
migration_tags:
- Custom
source:
plugin: file_entity
id: media_files
label: Migrate managed files
description: Migrate managed files
migration_group: media
migration_tags:
- Drupal 7
- Content
migration_dependencies:
required:
@weaver299
weaver299 / Dfence.php
Last active January 22, 2019 19:27
defensive programming
<?php
if (empty($json_object->fields) && empty($json_object->field_deltas)) {
echo "Embedded Reference -- fields NO, field_deltas NO.\n";
print_r($json_object);
die();
}
else if (!empty($json_object->fields) && empty($json_object->field_deltas)) {
echo "Embedded Reference -- fields YES, field_deltas NO.\n";
}