Skip to content

Instantly share code, notes, and snippets.

View MattLoyeD's full-sized avatar
🎯
Focusing

Matthieu D MattLoyeD

🎯
Focusing
View GitHub Profile
@MattLoyeD
MattLoyeD / gist:ba67bd4abd3b4853cbb76e5cc2f41e1d
Created September 30, 2022 09:38 — forked from habibmac/gist:2883102
WP: Wordpress profiling tools
if ( !defined('SAVEQUERIES') && isset($_GET['debug']) && $_GET['debug'] == 'sql' )
define('SAVEQUERIES', true);
if ( !function_exists('dump') ) :
/**
* dump()
*
* @param mixed $in
* @return mixed $in
**/
@MattLoyeD
MattLoyeD / wp-tool.sh
Last active April 19, 2022 04:10
Update & Deploy tool for wordpress installations
#!/bin/sh
# Use it as sudoer for better results, not optimal I know
# Usage : cd /path && sudo sh wp-tools.sh deploy|update|push
# Deploy will go to dir and make databases updates along with chmod after git pull
# Update will update all components inside the wp install
# Push will create a commit and push it to origin/master
# Verify if wp cli is installed, installing if not
WP_FILE=/usr/local/bin/wp
@MattLoyeD
MattLoyeD / Install Chia on Ubuntu Headless and Plot on AWS S3
Last active March 28, 2021 21:56
This script allow you to plot easely on chia blockchain (v1.0.1) with AWS S3 on your server. This is based on ubuntu 20.04 LTS.
# Please note :
# - This has only been tested on ubuntu 20.04
# - You need to create a S3 Bucket and IAM credentials securely
# - This is based on the fact that your user is named "ubuntu" which might not be your case
# - Plotting k 32 = 101 Go as far as I remember. 100 of K32 = 10 TB kind of.
# This was costing a 550$/month on S3 last time I checked.
aws_access_key=
aws_secret_key=
bucket_name=my_bucket_name
@MattLoyeD
MattLoyeD / mp4_compress_and_thumbnail.sh
Created July 20, 2020 09:34
Make thumbnail and compress mp4 video for web use
#!/bin/bash
# $1 = Filename
# $2 = S3 Bucket Name
base=$(basename -- "$1")
extension="${base##*.}"
filename="${base%.*}"
# p720="./videos/720p/$filename.mp4"
<?php
// Made this on production grade server (PHP FPM 7.2 & 7.4) and local PHP CLI 7.4
// Solution 2 > Solution 1
// Local cli 7.4 : Did solution1 in 7.2129311561584 seconds. Did solution2 in 4.0765311717987 seconds.
// Server 7.2 FPM : Did solution1 in 9.0072309970856 seconds. Did solution2 in 4.500275850296 seconds.
// Server 7.4 FPM : Did solution1 in 8.1211979389191 seconds. Did solution2 in 4.0727269649506 seconds.
// example code
function microtime_float()
@MattLoyeD
MattLoyeD / FrontController.php
Created June 22, 2020 08:47
This file is a workaround in case of Magic Redirect not working on some custom implementations.
<?php
class FrontController extends FrontControllerCore
{
public function init()
{
if (Module::isInstalled('magicredirect') && Module::isEnabled('magicredirect')) {
require_once _PS_MODULE_DIR_.'magicredirect/magicredirect.php';
$mod = new MagicRedirect();
@MattLoyeD
MattLoyeD / install_lamp_presta.sh
Last active December 28, 2016 13:21
Fast LAMP with prestashop
sudo apt-get install php apache2 mysql-server mysql-client zip libapache2-mod-php php-json php-xml php-curl php-opcache php-intl php-intl php-mcrypt php-mysql php-zip php-gd php-mbstring sendmail php-mail;
sudo service apache2 restart;
cd /var/www/html/
wget https://download.prestashop.com/download/releases/prestashop_1.7.0.3.zip
unzip prestashop_1.7.0.3.zip ;
mv prestashop.zip html/ ;
cd html/ ;
unzip prestashop.zip;
sudo chmod 777 -R ./ ;
sudo a2enmod rewrite;
@MattLoyeD
MattLoyeD / cron_checkup.sh
Created August 27, 2016 11:44
Check website availability then reboot services if needed
#runs a check of your website http code response (Bad gateway, empty response, or service off) every half minute then send sms if reboot via Free Mobile API
jobjob()
{
var=`curl -I http://www.zogzog.com/ 2>/dev/null | head -n 1 | awk -F" " '{print $2}'`
if [[ -z "$var" ]] || [ "$var" == "502" ] || [ "$var" == "324" ]
then
curl -I "https://smsapi.free-mobile.fr/sendmsg?user=___&pass=___&msg=$var%20Serv%20Autorestart%20!";
sudo service nginx restart; sudo service php7.0-fpm restart;
@MattLoyeD
MattLoyeD / index.php
Last active May 27, 2020 18:02
GIF to MP4 in PHP (with Linux & ffmpeg)
<?php
/**
* @author: Matthieu Loye Deroubaix / @matloyed
* @website : http://www.agence-malttt.fr/
* Do what you want with this file :)
* Usage : http://gifme.domain.tld/?url=http://www.domain.tld/blablabla.gif
*/
# Image (Lightroom online) tools #
https://v3.polarr.co/
# Vector image editor #
http://editor.method.ac/
# Compression/Optimisation Image #
https://tinyjpg.com/ or https://tinypng.com/
# Lorem ipsum (alternative) #