Skip to content

Instantly share code, notes, and snippets.

View manuelricci's full-sized avatar
👽
Coding... but mostly waiting for npm install

Manuel Ricci manuelricci

👽
Coding... but mostly waiting for npm install
View GitHub Profile
@manuelricci
manuelricci / profile_powershel.ps1
Created June 12, 2025 18:41
Profilo base per PowerShell con supporto a Oh My Posh. Tutorial completo 👉 https://youtu.be/LY4xK9vJ7f8
# Modulo per avere le icone nel terminale, installare il modulo con il comando
# Install-Module -Name Terminal-Icons -Repository PSGallery
Import-Module Terminal-Icons
# Modificare il NOME-TEMA con quello che preferisci (trovi la lista completa qui https://ohmyposh.dev/docs/themes)
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/NOME-TEMA.omp.json" | Invoke-Expression
# Cronologia completamento comandi
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
@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