Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / kindle_tana_paste_from_book_name.py
Last active March 7, 2023 09:13
Python script to be called by Espanso trigger, for importing kindle hightlights to Tana. Put this in C:\Users\[username]\AppData\Roaming\espanso\scripts
import json
import sys
sys.stdout.reconfigure(encoding='utf-8')
import io
import os
import traceback
from datetime import datetime
import re
booktitle = os.environ['ESPANSO_BOOKTITLE']
clippings_file = "E:/documents/My Clippings.txt"
@bitbutter
bitbutter / kindle_get_book_titles_from_clippings.py
Last active March 7, 2023 09:13
Python script to be called by Espanso trigger, for importing kindle hightlights to Tana. Put this in C:\Users\[username]\AppData\Roaming\espanso\scripts
import sys
sys.stdout.reconfigure(encoding='utf-8')
from datetime import datetime
# Open the clippings file and read its contents
with open("E:/documents/My Clippings.txt", "r", encoding="utf-8") as f:
contents = f.read()
# Split the contents into separate notes
notes = contents.split("==========\n")
@bitbutter
bitbutter / base.yml
Last active March 7, 2023 09:13
Espanso trigger for importing kindle highlights from connected device to Tana. Append this trigger to the file at [username]/AppData/Roaming/espanso/match
# append this to [username]/AppData/Roaming/espanso/match
- trigger: kindle_import_book_from_clippings
replace: "{{output}}"
vars:
- name: booktitles
type: script
params:
args:
- python
@bitbutter
bitbutter / base.yml
Created January 8, 2023 14:03
Espanso shortcut for converting latest kindle json to tana paste format
#add to C:\Users\username\AppData\Roaming\espanso\match\base.yml
- trigger: kindle_json_to_tanapaste
replace: "{{output}}"
vars:
- name: output
type: script
params:
args:
- python
- "%CONFIG%/scripts/kindle_json_to_tanapaste.py"
@bitbutter
bitbutter / kindle_json_to_tanapaste.py
Last active January 8, 2023 14:04
Convert kindle highlight .json file to tana paste format
#add to C:\Users\username\AppData\Roaming\espanso\scripts\
import json
import sys
sys.stdout.reconfigure(encoding='utf-8')
import io
import os
import traceback
def is_json_file(file):
filename, file_extension = os.path.splitext(file)
# Split the filename of the latest downloaded file into the base filename and file extension
@bitbutter
bitbutter / PerlinShake
Created April 13, 2015 13:37
Modified version of Michael G's PerlinShake
using UnityEngine;
using System.Collections;
public class PerlinShake : MonoBehaviour, IShaker {
public float duration = 0.5f;
public float speed = 1.0f;
public float magnitude = 0.1f;
public bool test = false;

Keybase proof

I hereby claim:

  • I am bitbutter on github.
  • I am tomaszkaye (https://keybase.io/tomaszkaye) on keybase.
  • I have a public key whose fingerprint is 5767 A274 4C66 82C9 40D1 BD50 87D1 D067 6D41 04E0

To claim this, I am signing this object: