Step 1: Activate htmx (link) for django: Render a csrf token somewhere Step 2: Create the form with hx-post Case: Targeting a container div Case: Loading states extension (docs) Setup: import script, set style to avoid flash, add header Disable submit, add a loading indicator
All posts by theptrk
Django and pgvector for semantic search
Goal: Semantic Search Setup pgvector You have a model with a field you want to make semantically searchable. Installation comes from: https://github.com/pgvector/pgvector-python Step: install pgvector on your machine Step: create a migration to activate Step: add a VectorField to your model Step: make migrations and migrate Setup sentence transformers for embeddings We will use the…
Can ChatGPT do math? NO! But why?
ChatGPT can “kind of” do math, but with limited precision. 1+1, 2+2, it’s great at these additions. Here’s GPT-3.5 Here’s GPT-4 But why? Interestingly, GPT knows the way it was trained and the inherent limitations of using a language model to produce accurate arithmetic.
How to create a chrome extension (react vite boilerplate)
How to use the boilerplate Step: Use a great boilerplate template Step: Copy the repo, change the details and you are set up! The 6 Areas of a chrome extension Step: Learn the different parts files in the “pages” directory content: stuff you want to add to the dom devtools: devtools tab AND panel: the…
Obsidian Vim remapping
How to create an “obsidian.vimrc” Step: download the plugin “obsidian-vimrc-support” (link) Step: create an “.obsidian.vimrc” file in your iCloud folder for obsidian Here are some mappings: Helpful links
GPT from scratch: Karpathy
Andrej Karpathy has an incredible video on building GPT from scratch. Here are cartoon notes covering the contents:
How to convert mov to mp4 with ffmpeg
When you record on Quicktime, that saves as .mov which is a SUPER huge file size. Notes:
How to use OpenAI whisper with python
OpenAI open sourced their speech recognition model: https://github.com/openai/whisper There are 5 sizes: tiny, base, small, medium, large Note: you need to pip install openai-whisper (pypi link) Here is code to transcribe an audio file
UserWarning: FP16 is not supported on CPU; using FP32 instead
warnings.warn(“FP16 is not supported on CPU; using FP32 instead”)
Q: Are you trying to use whisper on your Mac instead of a Google Colab? Short answer: Example: Source: https://github.com/openai/whisper/discussions/301
Create Django Project with scaffolding from Django Cookiecutter
I use Django Cookiecutter (link) 🍪 because its awesome! Find your python version Hit the github page to see what python version it supports, you should match whichever provider support you have. Create project: use pyenv to set python version Note: if your pyenv install –list is not listing the newest versions, you’ll need to…