Skip to content

Instantly share code, notes, and snippets.

View cedricvidal's full-sized avatar

Cedric Vidal cedricvidal

View GitHub Profile
@cedricvidal
cedricvidal / browse.chatmode.md
Created August 14, 2025 14:44
VS Code Copilot Playwright Chat Mode
description tools
Description of the custom chat mode.
playwright

Browse Mode

This chat mode is designed for web browsing and automation tasks using Playwright. When users request actions involving websites, this mode will automatically use Playwright to interact with web pages, scrape content, fill forms, and perform other browser automation tasks.

Purpose

  • Handle web browsing and automation requests
@cedricvidal
cedricvidal / github-repo-security-analysis.md
Created August 5, 2025 06:56
Claude custom command: Github repo security analysis
allowed-tools argument-hint description
Bash(git clone:*), Glob(*), Grep(*), Read(*), TodoWrite(*)
github-repo-url
Clone a GitHub repository and perform security analysis to detect harmful code and personal data leaks

You are performing a security analysis on a GitHub repository. Your task is to:

  1. Clone the repository from the provided URL: $ARGUMENTS
  2. Perform comprehensive security scanning to identify:
@cedricvidal
cedricvidal / basic_agent.py
Last active May 28, 2025 20:40
OpenAI Agents SDK with Azure AI Foundry and Keyless authentication
# uv add asyncio azure-identity dotenv-azd openai-agents
from openai import AsyncAzureOpenAI
from agents import Agent, Runner, set_default_openai_client, set_tracing_export_api_key
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
from dotenv import load_dotenv
from dotenv_azd import load_azd_env
import asyncio
import os
@cedricvidal
cedricvidal / json-diff.py
Last active May 22, 2025 17:49
Python CLI to create a JSON diff using the patchdiff package
#!/usr/bin/env python
import rich_click as click
import json
from pathlib import Path
from dotenv import load_dotenv
from sys import stdout
from patchdiff import diff as patch_diff
load_dotenv()
@cedricvidal
cedricvidal / gist:69e2dbfbe37bd718b9917578875c3a62
Created January 23, 2025 01:40
Source .env variables and execute command or docker image
# print env vars
cat .azure/test/.env | xargs -i echo {}
# use for a command and merge into current env
env $(cat .azure/test/.env | xargs) env
# use as a docker run --env-file
docker run -it --env-file <(cat .azure/test/.env | xargs -i echo {}) ubuntu env
@cedricvidal
cedricvidal / litellm_patched.py
Last active October 7, 2024 23:24
LiteLLM Monkey Patched to support Azure Keyless authentication using `DefaultAzureCredential` and `get_bearer_token_provider`
#!/usr/local/bin/python3.12
# -*- coding: utf-8 -*-
import re
import sys
# LiteLLM doesn't support DefaultAzureCredential and get_bearer_token_provider
# There has been a discussion on the subject but no clear path forward:
# See https://github.com/BerriAI/litellm/issues/4417
# This monkey patches LiteLLM to force it to use the DefaultAzureCredential and get_bearer_token_provider
@cedricvidal
cedricvidal / dedup_env.sh
Created August 22, 2024 14:50
Deduplicate environment variables from multiple sources with Bash 4+
#!/bin/bash
dedup_env() {
local -A env_ary
while IFS== read -r key value; do
value=$(echo "$value" | sed 's/^ *"//' | sed 's/" *$//')
env_ary[$key]=$value
done <<EOM
$(cat $*)
EOM
@cedricvidal
cedricvidal / array-filtering.bicep
Created August 21, 2024 09:45
Bicep array filtering example
var deployments = [
{
name: 'text-embedding-ada-002'
format: 'OpenAI'
}
{
name: 'llama'
format: 'serverless'
}
]
@cedricvidal
cedricvidal / hf_constant_hash_hack.py
Last active May 19, 2024 18:17
Huggingface hack to prevent fingerprint issues with functions
from typing import Any
def constant_hash(func):
"""
Wraps a function and changes its hashing behavior to a constant.
This allows Hugginface to only use functiona parameters for hashing and nothing else in
the function's captured context
"""
return ConstantHash(func)
@cedricvidal
cedricvidal / open_llm_openai.py
Last active March 7, 2024 21:56
Consume Azure AI Pay As You Go (PAYG) Open Model endpoint (Llama 2, ...)
# Those endpoints don't use the usual Azure OpenAI scheme, they use the OpenAI scheme.
# They also take the model field to route to the proper deployment, but I haven't verified this works
# Tested with openai 1.13.3
from openai import OpenAI
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(filename)s:%(funcName)s:%(lineno)d - %(message)s',