Skip to content

Instantly share code, notes, and snippets.

@sonnykt
sonnykt / aws-ses-identity-audit.md
Last active December 29, 2025 08:46
AWS SES Identity audit

PHP Script

<?php

function aws(string $command) : array|false {
  $aws_command = 'aws --no-cli-pager --no-paginate --output json ' . $command;
  $output = [];
  $result_code = NULL;

  if (exec($aws_command, $output, $result_code)) {
@sonnykt
sonnykt / drupal-debug-solr.md
Created October 8, 2025 05:18
Drupal - Debug Search API Solr search
$index = \Drupal\search_api\Entity\Index::load('solr_index');
$query = $index->query();
$parse_mode = \Drupal::service('plugin.manager.search_api.parse_mode')->createInstance('direct');
$query->setParseMode($parse_mode);
$query->keys('keywords to search');
$results = $query->execute();
$items = $results->getResultItems();
@sonnykt
sonnykt / drupal-lagoon-fix-collation-mismatch-mariadb-mysql8.md
Created July 15, 2025 01:14
Drupal/Lagoon - Fix collation mismatch between MariaDB and MySQL8

Prerequisites

Database settings in settings.php

// Default database configuration.
$databases = [
  'default' =>
    [
      'default' =>
        [
          // ...
@sonnykt
sonnykt / aws_iam_secret_to_smtp_password.md
Last active January 2, 2025 14:51 — forked from damusix/aws_iam_secret_to_smtp_password.md
Convert AWS IAM credentials to AWS SMTP credentials

Convert AWS IAM credentials to AWS SMTP credentials

If you do, or want to, use AWS to deploy your apps, you will end up using AWS SES via SMTP when you're launching an app that sends out emails of any kind (user registrations, email notifications, etc). For example, I have used this configuration on various Ruby on Rails apps, however, it is just basic SMTP configurations and crosses over to any framework that supports SMTP sendmail.

There are two ways to go about this:

Luckily, you found this MD file and the NOT SO EASY WAY is suddenly copy-pasta... sudo yum....

@sonnykt
sonnykt / drupal-mysql-convert-collation-all-tables.md
Last active October 27, 2025 08:30
Drupal 10 - Convert collation of all tables
$database = \Drupal::database();
$charset = $database->getConnectionOptions()['charset'] ?? 'utf8mb4';
$collation = $database->getConnectionOptions()['collation'] ?? 'utf8mb4_general_ci';

echo PHP_EOL;

$tables = $database->query('SHOW TABLE STATUS where Collation <> :collation', [':collation' => $collation ])->fetchAllAssoc('Name');
if (count($tables)) {
  echo 'Converting collation of ', count($tables), ' tables to ', $collation, PHP_EOL;
@sonnykt
sonnykt / drupal-migrate-plus-simulate-http-fetcher-plugin.md
Last active September 5, 2024 04:54
Drupal 10 - Migration - Simulate migrate_plus HTTP fetcher plugin
$entity_type_manager = \Drupal::entityTypeManager();
$storage = $entity_type_manager->getStorage('migration');
$migration_plugin_manager = \Drupal::service('plugin.manager.migration');

$migration_id = '...';
$migration = $storage->load($migration_id);
$migration_plugin = $migration_plugin_manager->createInstance($migration_id, $migration->toArray());

$source_plugin = $migration_plugin->getSourcePlugin();
@sonnykt
sonnykt / drupal-sdp-debug-bay-elasticsearch.md
Last active August 30, 2024 10:53
Drupal - SDP - Debug Bay Elasticsearch from the CLI container

Get indices

curl -sXGET  "http://${SEARCH_AUTH_USERNAME}:${SEARCH_AUTH_PASSWORD}@${SEARCH_HASH}.${SEARCH_URL}/_cat/indices?format=json&pretty=true"

curl -sXGET  "http://${SEARCH_AUTH_USERNAME}:${SEARCH_AUTH_PASSWORD}@${SEARCH_HASH}.${SEARCH_URL}/_cat/indices/${SEARCH_HASH}--${SEARCH_INDEX}node?format=json&pretty=true"

Get ingest pipelines

curl -s  "http://${SEARCH_AUTH_USERNAME}:${SEARCH_AUTH_PASSWORD}@${SEARCH_HASH}.${SEARCH_URL}/_ingest/pipeline?pretty=true"
@sonnykt
sonnykt / drupal-check-node-view-display-with-panelizer.md
Last active August 29, 2024 03:37
Drupal 10 - Check node view displays using Panelizer
use \Drupal\node\Entity\NodeType;

$panelizer = [];
$repo = \Drupal::service('entity_display.repository');

$types = NodeType::loadMultiple();
foreach (array_keys($types) as $node_type) {
  $viewmode_options = $repo->getViewModeOptionsByBundle('node', $node_type);
 foreach (array_keys($viewmode_options) as $viewmode_option) {
@sonnykt
sonnykt / drupal-10-debug-elasticsearch-connector.md
Created July 26, 2024 03:39
Drupal 10 - debug Elasticsearch connector
use Drupal\search_api\Entity\Index;

$index = Index::load('node')
$server = $index->getServerInstance()
$backend = $server->getBackend()
$backend->getCluster()

$cluster_manager = \Drupal::service('elasticsearch_connector.cluster_manager')
@sonnykt
sonnykt / drupal-10-decode-css-js-aggr-include.md
Last active July 26, 2024 03:36
Drupal 10 - decode CSS/JS aggregated include string
use Drupal\Component\Utility\UrlHelper;

$include = 'eJx...';
explode(',',UrlHelper::uncompressQueryParameter($include));