Skip to content

Instantly share code, notes, and snippets.

View azeemhassni's full-sized avatar

Azeem Hassni azeemhassni

View GitHub Profile
@azeemhassni
azeemhassni / .htaccess
Created September 20, 2018 10:19
Route all requests to index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
@azeemhassni
azeemhassni / mysql_add_user.sh
Last active January 20, 2019 15:13
Add user to mysql
FILENAME='./mysql_add_user.tmp.sql'
touch FILENAME;
echo "CREATE USER '$1'@'localhost' IDENTIFIED BY '$2';" >> FILENAME;
echo "GRANT ALL PRIVILEGES ON * . * TO '$1'@'localhost';" >> FILENAME;
echo "FLUSH PRIVILEGES;" >> FILENAME;
echo " 🔊 Adding $1 to mysql users";
sudo mysql -u root -p < FILENAME;
rm FILENAME;
@azeemhassni
azeemhassni / wordpress_estimated_reading_time_to_posts.php
Created March 8, 2022 13:55
Add Estimated reading time to your WordPress blog posts
<?php
// functions.php
function get_reading_time($content, $words_per_minute = 300): int {
$striped = strip_tags($content);
$words = explode(' ', $striped);
return round(sizeof($words) / $words_per_minute);