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
  • 03:20 (UTC -04:00)
View GitHub Profile
# /// 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"
@drbh
drbh / demo.py
Created April 17, 2024 02:28
Deploy Inference Endpoint and use tools from OpenAI client
from openai import OpenAI
ENDPOINT_URL = "ENDPOINT_URL"
HF_TOKEN = "YOUR_TOKEN"
# Initialize the client, pointing it to one of the available models
client = OpenAI(
base_url=ENDPOINT_URL + "/v1/",
api_key=HF_TOKEN,
)
@drbh
drbh / email.ts
Created December 12, 2023 23:50
simple OTP email login
const SEND_IN_BLUE_KEY = "..."
const randomString = (length) => {
const bytes = new Uint8Array(length);
window.crypto.getRandomValues(bytes);
let result = '';
bytes.forEach((b) => {
// Convert each byte to a digit (0-9)
result += (b % 10).toString();
});
@drbh
drbh / sink-slack.script
Created July 19, 2023 01:08
smol apple script that sinks recent slack messages into a json file
tell application "Safari"
-- Open Slack and navigate to the desired channel
activate
-- Navigate to the desired channel (with Josh in the name)
tell window 1
set currentTab to tab 1
set URL of currentTab to "https://app.slack.com/client/SPACE/CHAN"
repeat until (do JavaScript "document.readyState" in currentTab) is "complete"
delay 0.2
curl -OL http://nginx.org/download/nginx-1.23.4.tar.gz
tar -xvzf nginx-1.23.4.tar.gz && rm nginx-1.23.4.tar.gz
# todo add openssl and prce
curl -OL https://osdn.net/projects/sfnet_pcre/downloads/pcre/8.45/pcre-8.45.tar.gz
tar -xvzf pcre-8.45.tar.gz && rm pcre-8.45.tar.gz
curl -OL https://github.com/openssl/openssl/releases/download/openssl-3.1.0/openssl-3.1.0.tar.gz
tar -xvzf openssl-3.1.0.tar.gz && rm openssl-3.1.0.tar.gz
@drbh
drbh / d1-from-do.ts
Created January 8, 2023 22:29
A hacky but working solution to call D1 from a Durable Object
// our DO class
export class SomeDurableObject {
// should upgrade to explicit type in prod
env: any;
constructor(_controller, env) {
this.env = env;
}
// manually make request to D1 binding
import { ApiPromise, Keyring, WsProvider } from "@polkadot/api";
async function main() {
const wsProvider = new WsProvider("wss://rpc.parallel.fi");
const api = await ApiPromise.create({ provider: wsProvider });
// no blockHash is specified, so we retrieve the latest
const signedBlock = await api.rpc.chain.getBlock();