Skip to content

Instantly share code, notes, and snippets.

@Zetaphor
Zetaphor / chainforge_openai_compatible_provider.py
Created January 2, 2025 19:34
Chainforge - OpenAI Compatible API Provider
from chainforge.providers import provider
import openai
from typing import Optional, Any, List, Dict, Union
# Define ChatHistory type locally
ChatMessage = Dict[str, str] # {"role": str, "content": str}
ChatHistory = List[ChatMessage]
# Schema for provider settings
OPENAI_COMPATIBLE_SETTINGS_SCHEMA = {
@Zetaphor
Zetaphor / mastodon.net_user_counts.js
Created November 18, 2024 17:54
Mastodon.net User Counts
const userCounts = [];
document.querySelectorAll('.fa-robot-astromech').forEach(el => {
const text = el.closest('p').innerText;
const count = parseInt(text.match(/[\d,]+/)[0].replace(/,/g, ''));
userCounts.push(count);
});
const totalUsers = userCounts.reduce((sum, count) => sum + count, 0);
console.log(`Total users: ${totalUsers.toLocaleString()}`);
@Zetaphor
Zetaphor / picosky-post.py
Created November 6, 2024 20:17
A (now outdated) example of creating a record using HTTP request for Picosky
import requests
from datetime import datetime
import re
# Bluesky API endpoints
BASE_URL = "https://bsky.social/xrpc"
LOGIN_URL = f"{BASE_URL}/com.atproto.server.createSession"
CREATE_RECORD_URL = f"{BASE_URL}/com.atproto.repo.createRecord"
# Updated lexicon definition
@Zetaphor
Zetaphor / tonejs-beat-generator.html
Last active August 7, 2024 18:32
ToneJS Beat Generator
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Intelligent Melody Generator</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tone/14.8.49/Tone.js"></script>
<style>
body {
@Zetaphor
Zetaphor / markov_chain.py
Created February 17, 2024 07:11
ChatGPT authored Markov Chain in Python
"""
Read a collection of JSON files from a directory as the inputs to a Markov Chain.
Also adds the user inputs to the dictionary as the conversation progresses.
Assumes it's using the formatted data from the NeoLLaMder project.
Written by ChatGPT
"""
import json
import random
import re
@Zetaphor
Zetaphor / docker-selenium.sh
Last active November 15, 2023 03:05
Music download automation
docker pull selenium/standalone-chrome
docker run -d -p 4444:4444 --shm-size=2g selenium/standalone-chrome
@Zetaphor
Zetaphor / keychron_linux.md
Created July 11, 2022 21:31 — forked from andrebrait/keychron_linux.md
Keychron keyboards on Linux + Bluetooth fixes

Here is the best setup (I think so :D) for K-series Keychron keyboards on Linux.

Most of these commands have been tested on Ubuntu 20.04 and should also work on most Debian-based distributions. If a command happens not to work for you, take a look in the comment section.

Make Fn + F-keys work

Keychron Keyboards on Linux use the hid_apple driver (even in Windows/Android mode), both in Bluetooth and Wired modes. By default, this driver uses the F-keys as multimedia shortcuts and you have to press Fn + the key to get the usual F1 through F12 keys.

@Zetaphor
Zetaphor / bash-sensors.sh
Last active October 29, 2021 21:21
Bash Sensors
echo 🌡 AMD: `sensors | grep 'edge:' | cut -c 16-18 | rev | cut -c 2-100 | rev`°C
echo 🌡 NVIDIA: `nvidia-smi -q -d temperature | grep 'GPU Current Temp' | cut -c 45-47 | xargs`°C
echo 🌡 2TB: `sensors | grep 'Composite:' | sed -n '1p' | cut -c 16-18 | rev | cut -c 2-10 | rev`°C
echo 🌡 1TB: `sensors | grep 'Composite:' | sed -n '2p' | cut -c 16-18 | rev | cut -c 2-10 | rev`°C
echo ⌬ CPU: `top -bn1 | sed -n '/Cpu/p' | awk '{print $2}' `%
echo ⌧ RAM `free -m | awk 'NR==2{printf "%.2fGB (%.2f%%)\n", $3/1024,$3*100/$2 }'`
echo 🌡 CPU `cat /sys/class/thermal/thermal_zone0/temp | sed 's/.\{3\}$/.&/' | rev | cut -c 5-10 | rev`°C
echo ֎ FAN: `sensors | grep cpu_fan | cut -c 17-100 | rev | cut -c 5-100 | rev | xargs`RPM
@Zetaphor
Zetaphor / test.json
Last active September 22, 2021 23:22
{
"MRData": {
"xmlns": "http:\/\/ergast.com\/mrd\/1.4",
"series": "f1",
"url": "http://ergast.com/api/f1/2018/circuits.json",
"limit": "30",
"offset": "0",
"total": "21",
"CircuitTable": {
"season": "2018",
@Zetaphor
Zetaphor / airdots.sh
Created October 16, 2019 19:42
Automatically reconnect bluetooth headphones
#!/bin/bash
##### CONFIGURATION #####
MAC="E8:EC:A3:30:0C:62"
MODE="connect"
#########################
STATUS=$(bluetoothctl info $MAC | grep "Connected" | awk '{print $2}')