Skip to content

Instantly share code, notes, and snippets.

View stonecorleone's full-sized avatar

Stone Corleone stonecorleone

View GitHub Profile
@stonecorleone
stonecorleone / Remove all attachment wordpress
Last active July 9, 2020 15:47 — forked from solancer/apache-nginx-ftp
Correct permissions for /var/www/html
# First:
DELETE FROM wp_postmeta
WHERE post_id IN
(
SELECT id
FROM wp_posts
WHERE post_type = 'attachment'
)
;
@stonecorleone
stonecorleone / Mysql password update
Created May 24, 2019 05:45
Update password Mysql
ALTER USER 'root'@'localhost' IDENTIFIED with mysql_native_password;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
@stonecorleone
stonecorleone / gist:a140618e40f8bd6fd575364d34bd3998
Last active September 25, 2022 10:50
Setup Let’s Encrypt SSL on Ubuntu 18.04 & 16.04 LTS
- sudo git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
- cd /opt/letsencrypt
- Cert Only: sudo -H ./letsencrypt-auto certonly --standalone -d example.com -d www.example.com
- Auto config: sudo -H ./letsencrypt-auto -d example.com -d www.example.com
Check Certificate Domains
- sudo ls /etc/letsencrypt/live
- ./certbot-auto certificates
@stonecorleone
stonecorleone / tasksel-lampserver.txt
Last active October 13, 2019 04:59
To install LAMP server using tasksel
$ sudo tasksel install lamp-server
MySQL Secure Installation:
mysql_secure_installation
Firewall Configuration:
Enable firewall:
$ sudo ufw enable
@stonecorleone
stonecorleone / Apache2Buddy.txt
Last active June 7, 2020 07:03
Apache2Buddy
Apache2Buddy is a great tool that checks your server setup and performance and makes a report and suggestions based on the information it collects. It calculates the MaxRequestWorkers on remaining RAM, not total installed RAM.
curl -sL https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl | perl
@stonecorleone
stonecorleone / mysql-import-export-gzip
Created July 1, 2020 07:39
Mysql command to import/export gzip
Export
mysqldump -u user -pupasswd my-database | gzip -c > dbfile.sql.gz
Multiple parts:
mysqldump -u user -pupasswd my-database | gzip -c > one.gz; gzip -c one.gz > two.gz; gzip -c two.gz > three.gz
Import
zcat /path/to/file.sql.gz | mysql -u 'root' -p your_database
@stonecorleone
stonecorleone / delete-all-woocommerce-products.php
Created July 9, 2020 15:51 — forked from mikaelz/delete-all-woocommerce-products.php
Remove all WooCommerce products from database via SQL
<?php
require dirname(__FILE__).'/wp-blog-header.php';
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')");
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'");
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)");
$wpdb->query("DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_posts WHERE post_type IN ('product','product_variation')");
@stonecorleone
stonecorleone / mod_expires
Last active July 29, 2020 03:48
Make Browsers Cache Static Files With mod_expires On Apache2
Enabling mod_expires
a2enmod expires
Configuring mod_expires
If you have multiple file types that should expire after the same time after they have been accessed (let's say in one week),
you can use a combination of the FilesMatch and the ExpiresDefault directives, e.g. as follows:
<IfModule mod_expires.c>
@stonecorleone
stonecorleone / 1-remove-woocommerce-tabs.php
Created September 24, 2022 14:39 — forked from kittenlane/1-remove-woocommerce-tabs.php
Remove tabs but keep product description in WooCommerce
//* http://gasolicious.com/remove-tabs-keep-product-description-woocommerce/
// Location: add to functions.php
// Output: removes woocommerce tabs
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );