Skip to content

Instantly share code, notes, and snippets.

@bitbutter
bitbutter / knowledge_extractor.py
Created April 24, 2023 14:46
A python console program that uses Chroma and OpenAI to query text files
import chromadb
import openai
import os
from tqdm import tqdm
import tiktoken
from chromadb.errors import NotEnoughElementsException
import re
from colorama import Fore, Style
# Instructions (assumes Windows OS)
@bitbutter
bitbutter / create_embeddings.py
Created July 30, 2023 16:53
create embeddings from tweets, then semantic search them
import json
import spacy
import zipfile
import os
import pickle
# File paths
zip_path = r"pathtotwitterarchive.zip" # Path to zipped twitter archive
extract_path = r"somepath\twitter_data" # Path to extract twitter data
embeddings_path = r"somepath\tweet_embeddings.pkl" # Path to save embeddings
@bitbutter
bitbutter / SignalWaiter.gd
Created July 8, 2024 08:25
A godot 4 class. Waits for multiple signals to be received before continuing
class_name SignalWaiter
signal AllFinished
# Internal variables
var _active_nodes = {}
var _signal_connections = {}
var _callables = []
## External method to add a node, its callable, and the signal to listen for.
@bitbutter
bitbutter / SignalGroup.gd
Last active November 17, 2025 09:06
SignalGroup. Wait for all of, or any of, an array of signals.
'''
Based on https://shaggydev.com/2025/06/12/godot-awaiting-signals/
# usage
var sigs=[
get_tree().create_timer(0.1).timeout,
get_tree().create_timer(0.1).timeout,
get_tree().create_timer(0.1).timeout,
]
@bitbutter
bitbutter / generate_tileset_collision_polygons.gd
Last active February 13, 2026 19:23
Auto-generates collision polygons from tile pixel alpha. 1. Add to your project. 2. Tune the params at the top of the script. 3. Right click the script in FileSystem tab, choose "Run".
@tool
extends EditorScript
## Auto-generate collision polygons from tile pixel alpha.
## Run from Script Editor: File > Run (Ctrl+Shift+X)
## Path to the TileSet resource to process.
const TILESET_PATH := "res://game_specific/resources/tilesets/greentileset.tres"
## Physics layer index to assign collision polygons to.