Skip to content

Instantly share code, notes, and snippets.

View zuhairkareem's full-sized avatar
🏠
Working from home

zuhairkareem

🏠
Working from home
View GitHub Profile
@zuhairkareem
zuhairkareem / search_partial_string_array.php
Last active November 3, 2024 03:12
Search partial string in an array in PHP
<?php
/**
* First Method.
*/
function array_search_partial($arr, $keyword) {
foreach($arr as $index => $string) {
if (strpos($string, $keyword) !== FALSE)
return $index;
}
}
@zuhairkareem
zuhairkareem / xdebug_ubuntu.md
Last active December 2, 2022 08:50
Xdebug on Ubuntu 16.04 and PHP 5.6/7.1
@zuhairkareem
zuhairkareem / windows-server-startup.md
Created August 15, 2022 07:51
Add scripts on startup on windows server
@zuhairkareem
zuhairkareem / sudo_error.md
Last active August 4, 2022 17:38
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set error in Ubuntu 18.04

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set error in Ubuntu

To fix

  1. If root user is not set, goto recovery mode, select drop as root shell prompt, then it will goto root prompt, run
mount -o remount,rw /
@zuhairkareem
zuhairkareem / drupal_upgrade_domains_firewall.md
Last active June 14, 2022 08:18
Drupal upgrade - domains to include in firewall in decoupled architecture

Here is some unofficial info that I compiled for a customer some time ago. Maybe you can use it as a starting point.

ftp.drupal.org , Port 443 (for update module)

git.drupal.org , Port 22, 80, 443 (for patches)

packages.drupal.org , Port 22, 80, 443 (for Drupal Composer packages)

updates.drupal.org , Port 80, 443 (for update module)

@zuhairkareem
zuhairkareem / ubuntu_error_fix.md
Last active May 16, 2022 12:16
invoke-rc.d: policy-rc.d denied execution of stop. , dpkg: error processing package mysql-server-8.0 error on Ubuntu 20.04

For forcefully purging the package.

Since removing packages can be destructive, print the list of the package that will be removed:

dpkg -l | awk  '{print $2}' | grep -i mysql | grep -v lib

Check if any important package is being removed. If everything seems fine, proceed to step 2.

Purge the packages:

@zuhairkareem
zuhairkareem / manually_translate_d8_config.php
Created February 15, 2022 15:13
Create translated strings manually in Drupal 8 config interface translation
<?php
use \Drupal\locale\SourceString;
$source_string = "Source text string";
$translated_string = "translated string";
$langcode = "ar";
// Find existing source string.
$storage = \Drupal::service('locale.storage');
@zuhairkareem
zuhairkareem / rest_resource_del.md
Created November 7, 2021 13:34
Delete a specific REST resource using drush Drupal 8/9

drush cdel rest.resource.{YOUR_RESOURCE_NAME}

@zuhairkareem
zuhairkareem / delete_tokens_d8_oauth2.md
Created October 18, 2021 10:01
delete all oAuth2 tokens - Drupal 8/9
<?php

$query = \Drupal::entityTypeManager()->getStorage('oauth2_token')->getQuery();
$entity_ids = $query->execute();


$results = \Drupal::entityTypeManager()->getStorage('oauth2_token')->loadMultiple(array_values($entity_ids));

//var_dump($results);