Skip to content

Instantly share code, notes, and snippets.

View r1cc4rd0m4zz4's full-sized avatar
๐Ÿ‚

Riccardo Mazza r1cc4rd0m4zz4

๐Ÿ‚
View GitHub Profile
@r1cc4rd0m4zz4
r1cc4rd0m4zz4 / README.md
Last active July 7, 2026 22:18 — forked from mattpocock/README.md
agent-proxy - fork with configurable upstream URL. Works with any Anthropic-compatible API, not just api.anthropic.com. Based on @mattpocock's original.

agent-proxy - fork with configurable upstream

Fork of Matt Pocock's agent-proxy with one improvement: the upstream URL is now configurable via UPSTREAM_URL env var.

Why

The original only forwards to api.anthropic.com over HTTPS on port 443. This fork lets you point the proxy at any Anthropic-compatible API:

# Default - works like the original
@r1cc4rd0m4zz4
r1cc4rd0m4zz4 / Setup_secure_remote_ollama_server_on_colab.ipynb
Created May 19, 2025 22:09
Secure remote Ollama API with Caddy Auth & Ngrok on Google Colab in one shot
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@r1cc4rd0m4zz4
r1cc4rd0m4zz4 / docker-cleanup.sh
Last active January 4, 2025 22:28
Automatically removes unused Docker images daily. No temporary files, no dependencies, self-contained.
# Docker Image Cleanup
# Automatically removes unused Docker images daily
# No temporary files, no dependencies, self-contained
#
# Usage:
# Direct execution from gist:
# curl -s https://gist.githubusercontent.com/r1cc4rd0m4zz4/cd7d80c592867eeadc084eebbeab6f8d/raw/docker-cleanup.sh | bash
#
# Or download and run:
# 1. curl -o docker-cleanup.sh https://gist.githubusercontent.com/r1cc4rd0m4zz4/cd7d80c592867eeadc084eebbeab6f8d/raw/docker-cleanup.sh
@r1cc4rd0m4zz4
r1cc4rd0m4zz4 / ffmpeg.compress.py
Created December 17, 2024 12:40
This script compresses audio files in a specified folder using FFmpeg. It reduces the file size by adjusting the bitrate and sample rate.
## Dependencies
#- [FFmpeg](https://ffmpeg.org/download.html): Make sure FFmpeg is installed and accessible from the command line.
## Usage
#```sh
#python ffmpeg.compress.py [input_folder] [--bitrate TARGET_BITRATE] [--sample_rate SAMPLE_RATE]
#python ffmpeg.compress.py ./audio_files --bitrate 128k --sample_rate 44100
import subprocess
import os
@r1cc4rd0m4zz4
r1cc4rd0m4zz4 / remove_metadata.sh
Created November 13, 2024 19:35
Script to remove metadata from audio/video files using ffmpeg
#!/bin/bash
# Script to remove metadata from audio/video files using ffmpeg
# Usage: ./remove_metadata.sh input_file
# Example: ./remove_metadata.sh music.m4a
# Check if input file is provided
if [ $# -ne 1 ]; then
echo "Error: Please provide an input file"
echo "Usage: $0 input_file"
@r1cc4rd0m4zz4
r1cc4rd0m4zz4 / tok-n.py
Created September 18, 2024 21:36
Calcola i token di un testo usando tiktoken
#!/usr/bin/env python3
## pip install tiktoken
import argparse
import tiktoken
import sys
def count_tokens(text, model_name="gpt-4"):
# Inizializza il tokenizzatore per il modello GPT-4
encoding = tiktoken.encoding_for_model(model_name)
tokens = encoding.encode(text)
@r1cc4rd0m4zz4
r1cc4rd0m4zz4 / pdf2text.py
Created September 11, 2024 23:44
This Python script extracts text from PDF files using three different libraries: `pdfminer`, `unstructured`, and `pymupdf`. It allows you to choose the extraction method via command-line arguments and saves the extracted text to a specified output file or prints it to the terminal.
#!/usr/bin/env python3
#python3 -m pip install pymupdf unstructured pdfminer
#chmod +x pdf2text.py
#python3 pdf2text.py path/to/your/pdf/file.pdf -m unstructured -o output_file
import warnings
import argparse
import os
import importlib
import sys
@r1cc4rd0m4zz4
r1cc4rd0m4zz4 / split_sentence2maxtok.py
Last active February 7, 2025 07:47
Split Text into Tokenized Chunks
#!/usr/bin/env python3
#python3 -m pip install nltk tiktoken
#chmod +x split_sentence2maxtok.py
#./split_sentence2maxtok.py "This is a test sentence. This is another test sentence. This is a long test sentence." 6
import nltk
from nltk.tokenize import sent_tokenize
from nltk.data import find
import tiktoken
import sys
@r1cc4rd0m4zz4
r1cc4rd0m4zz4 / split_max_text.py
Created September 11, 2024 19:29
Split Text into Sentences with Maximum Length
#!/usr/bin/env python3
#python3 -m pip install nltk
#chmod +x split_max_text.py
#./split_max_text.py "This is a test sentence. This is another test sentence. This is a long test sentence." 20
import nltk
from nltk.tokenize import sent_tokenize
from nltk.data import find
import sys