Skip to content

Instantly share code, notes, and snippets.

View manuelricci's full-sized avatar
🤨
1337

Manuel Ricci manuelricci

🤨
1337
View GitHub Profile
@manuelricci
manuelricci / delete-the-events-calendar.sql
Last active August 16, 2021 05:46
Query to delete all the records of the events created with The Events Calendar
/*
How to use it:
1 - Change the table prefix `wp_` if the one in the db is different
2 - Execute the query
3 - Done 🎉
*/
DELETE a,b,c,d
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id )
LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id )
@manuelricci
manuelricci / add-border-to-all-elements.js
Created January 28, 2021 16:15
Find the element that make appear the horizontal scrollbar
[].forEach.call($$("*"), function(a) {
a.style.outline =
"1px solid #" + (~~(Math.random() * (1 << 24))).toString(16);
});
@manuelricci
manuelricci / debounce.js
Created January 28, 2021 16:14
Debounce a function in JavaScript
const debounce = (funcToExecute, executeAfter) => {
let timer;
return function(){
clearTimeout(timer);
const context = this;
const args = arguments;
timer = setTimeout(()=>{
funcToExecute.apply(context, args)}
, executeAfter);
}
@manuelricci
manuelricci / get-wp-table-prefix.sql
Last active January 28, 2021 16:13
SQL query to find WordPress table prefix
SELECT DISTINCT SUBSTRING(`TABLE_NAME` FROM 1 FOR ( LENGTH(`TABLE_NAME`)-8 ) )
FROM information_schema.TABLES WHERE
`TABLE_NAME` LIKE '%postmeta';
@manuelricci
manuelricci / update-wp-table.sql
Created January 28, 2021 16:11
SQL queries to update WordPress database after moving it from localhost to production server
# How to use it
# 1- Update table prefix with the one you've in your db
# 2- Replace Existing URL with the one in your db (e.g. http://localhost/)
# 3- Replace New URL with the new one (e.g. https://mywebsite.com/)
# Don't forget the trailing slash in both URLs
UPDATE wp_options SET option_value = replace(option_value, 'Existing URL', 'New URL') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, 'Existing URL', 'New URL');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'Existing URL','New URL');
UPDATE wp_usermeta SET meta_value = replace(meta_value, 'Existing URL','New URL');
UPDATE wp_links SET link_url = replace(link_url, 'Existing URL','New URL');
@manuelricci
manuelricci / estimated-reading-time.js
Created October 19, 2019 09:23
Show the estimated time to read a content.
/**
* Show the estimated time to read a content.
*
* Usage
*
* To show the estimated time in your page you need to:
* 1 - Include in your page a container with a class that you'll pass to the function
* 2 - Call the function passing the text container, the timer container and set echo
* to true to show the estimated time.
*
<?php
function wc_promo_alert_product()
{
global $woocommerce;
global $post;
$cart = $woocommerce->cart;
$category_id = array(14, 8, 38, 16); // Categorie alla quale viene applicata la promozione
$simple_flag = 0;
$variation_flag = 0;
<?php
function wc_promo_alert_product()
{
global $woocommerce;
global $post;
$cart = $woocommerce->cart;
$category_id = array(14, 8, 38, 16); // Categorie alla quale viene applicata la promozione
$simple_flag = 0;
$variation_flag = 0;
@manuelricci
manuelricci / youtube-downloader.py
Created December 30, 2018 15:12
Programma per scaricare video da YouTube. Ho realizzato questo piccolo software per mio nonno che voleva i video del karaoke. Mio nonno è il TOP!
"""
Project Name: Progetto Acquarius
Description: Un semplice downloader per YouTube
"""
from pytube import YouTube
import os
import re
from tkinter import *
import tkinter.messagebox
@manuelricci
manuelricci / related-keyword-extractor.js
Created December 30, 2018 14:34
Questo piccolo script JavaScript estrae le parole chiave correlate da una pagina di ricerca di Google. Può essere inserito nella console javascript del proprio Browser per ricevere la lista di keywords