Skip to content

Instantly share code, notes, and snippets.

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

Khaled Abu Alqomboz EngKhaledB

🏠
Working from home
View GitHub Profile
@EngKhaledB
EngKhaledB / Fix Ubuntu black screen on Google Meet screen sharing.md
Last active November 3, 2022 18:40
Fix Ubuntu black screen on Google Meet screen sharing

Disable WaylandEnable

> sudo nano /etc/gdm3/custom.conf

Uncomment #WaylandEnable=false

Restart gdm3

NOTE: this command will stop all of your running apps, make sure to save all of your files before running it.

> sudo systemctl restart gdm3

@EngKhaledB
EngKhaledB / DB-Size.sql
Created October 17, 2022 15:45
MySQL Get DB Size
-- Get size of single database
SELECT
table_schema "DB Name",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
FROM information_schema.tables WHERE table_schema = '<db_name>';
-- Get size of all databases
SELECT
table_schema "DB Name",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"

Setting Up WP-Rocket on Pantheon

1- Install WP-Rocket

Install WP-Rocket regulary, do not activate.

2- Create caching folders

via your pantheon Dashboard, go to the envrionment then Connection Info and copy the login command line to SFTP. Login to SFTP, then create these 2 folders under Uploads

  • cd /code/wp-content/uploads
@EngKhaledB
EngKhaledB / Fix upstream sent too big header.md
Created February 3, 2022 19:37
Fix: upstream sent too big header while reading response header from upstream

Fix: upstream sent too big header while reading response header from upstream

Add this to /etc/nginx/nginx.conf under http block

fastcgi_busy_buffers_size 2048k;
fastcgi_buffer_size 2048k;
fastcgi_buffers 16 2048k;

Window Firewall Allow WSL 2

Run in PowerShell

New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow

@EngKhaledB
EngKhaledB / SIMPLE_PARALLEL_PROCESSING_IN_PHP_WITH_PCNTL_FORK.php
Last active December 17, 2021 04:18
SIMPLE PARALLEL PROCESSING IN PHP WITH PCNTL_FORK
<?php
# Source: https://jrsinclair.com/articles/2013/simple-parallel-processing-in-php-with-pcntl-fork/
// A function to run
$makeDir = function($a) {
shell_exec('mkdir '.shellescapearg($a));
}
// An array to process
$dirnames = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k');
@EngKhaledB
EngKhaledB / Query.sql
Last active April 29, 2021 15:00
Create Oracle Tablespace & User / Schema & Grant Permissions
CREATE TABLESPACE TBS_ORA_DOCKER_01 DATAFILE 'TBS_ORA_DOCKER_01.dat' SIZE 50M ONLINE;
CREATE TEMPORARY TABLESPACE TBS_TEMPORARY_ORA_DOCKER_01 TEMPFILE 'TBS_TEMPORARY_ORA_DOCKER_01.dbf' SIZE 10M AUTOEXTEND ON;
CREATE USER ORA_DOCKER
IDENTIFIED BY ORA_DOCKER
DEFAULT TABLESPACE TBS_ORA_DOCKER_01
TEMPORARY TABLESPACE TBS_TEMPORARY_ORA_DOCKER_01
QUOTA UNLIMITED on TBS_ORA_DOCKER_01;
@EngKhaledB
EngKhaledB / AllowOnlyGmailEmailOnEDDChecout.php
Created February 25, 2021 13:06
Allow only Gmail emails on EDD checkout
<?php
// Add this code to functions.php
function checkout_allow_only_gmail_emails( $valid_data, $posted ) {
if ( ! empty( $posted['edd_email'] ) ) {
list( $user_id, $domain ) = explode( '@', $posted['edd_email'] );
if ( strtolower( $domain ) != 'gmail.com' ) {
edd_set_error( 'email_not_allowed', 'Only Google emails are allowed!' );
@EngKhaledB
EngKhaledB / AllowOnlyGmailEmailOnChecout.php
Last active February 25, 2021 12:53
Allow only Gmail emails on WooComerce checkout
<?php
// Add this code to functions.php
add_action( 'woocommerce_after_checkout_validation', 'checkout_allow_only_gmail_emails', 10, 2 );
function checkout_allow_only_gmail_emails( $fields, $errors ) {
if ( ! empty( $fields['billing_email'] ) ) {
list( $user_id, $domain ) = explode( '@', $fields['billing_email'] );
@echo off
Setlocal enabledelayedexpansion
Set "Pattern=Untitled"
Set "Replace=Page"
For %%# in ("D:\Folder Name\*.jpg") Do (
Set "File=%%~nx#"
Ren "%%#" "!File:%Pattern%=%Replace%!"
)