Skip to content

Instantly share code, notes, and snippets.

View adrianlzt's full-sized avatar

Adrián López adrianlzt

View GitHub Profile
#!/usr/bin/env -S uv run
# /// script
# requires-python = ">=3.10"
# dependencies = []
# [tool.uv]
# exclude-newer = "2025-06-03T00:00:00Z"
# ///
"""
Monitor TIME-WAIT connections and detect threshold violations.
#!/usr/bin/python3
# @lint-avoid-python-3-compatibility-imports
#
# tcpconnect Trace TCP connect()s.
# For Linux, uses BCC, eBPF. Embedded C.
#
# USAGE: tcpconnect [-h] [-c] [-t] [-p PID] [-P PORT [PORT ...]] [-4 | -6]
#
# All connection attempts are traced, even if they ultimately fail.
#
#!/usr/bin/python3
# @lint-avoid-python-3-compatibility-imports
#
# tcpconnect Trace TCP connect()s.
# For Linux, uses BCC, eBPF. Embedded C.
#
# USAGE: tcpconnect [-h] [-c] [-t] [-p PID] [-P PORT [PORT ...]] [-4 | -6]
#
# All connection attempts are traced, even if they ultimately fail.
#
#!/usr/bin/env -S uv run
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "pandas",
# "matplotlib",
# ]
# ///
import pandas as pd
import matplotlib.pyplot as plt
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "bleak",
# ]
# [tool.uv]
# exclude-newer = "2025-07-03T00:00:00Z"
# ///
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shoulder Mobility Assessment Calculator</title>
<link rel="stylesheet" href="style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">

DSPy LabeledFewShot Optimizer Example

This repository contains a Python script, dspy_LabeledFewShot.py, that demonstrates how to use the dspy.teleprompt.LabeledFewShot optimizer for sentiment analysis.

The script defines a simple DSPy program to classify the sentiment of a sentence as "Positive", "Negative", or "Neutral". It then uses LabeledFewShot to "compile" this program by creating few-shot prompts from a small training set. Finally, it runs the compiled program on a new sentence and inspects the prompt sent to the Language Model (LLM) to show how the few-shot examples were included.

Requirements

  • Python 3.13+
  • uv
#!/usr/bin/env -S uv run
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "mlflow",
# "azureml-mlflow",
# "azure-ai-ml",
# "azure-identity",
# ]
# [tool.uv]
@adrianlzt
adrianlzt / incomplete-json-pretty-printer.html
Last active April 1, 2025 11:29
Incomplete JSON pretty printer
<!-- Taken from https://simonwillison.net/2025/Mar/28/incomplete-json-pretty-printer/ -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JSON Pretty Printer</title>
<style>
body {
font-family: Arial, sans-serif;
@adrianlzt
adrianlzt / docker_clean_ask.py
Last active January 23, 2025 07:44
Delete all none images and then ask the user, for each image:tag, if he wants to delete it
#!/usr/bin/env python3
import subprocess
def remove_image(image_id):
"""Safely remove a docker image."""
try:
subprocess.run(["docker", "rmi", image_id], check=True, capture_output=True)
print(f" ✓ Removed: {image_id}")
except subprocess.CalledProcessError: