Skip to content

Instantly share code, notes, and snippets.

View mehdichaouch's full-sized avatar
🤖
Happiness Developer

Mehdi Chaouch mehdichaouch

🤖
Happiness Developer
View GitHub Profile
@mehdichaouch
mehdichaouch / memory_usage.php
Last active April 11, 2024 15:55
PHP Snippet to get human readable memory usage
<?php
function convert($size)
{
$unit=array('b','kb','mb','gb','tb','pb');
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
}
convert(memory_get_usage());
@mehdichaouch
mehdichaouch / google-dorks
Created March 22, 2020 17:53
Listing of a number of useful Google dorks.
Explanations:
cache: If you include other words in the query, Google will highlight those words within
the cached document. For instance, [cache:www.google.com web] will show the cached
content with the word “web” highlighted. This functionality is also accessible by
clicking on the “Cached” link on Google’s main results page. The query [cache:] will
show the version of the web page that Google has in its cache. For instance,
[cache:www.google.com] will show Google’s cache of the Google homepage. Note there
can be no space between the “cache:” and the web page url.
------------------------------------------------------------------------------------------
@mehdichaouch
mehdichaouch / README.md
Last active November 30, 2023 17:33
🔧 WordPress Plugins Compatibility from command line with WP-CLI
@mehdichaouch
mehdichaouch / generate-git-branch-name-from-jira-issue.html
Last active December 12, 2022 14:01
🌿 Bookmarklet to generate a Git branch name from Jira issue
<!doctype html>
<html lang="en">
<head>
<meta name="description" content="Bookmarklet - Generate a Git branch name from Jira issue by Mehdi Chaouch">
<meta name="keywords" content="Bookmarklet,Git,Jira,issue">
<meta name="author" content="Mehdi Chaouch">
<!-- Author: https://gist.github.com/mehdichaouch -->
<!-- Required meta tags -->
<meta charset="utf-8">
@mehdichaouch
mehdichaouch / encrypt.php
Created November 15, 2016 09:39
Magento - AES encryption
<?php
$product = $this->getProduct();
// return no link in case of zero night
if (is_null($product->getData('nights'))) {
return '#';
}
$language = Mage::getStoreConfig('general/locale/code');
$country = $dcsInfo->getData('country');
@mehdichaouch
mehdichaouch / OystAPI.10s.sh
Last active November 29, 2022 21:36
BitBar / xbar - Plugin Oyst API status
#!/bin/bash
#set -e
#set -x
# Oyst API status
API_KEY_SANDBOX=
API_KEY_STAGING=
ENVIRONMENTS=('sandbox' 'staging') # Add more env here if needed ; Add also variable above
@mehdichaouch
mehdichaouch / install_xdebug.sh
Created December 3, 2020 14:35
Quick setup for Xdebug
#!/bin/bash
yes | pecl install xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_connect_back = 1" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_port = 9000" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.scream = 0" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.show_local_vars = 1" >> /usr/local/etc/php/conf.d/xdebug.ini \
@mehdichaouch
mehdichaouch / m2-dev-tools.sh
Last active November 29, 2022 21:31
m2-dev-tools.sh
#!/bin/bash
###
# @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
# @author Mehdi Chaouch <mehdi@advocodo.com> <@advocodo>
# @copyright Copyright (c) 2020 ADVOCODO (https://www.advocodo.com)
# @description This script install some developer tools for Magento 2
# @usage ./m2-dev-tools.sh
###
@mehdichaouch
mehdichaouch / fix_user_password.sql
Created April 5, 2022 16:45
Magento 2 SQL snippet to reset admin password
# xxxxxxxx is the salt - it can change or stay like that
# admin123 is the password, you must change it
UPDATE admin_user SET `password` = CONCAT(SHA2('xxxxxxxxadmin123', 256), ':xxxxxxxx:1') WHERE `username` = 'admin';