Skip to content

Instantly share code, notes, and snippets.

View Favo02's full-sized avatar
🤠
failing exams

Luca Favini Favo02

🤠
failing exams
View GitHub Profile
@Favo02
Favo02 / template-updater.sh
Last active March 9, 2026 11:03
Update typst-notes-template
find ./ -type f -name "*.typ" -exec sed -i \
-e 's/#teorema(\"Teorema\")/#theorem/g' \
-e 's/#teorema(\"/#theorem(title: \"/g' \
-e 's/#theorem(\"/#theorem(title: \"/g' \
-e 's/#esempio/#example/g' \
-e 's/#informalmente/#informally/g' \
-e 's/#nota/#note/g' \
-e 's/#attenzione/#warning/g' \
-e 's/#dimostrazione/#proof/g' \
-e 's/link-teorema(/link-theorem(/g' \
@Favo02
Favo02 / backup.sh
Last active July 11, 2025 16:07
Script to backup things using restic
#!/bin/bash
# custom echo function with red color and arrow
print() {
echo -e "\033[32m---> $*\033[0m"
}
error() {
echo -e "\033[31m---> $*\033[0m"
exit 1
}
@Favo02
Favo02 / jetbrains-internship-application.kt
Last active April 22, 2025 11:55
Task to apply for jetbrains internship
import java.nio.file.Files
import java.nio.file.LinkOption
import java.nio.file.Path
import kotlin.io.path.getAttribute
import kotlin.system.exitProcess
fun main(vararg args: String) {
val dir = try {
Path.of(args[0])
} catch (_: Exception) {
@Favo02
Favo02 / jetbrains-internship-application.rs
Created April 7, 2025 19:02
Task to apply for jetbrains internship
use sha2::{Digest, Sha256};
use std::collections::HashMap;
use std::io::{Read, Write};
use std::net::TcpStream;
fn communicate(range_start: usize) -> (HashMap<String, String>, Vec<u8>) {
let mut stream = TcpStream::connect("127.0.0.1:8080").expect("Failed to connect to server");
let request = format!(
"GET / HTTP/1.1\r\n\
Host: localhost:8080\r\n\
@Favo02
Favo02 / immich-search.py
Last active September 21, 2026 03:31
Check if photos are already uploaded to Immich searching for hash and filename
"""
Check if some photos (contained in the IMAGES folder) are already uplaoded to Immich,
without actually uploading them, but searching for the hash and the filename.
If the photo is NOT uploaded, it is moved to the ERRORS directory (that should ALREADY EXISTS).
"""
URL = ""
API_KEY = ""
IMAGES = ""
ERRORS = ""
@Favo02
Favo02 / git-merge-repositories
Created October 6, 2024 12:59
Merge git repositories rewriting history
git remote add new git@github.com:username/reponame.git --fetch
git branch new new/main
git checkout new
git-filter-repo --force --message-callback 'return b"reponame: " + message' --refs new
git-filter-repo --force --to-subdirectory-filter reponame --refs new
git checkout main
git merge --allow-unrelated-histories new -m "Merge branch 'reponame'"
@Favo02
Favo02 / parti.py
Created September 5, 2024 13:27
Insieme delle parti senza cicli
n = int(input())
res = set()
def aggiungi(cur, remaining):
res.add(tuple(cur))
scorri(cur, remaining)
return res
def scorri(cur, rem):
if not rem:
@Favo02
Favo02 / test.md
Created February 21, 2024 00:22
LaTeX not rendering GitHub preview

Problem:

I noticed this snippet of LaTeX not rendered in my Calculus notes:

$lim_{h \rightarrow 0^+} \frac{f(x_0+h)-f(x_0)}{h} = f'+(x_0)$, per il teorema della permanenza del segno $f'+(x_0) \geq 0$

adding an extra whitespace, it works:

$lim_{h \rightarrow 0^+} \frac{f(x_0+h)-f(x_0)}{h} = f'_ +(x_0)$, per il teorema della permanenza del segno $f'_+(x_0) \geq 0$

@Favo02
Favo02 / crop.py
Created September 26, 2023 20:45
Crop 4 slides/page PDF into 1 slide/page PDF
# usage: python crop.py <input.pdf> <output.pdf>
# requirements: PyPDF2 (pip install PyPDF2)
# issues: @Favo02 on Telegram/GitHub
import PyPDF2
import sys
def crop_pdf(input, output):
with open(input, "rb") as input_pdf:
@Favo02
Favo02 / moveFilesInGitRepo.py
Created September 12, 2023 10:41
Move file in a Git repository without a new commit (and without losing his last commit message). REWRITES HISTORY, DANGEROUS
# move files in git rewriting history without a new commit (and without renaming the last commit message)
# VERY DANGEROUS
import os
directory_path = '/home/...'
new_folder = 'new_folder'
for filename in os.listdir(directory_path):