Skip to content

Instantly share code, notes, and snippets.

View vyspiansky's full-sized avatar

Ihor Vyspiansky vyspiansky

View GitHub Profile
@vyspiansky
vyspiansky / error_messages_visibility_in_drupal_10.md
Last active March 20, 2025 09:09
Visibility of error messages in Drupal 10

To configure the error messages visibility, set an appropriate configuration in the settings.php file

// Show all error messages, including notices and coding standards warnings.
$config['system.logging']['error_level'] = 'verbose';

File: /path/to/docroot/sites/<SITE_NAME>/settings.php.

Then clear the Drupal cache.

@vyspiansky
vyspiansky / common_iife_pattern.md
Last active March 20, 2025 09:10
Common Immediately Invoked Function Expression (IIFE) pattern

One of the ways to create an immediately executed anonymous function

(function() {
    'use strict';
    
    // ...
})();
@vyspiansky
vyspiansky / remove_nodes_via_drush.md
Last active November 28, 2024 13:08
Use Drush to remove nodes in Drupal 10

Drush version: 12.3.0.0.

Remove nodes with a specific bundle

If you have a large number of nodes and want to process them in batches, you can use the --chunk option:

drush entity:delete node --bundle=article --chunks=50
@vyspiansky
vyspiansky / uuid-crc-test.md
Last active November 24, 2024 11:03
UUID Field vs CRC Index Querying

Performance Comparison: UUID Field vs CRC Index Querying

  • MySQL version: 5.7.29
SELECT * FROM uuid_crc_test WHERE uuid = 'c3830c70-a8e6-11ef-b990-0242ac180005';
Number of records Execution times (ms)
@vyspiansky
vyspiansky / mysql-queries-using-timestamp-field.md
Last active October 25, 2024 09:43
MySQL queries using timestamp integer field

MySQL queries for selecting records based on different time criteria using a timestamp integer field named created.

Get records newer than today's 10 AM

SELECT
  *
FROM
  your_table
WHERE
@vyspiansky
vyspiansky / git-rebase-by-default.md
Created September 12, 2024 09:10
Git rebase by default

This technique updates your local branch and then "replays" your changes on top, effectively putting your changes at the head of the branch.

Enable

git config --global pull.rebase true

Disable

@vyspiansky
vyspiansky / coding_programming_quotes.md
Last active March 20, 2025 09:08
Coding & Programming Quotes

“There are only two hard things in Computer Science: cache invalidation and naming things.”

— Phil Karlton

“One of life's greatest sources of satisfaction is the knowledge that something you have created is contributing to the progress or welfare of society.”

— Donald Knuth

@vyspiansky
vyspiansky / clear-older-recent-log-messages-in-drupal.sql
Last active September 9, 2024 15:00
Clear older recent log messages in Drupal 10, retaining only the last 500
-- Remove all watchdog's records from a MySQL table except for the last 500.
DELETE FROM `watchdog`
WHERE wid NOT IN (
SELECT wid
FROM (
SELECT wid
FROM `watchdog`
ORDER BY wid DESC
LIMIT 500
@vyspiansky
vyspiansky / plain_sql_query_in_drupal.php
Last active September 11, 2024 15:57
Retrieve a plain SQL query from a Select query object in Drupal 10
<?php
use Drupal\Core\Database\Database;
use Drupal\Core\Database\Query\SelectInterface;
/**
* Returns a plain SQL query from a Select query object.
*/
function get_plain_sql_query(SelectInterface $query): string
{
@vyspiansky
vyspiansky / enable-xhprof-in-lando.md
Last active August 27, 2024 19:57
Enable XHProf in Lando

.lando.yml

name: "..."
recipe: lamp
config:
  php: "8.1"
  xdebug: false
services:
 appserver: