Skip to content

Instantly share code, notes, and snippets.

View drbh's full-sized avatar
🕳️
a for AI

drbh drbh

🕳️
a for AI
  • drbh
  • state space
  • 18:50 (UTC -04:00)
View GitHub Profile
@drbh
drbh / chunk_h5ad.py
Created July 14, 2025 14:25
tool to chunk h5ad files
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "anndata",
# "numpy",
# ]
# ///
import anndata as ad
import numpy as np
import os
@drbh
drbh / benchmark_attention_script.py
Created July 9, 2025 22:42
SDPA benchmark for torch, FA2, FA3, transformer engine, xformers, Sage Attention and HF kernels-lib via a uv PEP 723 script
# /// script
# dependencies = [
# "numpy",
# "torch",
# "kernels",
# "pandas",
# "matplotlib"
# ]
# ///
# Benchmarking common shapes for Flux 1024x1024px image + varying text sequence lengths
# /// script
# dependencies = [
# "numpy",
# "torch",
# "kernels",
# ]
# ///
import torch
import torch.nn as nn
# /// script
# dependencies = [
# "numpy",
# "torch",
# "kernels",
# ]
# ///
import torch
# reuse the models from the previous snippets or copy the class
# /// script
# dependencies = [
# "numpy",
# "torch",
# "kernels",
# ]
# ///
import torch
import torch.nn as nn
# /// script
# dependencies = [
# "numpy",
# "torch",
# "kernels",
# ]
# ///
import torch
import torch.nn.functional as F
# /// script
# dependencies = [
# "numpy",
# "torch",
# "kernels",
# ]
# ///
import torch
# /// script
# dependencies = [
# "requests<3",
# ]
# ///
import requests
import concurrent.futures
import time
from datetime import datetime
@drbh
drbh / start-stop-tv.js
Created November 29, 2024 20:06
start and stop your tv every 3 seconds in JS and Python
// Roku device IP address
const rokuIp = "192.168.1.252";
// Base URL for ECP commands
const baseUrl = `http://${rokuIp}:8060/keypress`;
// Delay between commands in milliseconds
const delay = 3000;
async function sendKeypress(command) {
try {
const response = await fetch(`${baseUrl}/${command}`, { method: 'POST' });
@drbh
drbh / echo-bots.py
Created November 26, 2024 02:39
a small python script to facilitate a conversation between two llm chat endpoints
from collections import deque
import time
from dataclasses import dataclass
from typing import Deque, List, Dict
import requests
import os
class Colors:
PURPLE = "\033[95m"