Skip to content

Instantly share code, notes, and snippets.

View isalmanhaider's full-sized avatar
👨‍💻
Exploring Drupal 10/11, Symphony 7, PHP 8.3, GenAI

Salman Haider isalmanhaider

👨‍💻
Exploring Drupal 10/11, Symphony 7, PHP 8.3, GenAI
View GitHub Profile
<?php
/**
* @file
* Script to help cleanup the not existing permissions from your roles.
*
* @code
* drush scr clean_permissions.php
* drush -y cex
* @endcode
*
@isalmanhaider
isalmanhaider / delete_node.php
Created July 26, 2024 13:02
delete node from content and group_content
<?php
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
use Drupal\node\Entity\Node;
// Bootstrap Drupal.
$autoloader = require_once __DIR__ . '/vendor/autoload.php';
$kernel = DrupalKernel::createFromRequest(Request::createFromGlobals(), $autoloader, 'prod');
$kernel->boot();
@isalmanhaider
isalmanhaider / php-cs-stan.php
Created July 25, 2024 04:51
Code Analysis Drupal
vendor/bin/phpcs --standard=Drupal,DrupalPractice -p ./html/modules/custom > phpcs.txt
vendor/bin/phpstan analyse -l 8 ./html/modules/custom > phpstan.txt
@isalmanhaider
isalmanhaider / find-fields.php
Created July 22, 2024 21:04
find content types containing fields
<?php
use Drupal\Core\Database\Database;
use Drush\Drush;
function find_content_types_with_fields() {
$fields_to_find = [
'field_salesforce_account_id',
'field_publish_on_csrwire',
];
@isalmanhaider
isalmanhaider / ordinal.php
Created July 20, 2024 17:39
code to determine the ordinal suffix for a given integer
function ordinal($number)
{
$ends = array(
'th',
'st',
'nd',
'rd',
'th',
'th',
'th',
@isalmanhaider
isalmanhaider / tailwind.config.js
Created July 16, 2024 11:25
tailwind config file for drupal
module.exports = {
content: [
'./{templates, components}/**/*.{twig,js}',
],
theme: {
extend: {},
},
plugins: []
}
@isalmanhaider
isalmanhaider / cron.php
Last active June 26, 2024 10:36
batch process using cron - elysia cron in Drupal
<?php
// Example of setting up a batch process in Drupal that runs programmatically without user intervention
// Define batch operations and other batch settings as required: $batch
batch_set($batch); // Initialize and register the batch with Drupal's batch processing system.
drupal_alter('batch', $batch); // Allow other modules to alter the batch settings before it runs.
$batch = &batch_get(); // Retrieve a reference to the current batch array for direct manipulation.
$batch['progressive'] = FALSE; // Set the batch to run non-progressively, suitable for automated processes.
batch_process(); // Start processing the batch without expecting a user-driven progression.
@isalmanhaider
isalmanhaider / animation-delay.md
Last active June 8, 2024 13:03
Dock animation delay on mac

to disable:

defaults write com.apple.dock autohide-delay -float 0; defaults write com.apple.dock autohide-time-modifier -int 0; killall Dock;

restore default:

defaults delete com.apple.dock autohide-delay; defaults delete com.apple.dock autohide-time-modifier; killall Dock
@isalmanhaider
isalmanhaider / drupal-logo.yml
Last active May 23, 2024 10:22
Drupal 10 logo in YAML
###################################################################################
#
# *
# /(
# ((((,
# /(((((((
# ((((((((((*
# ,(((((((((((((((
# ,(((((((((((((((((((
# ((((((((((((((((((((((((*
@isalmanhaider
isalmanhaider / gist:60224383d32b7648abd0909c1d68e6d4
Created April 5, 2024 02:33
ERROR 1273 (HY000) at line 30: Unknown collation: 'utf8mb4_0900_ai_ci'
sed -i 's/utf8mb4_0900_ai_ci/utf8mb4_general_ci/g' db.sql