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
# /// 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:
#!/bin/bash
# Check if two arguments (cgroup paths) are provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <cgroup1_path> <cgroup2_path>"
exit 1
fi
cgroup1_path="$1"
cgroup2_path="$2"
@adrianlzt
adrianlzt / README.md
Last active January 16, 2025 15:12
Connect to the PostgreSQL where AWX stores its data, Get the credentials stored and select which one you want to decode. You need to pass the AWX secret_key.
❯ uv run https://gist.githubusercontent.com/adrianlzt/b2c2c9581757ad359216eef0f05beb1a/raw/5a0f29c2496a98e9aef0eef8ad1469d1cbdd09e8/awx_secrets.py --host 10.1.1.10 --user awx --password SECRETPASSWORD --secret-key SECRETKEY

Reading inline script metadata from `./awx_secrets.py`
Available secrets:
1. Name: Demo Credential, Type: Machine
Select the secret to decrypt: 7
username: admin
#!/bin/bash
#
# Aplicación para editar un KV secret version 2 en Vault
#
path=$1
tmpfile=$(mktemp)
# Fetch the secret and write it to a temporary file
vault kv get -format=json $path | jq -er .data.data > $tmpfile
# Creamos una CA self-signed para generar los certificados de los clientes VPN
resource "tls_private_key" "foo-vpn-ca-key" {
algorithm = "RSA"
rsa_bits = 4096
}
resource "tls_self_signed_cert" "foo-vpn-ca" {
private_key_pem = tls_private_key.foo-vpn-ca-key.private_key_pem
subject {