Skip to content

Instantly share code, notes, and snippets.

View sabrysuleiman's full-sized avatar

Sabry Suleiman sabrysuleiman

View GitHub Profile
<script>
function loadScript(url) {
let isLoaded = document.querySelectorAll('.search-script');
if(isLoaded.length > 0) { return; }
let myScript = document.createElement("script");
myScript.src = url;
myScript.async = 'async';
myScript.className = 'search-script';
document.head.appendChild(myScript);
}
@sabrysuleiman
sabrysuleiman / functions.php
Created November 18, 2023 18:25
lazy load wordpress content images
function add_lazy_loading_to_images($content) {
// Add loading="lazy" to all <img> tags in the content
$content = preg_replace('/<img(.*?)src=(["\'])(.*?)\2(.*?)>/i', '<img$1loading="lazy" src=$2$3$2$4>', $content);
return $content;
}
add_filter('the_content', 'add_lazy_loading_to_images');
@sabrysuleiman
sabrysuleiman / .htaccess
Created November 18, 2023 18:23 — forked from lukecav/.htaccess
Browser caching for Apache
<IfModule mod_expires.c>
ExpiresActive On
# Images
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/avif "access plus 1 year"
ExpiresByType image/avif-sequence "access plus 1 year"
@sabrysuleiman
sabrysuleiman / gist:227141bc5fe3f19dab73d5374f4ec8e4
Created November 15, 2023 17:52
Installing Apache Cordova on Ubuntu
# Install Node.js and npm
sudo apt update
sudo apt install nodejs
sudo apt install npm
# Install Cordova
sudo npm install -g cordova
# Create a Cordova Project
cordova create MyAndroidApp
@sabrysuleiman
sabrysuleiman / List-social-profile-links.txt
Created August 23, 2023 20:15 — forked from manhleo93/List-social-profile-links.txt
+250 Social Profile Backlinks © Copyright 2018 by Vũ Đức Mạnh
@sabrysuleiman
sabrysuleiman / make Apache run as current user
Created June 30, 2023 18:49
make Apache run as current user
export APACHE_RUN_USER=username
export APACHE_RUN_GROUP=www-data
sudo adduser username www-data
@sabrysuleiman
sabrysuleiman / Set Up Apache Virtual Hosts on Ubuntu
Created June 30, 2023 18:27
Set Up Apache Virtual Hosts on Ubuntu
# Set Up Apache Virtual Hosts on Ubuntu
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/domain.conf
sudo nano /etc/apache2/sites-available/domain.conf
ServerAdmin webmaster@localhost
ServerName your_domain_1
ServerAlias www.your_domain_1
DocumentRoot /var/www/html
@sabrysuleiman
sabrysuleiman / enhanced data layer for your WordPress website
Created April 13, 2023 20:51
enhanced data layer for your WordPress website
To create an enhanced data layer for your WordPress website, you can follow these steps:
Install and activate a Google Tag Manager (GTM) plugin:
First, you need to install a GTM plugin to your WordPress site. A popular choice is the Google Tag Manager for WordPress by Thomas Geiger. You can install and activate it from your WordPress dashboard by going to Plugins > Add New and searching for "Google Tag Manager for WordPress".
Set up a Google Tag Manager account:
If you don't already have a GTM account, sign up and create a new container for your website.
Configure the GTM plugin:
In your WordPress dashboard, go to Settings > Google Tag Manager and enter your GTM container ID (e.g., GTM-XXXXXX). Follow the plugin's instructions to properly configure the settings.
@sabrysuleiman
sabrysuleiman / wordpress_robots_custom.php
Created April 6, 2023 22:51 — forked from amboutwe/wordpress_robots_custom.php
Filters and example code for Yoast SEO robots or WP robots.txt
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Replace Disallow with Allow Generated Robots.txt
* Credit: Unknown
* Last Tested: June 09 2020 using WordPress 5.4.1
*/
add_filter('robots_txt','custom_robots');
@sabrysuleiman
sabrysuleiman / Switching language shortcut (Alt + Shift) in ubuntu
Created March 31, 2023 22:09
Switching language shortcut (Alt + Shift) in ubuntu
gsettings set org.gnome.desktop.wm.keybindings switch-input-source "['<Alt>Shift_R']"
gsettings set org.gnome.desktop.wm.keybindings switch-input-source-backward "['<Alt>Shift_L']"