Skip to content

Instantly share code, notes, and snippets.

View salvatorecapolupo's full-sized avatar
🎯
Focusing

Salvatore Capolupo salvatorecapolupo

🎯
Focusing
View GitHub Profile
@salvatorecapolupo
salvatorecapolupo / testo3d.html
Last active April 6, 2024 16:28
Realizzare testo 3D in HTML con three.js - Semplicissimo :-) Vedi anche: https://trovalost.it/creare-testo-3d/
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello Three.js</title>
<style>
body { margin: 0; }
canvas { display: block; }
</style>
</head>
Trovare file che occupano più spazio via SSH
find / -size +250M -ls
--
Liberare spazio su disco Linux via SSH
cd /
sudo du -h --max-depth=1
- Note which directories are using a lot of disk space.
- cd into one of the big directories.
@salvatorecapolupo
salvatorecapolupo / azlisting.php
Created March 2, 2024 20:44
Wordpress A-Z Listing (plugin 2024)
<?PHP
/**
*
* Plugin Name: AZ Listing 2
* Description: The cat is under the ground
* Author: Salvatore Capolupo
* Version: 1.0
* Author URI: http://www.trovalost.it
*/
Ecco la condizione corretta per verificare se una matrice è una matrice simmetrica:
INIZIO
Come prima cosa poniamo di avere la matrice già piena:
m ={{1,2,3},{1,2,3},{1,2,3}} ad es.
se m[][] è la matrice, per ogni i e per ogni j devo avere:
m[i][j] == m[j][i]
//se per qualche condizione è false, è false anche la condizione cercata
//nota gli elementi sulla diagonale principale m[i][i] non contano
@salvatorecapolupo
salvatorecapolupo / random_walk2d.py
Created January 20, 2024 14:32
Random walk in due dimensioni
import turtle
import random
# Funzione per un passo casuale in due dimensioni
def random_step():
return random.choice([(0, 1), (0, -1), (1, 0), (-1, 0)])
# Funzione per eseguire la random walk in due dimensioni
def random_walk_2d(steps):
positions = [(0, 0)] # Inizializza la posizione iniziale
@salvatorecapolupo
salvatorecapolupo / random_walk1d.py
Created January 20, 2024 14:25
Camminata casuale a una sola dimensione - Turtle + Python 3
import turtle
import random
# Funzione per un passo casuale a destra o sinistra
def random_step():
return random.choice([-1, 1])
# Funzione per eseguire il random walk
def random_walk(steps):
positions = [0] # Inizializza la posizione iniziale
@salvatorecapolupo
salvatorecapolupo / lzw.py
Created January 13, 2024 16:04
LZW simple implementation in Python 3
def compress(uncompressed):
"""Compress a string to a list of output symbols."""
# Build the dictionary.
dict_size = 256
dictionary = dict((chr(i), i) for i in range(dict_size))
# in Python 3: dictionary = {chr(i): i for i in range(dict_size)}
w = ""
result = []
@salvatorecapolupo
salvatorecapolupo / noduplicates.sql
Last active September 9, 2022 06:29
WordPress find post duplicates via MySQL query - Used to remove duplicated posts from WordPress - i.e https://www.lipercubo.it, https://capolooper.it
SELECT a.ID, a.post_title, a.post_type, a.post_status
FROM wp_posts AS a
INNER JOIN (
SELECT post_title, MIN( id ) AS min_id
FROM wp_posts
WHERE post_type = 'post'
AND post_status = 'publish'
GROUP BY post_title
HAVING COUNT( * ) > 1
) AS b ON b.post_title = a.post_title
## ## ## ## ## ## ## ## ## ## ## ## ## ## -
## ## wp_postmeta
## ## ## ## ## ## ## ## ## ## ## ## ## ## -
## minusc
UPDATE wp_postmeta SET meta_key = replace(meta_key, "Ã ", "à");
UPDATE wp_postmeta SET meta_key = replace(meta_key, "è", "è");
UPDATE wp_postmeta SET meta_key = replace(meta_key, "ì", "ì");
UPDATE wp_postmeta SET meta_key = replace(meta_key, "ò", "ò");